import { Id } from '@win2win/shared';
import { useStoreLite } from 'src/widgets/useStoreLite';
import { computed } from 'vue';
import { useRoute } from 'vue-router';

export function useIdGama() {
  const route = useRoute();
  const routeIdGama = computed(() => {
    const id = route.query.gamaId;
    if (!id || isNaN(Number(id))) {
      return null;
    }
    return Number(id) as Id;
  });

  const { idGama: activeIdGama } = useStoreLite();
  const idGama = computed(() => (activeIdGama.value || routeIdGama.value) as Id | null);
  return idGama;
}
