import { JsonObject } from '@win2win/shared';
import { useFetch } from '@win2win/shared-ui';
import { computed } from 'vue';

export function usePaises() {
  const queryKey = ['paises', 'all'];
  const url = `/paises/all`;
  const { data, fetching } = useFetch<JsonObject[]>(queryKey, url, {}, undefined, { defaultValue: [] });
  const options = computed(() => (data.value || []).map((item) => ({ label: item.NOMBRE, value: item.ID_PAIS })));
  return {
    data,
    options,
    fetching,
  };
}
