2024-09-22 09:59:20 -05:00
|
|
|
import { useData, useStore } from "../partials/use-store-factory";
|
2025-06-20 00:09:12 +07:00
|
|
|
import type { IngredientUnit } from "~/lib/api/types/recipe";
|
2024-09-22 09:59:20 -05:00
|
|
|
import { useUserApi } from "~/composables/api";
|
2022-05-29 17:29:59 -08:00
|
|
|
|
2024-09-22 09:59:20 -05:00
|
|
|
const store: Ref<IngredientUnit[]> = ref([]);
|
|
|
|
const loading = ref(false);
|
2022-05-29 17:29:59 -08:00
|
|
|
|
|
|
|
export const useUnitData = function () {
|
2024-09-22 09:59:20 -05:00
|
|
|
return useData<IngredientUnit>({
|
2022-05-29 17:29:59 -08:00
|
|
|
id: "",
|
|
|
|
name: "",
|
|
|
|
fraction: true,
|
|
|
|
abbreviation: "",
|
|
|
|
description: "",
|
|
|
|
});
|
2025-06-20 00:09:12 +07:00
|
|
|
};
|
2022-05-29 17:29:59 -08:00
|
|
|
|
|
|
|
export const useUnitStore = function () {
|
|
|
|
const api = useUserApi();
|
2024-09-22 09:59:20 -05:00
|
|
|
return useStore<IngredientUnit>(store, loading, api.units);
|
2025-06-20 00:09:12 +07:00
|
|
|
};
|