import { itGetCached } from "@/fetchHelpers";
import type { Ref } from "vue";
import { ref } from "vue";

export type Organisation = {
  id: number;
  name: string;
};

export type Country = {
  id: number;
  name: string;
};

export function useEntities() {
  const countries: Ref<Country[]> = ref([]);
  const organisations: Ref<Organisation[]> = ref([]);

  itGetCached("/api/core/entities/").then((res) => {
    countries.value = res.countries;
    organisations.value = res.organisations;
  });

  return { organisations, countries };
}
