mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-04-13 00:15:34 -04:00
chore: Nuxt 4 upgrade (#7426)
This commit is contained in:
38
frontend/app/composables/store/use-tool-store.ts
Normal file
38
frontend/app/composables/store/use-tool-store.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import type { Composer } from "vue-i18n";
|
||||
import { useData, useReadOnlyStore, useStore } from "../partials/use-store-factory";
|
||||
import type { 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 function resetToolStore() {
|
||||
store.value = [];
|
||||
loading.value = false;
|
||||
publicLoading.value = false;
|
||||
}
|
||||
|
||||
export const useToolData = function () {
|
||||
return useData<RecipeToolWithOnHand>({
|
||||
id: "",
|
||||
name: "",
|
||||
slug: "",
|
||||
onHand: false,
|
||||
householdsWithTool: [],
|
||||
});
|
||||
};
|
||||
|
||||
export const useToolStore = function (i18n?: Composer) {
|
||||
const api = useUserApi(i18n);
|
||||
return useStore<RecipeTool>("tool", store, loading, api.tools);
|
||||
};
|
||||
|
||||
export const usePublicToolStore = function (groupSlug: string, i18n?: Composer) {
|
||||
const api = usePublicExploreApi(groupSlug, i18n).explore;
|
||||
return useReadOnlyStore<RecipeTool>("tool", store, publicLoading, api.tools);
|
||||
};
|
||||
Reference in New Issue
Block a user