mealie/frontend/composables/store/use-tool-store.ts
Michael Genson e9892aba89
feat: Move "on hand" and "last made" to household (#4616)
Co-authored-by: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com>
2025-01-13 17:19:49 +01:00

33 lines
941 B
TypeScript

import { ref, Ref } from "@nuxtjs/composition-api";
import { useData, useReadOnlyStore, useStore } from "../partials/use-store-factory";
import { RecipeTool } from "~/lib/api/types/recipe";
import { usePublicExploreApi, useUserApi } from "~/composables/api";
interface RecipeToolWithOnHand extends RecipeTool {
onHand: boolean;
}
const store: Ref<RecipeTool[]> = ref([]);
const loading = ref(false);
const publicLoading = ref(false);
export const useToolData = function () {
return useData<RecipeToolWithOnHand>({
id: "",
name: "",
slug: "",
onHand: false,
householdsWithTool: [],
});
}
export const useToolStore = function () {
const api = useUserApi();
return useStore<RecipeTool>(store, loading, api.tools);
}
export const usePublicToolStore = function (groupSlug: string) {
const api = usePublicExploreApi(groupSlug).explore;
return useReadOnlyStore<RecipeTool>(store, publicLoading, api.tools);
}