mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-02-23 18:37:23 -08:00
28 lines
861 B
TypeScript
28 lines
861 B
TypeScript
import { ref, Ref } from "@nuxtjs/composition-api";
|
|
import { useData, useReadOnlyStore, useStore } from "../partials/use-store-factory";
|
|
import { IngredientFood } from "~/lib/api/types/recipe";
|
|
import { usePublicExploreApi, useUserApi } from "~/composables/api";
|
|
|
|
const store: Ref<IngredientFood[]> = ref([]);
|
|
const loading = ref(false);
|
|
const publicLoading = ref(false);
|
|
|
|
export const useFoodData = function () {
|
|
return useData<IngredientFood>({
|
|
id: "",
|
|
name: "",
|
|
description: "",
|
|
labelId: undefined,
|
|
});
|
|
}
|
|
|
|
export const useFoodStore = function () {
|
|
const api = useUserApi();
|
|
return useStore<IngredientFood>(store, loading, api.foods);
|
|
}
|
|
|
|
export const usePublicFoodStore = function (groupSlug: string) {
|
|
const api = usePublicExploreApi(groupSlug).explore;
|
|
return useReadOnlyStore<IngredientFood>(store, publicLoading, api.foods);
|
|
}
|