2025-07-08 08:32:18 -05:00
|
|
|
import type { Composer } from "vue-i18n";
|
2025-06-24 02:36:40 -05:00
|
|
|
import { useReadOnlyStore, useStore } from "../partials/use-store-factory";
|
|
|
|
import type { RecipeCookBook } from "~/lib/api/types/cookbook";
|
|
|
|
import { usePublicExploreApi, useUserApi } from "~/composables/api";
|
|
|
|
|
|
|
|
const store: Ref<RecipeCookBook[]> = ref([]);
|
|
|
|
const loading = ref(false);
|
|
|
|
const publicLoading = ref(false);
|
|
|
|
|
2025-07-08 08:32:18 -05:00
|
|
|
export const useCookbookStore = function (i18n?: Composer) {
|
|
|
|
const api = useUserApi(i18n);
|
2025-06-24 02:36:40 -05:00
|
|
|
return useStore<RecipeCookBook>(store, loading, api.cookbooks);
|
|
|
|
};
|
|
|
|
|
2025-07-08 08:32:18 -05:00
|
|
|
export const usePublicCookbookStore = function (groupSlug: string, i18n?: Composer) {
|
|
|
|
const api = usePublicExploreApi(groupSlug, i18n).explore;
|
2025-06-24 02:36:40 -05:00
|
|
|
return useReadOnlyStore<RecipeCookBook>(store, publicLoading, api.cookbooks);
|
|
|
|
};
|