2025-07-08 08:32:18 -05:00
|
|
|
import type { Composer } from "vue-i18n";
|
2024-09-22 09:59:20 -05:00
|
|
|
import { useReadOnlyStore } from "../partials/use-store-factory";
|
2025-06-20 00:09:12 +07:00
|
|
|
import type { HouseholdSummary } from "~/lib/api/types/household";
|
2024-09-22 09:59:20 -05:00
|
|
|
import { usePublicExploreApi, useUserApi } from "~/composables/api";
|
|
|
|
|
|
|
|
const store: Ref<HouseholdSummary[]> = ref([]);
|
|
|
|
const loading = ref(false);
|
|
|
|
const publicLoading = ref(false);
|
|
|
|
|
2025-07-08 08:32:18 -05:00
|
|
|
export const useHouseholdStore = function (i18n?: Composer) {
|
|
|
|
const api = useUserApi(i18n);
|
2024-09-22 09:59:20 -05:00
|
|
|
return useReadOnlyStore<HouseholdSummary>(store, loading, api.households);
|
2025-06-20 00:09:12 +07:00
|
|
|
};
|
2024-09-22 09:59:20 -05:00
|
|
|
|
2025-07-08 08:32:18 -05:00
|
|
|
export const usePublicHouseholdStore = function (groupSlug: string, i18n?: Composer) {
|
|
|
|
const api = usePublicExploreApi(groupSlug, i18n).explore;
|
2024-09-22 09:59:20 -05:00
|
|
|
return useReadOnlyStore<HouseholdSummary>(store, publicLoading, api.households);
|
2025-06-20 00:09:12 +07:00
|
|
|
};
|