mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-02 12:05:21 +02:00
Co-authored-by: Michael Genson <71845777+michael-genson@users.noreply.github.com> Co-authored-by: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com>
25 lines
808 B
TypeScript
25 lines
808 B
TypeScript
import { useData, useReadOnlyStore, useStore } from "../partials/use-store-factory";
|
|
import type { RecipeCategory } from "~/lib/api/types/recipe";
|
|
import { usePublicExploreApi, useUserApi } from "~/composables/api";
|
|
|
|
const store: Ref<RecipeCategory[]> = ref([]);
|
|
const loading = ref(false);
|
|
const publicLoading = ref(false);
|
|
|
|
export const useCategoryData = function () {
|
|
return useData<RecipeCategory>({
|
|
id: "",
|
|
name: "",
|
|
slug: "",
|
|
});
|
|
};
|
|
|
|
export const useCategoryStore = function () {
|
|
const api = useUserApi();
|
|
return useStore<RecipeCategory>(store, loading, api.categories);
|
|
};
|
|
|
|
export const usePublicCategoryStore = function (groupSlug: string) {
|
|
const api = usePublicExploreApi(groupSlug).explore;
|
|
return useReadOnlyStore<RecipeCategory>(store, publicLoading, api.categories);
|
|
};
|