2024-09-22 09:59:20 -05:00
|
|
|
import { ref, Ref } from "@nuxtjs/composition-api";
|
|
|
|
import { useData, useReadOnlyStore, useStore } from "../partials/use-store-factory";
|
2022-10-22 11:51:07 -08:00
|
|
|
import { IngredientFood } from "~/lib/api/types/recipe";
|
2024-09-22 09:59:20 -05:00
|
|
|
import { usePublicExploreApi, useUserApi } from "~/composables/api";
|
2022-05-29 17:29:59 -08:00
|
|
|
|
2024-09-22 09:59:20 -05:00
|
|
|
const store: Ref<IngredientFood[]> = ref([]);
|
|
|
|
const loading = ref(false);
|
|
|
|
const publicLoading = ref(false);
|
2022-05-29 17:29:59 -08:00
|
|
|
|
|
|
|
export const useFoodData = function () {
|
2024-09-22 09:59:20 -05:00
|
|
|
return useData<IngredientFood>({
|
2022-05-29 17:29:59 -08:00
|
|
|
id: "",
|
|
|
|
name: "",
|
|
|
|
description: "",
|
|
|
|
labelId: undefined,
|
|
|
|
});
|
2024-09-22 09:59:20 -05:00
|
|
|
}
|
2023-09-14 09:01:24 -05:00
|
|
|
|
2022-05-29 17:29:59 -08:00
|
|
|
export const useFoodStore = function () {
|
|
|
|
const api = useUserApi();
|
2024-09-22 09:59:20 -05:00
|
|
|
return useStore<IngredientFood>(store, loading, api.foods);
|
|
|
|
}
|
2022-05-29 17:29:59 -08:00
|
|
|
|
2024-09-22 09:59:20 -05:00
|
|
|
export const usePublicFoodStore = function (groupSlug: string) {
|
|
|
|
const api = usePublicExploreApi(groupSlug).explore;
|
|
|
|
return useReadOnlyStore<IngredientFood>(store, publicLoading, api.foods);
|
|
|
|
}
|