mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-24 23:59:45 +02:00
Some checks are pending
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Docker Nightly Production / Backend Server Tests (push) Waiting to run
Docker Nightly Production / Frontend and End-to-End Tests (push) Waiting to run
Docker Nightly Production / Build Tagged Release (push) Blocked by required conditions
Docker Nightly Production / Notify Discord (push) Blocked by required conditions
* labels bulk delete * add foods * bulk delete units * add categories * add tags * add tools * update translations * fix types for text * fix reactivity for stores --------- Co-authored-by: Hayden <64056131+hay-kot@users.noreply.github.com>
49 lines
975 B
TypeScript
49 lines
975 B
TypeScript
import { reactive, ref, Ref } from "@nuxtjs/composition-api";
|
|
import { useStoreActions } from "../partials/use-actions-factory";
|
|
import { MultiPurposeLabelOut } from "~/lib/api/types/labels";
|
|
import { useUserApi } from "~/composables/api";
|
|
|
|
let labelStore: Ref<MultiPurposeLabelOut[] | null> = ref([]);
|
|
|
|
export function useLabelData() {
|
|
const data = reactive({
|
|
groupId: "",
|
|
id: "",
|
|
name: "",
|
|
color: "",
|
|
});
|
|
|
|
function reset() {
|
|
data.groupId = "";
|
|
data.id = "";
|
|
data.name = "";
|
|
data.color = "";
|
|
}
|
|
|
|
return {
|
|
data,
|
|
reset,
|
|
};
|
|
}
|
|
|
|
export function useLabelStore() {
|
|
const api = useUserApi();
|
|
const loading = ref(false);
|
|
|
|
const actions = {
|
|
...useStoreActions<MultiPurposeLabelOut>(api.multiPurposeLabels, labelStore, loading),
|
|
flushStore() {
|
|
labelStore.value =[];
|
|
},
|
|
};
|
|
|
|
if (!labelStore.value) {
|
|
labelStore = actions.getAll();
|
|
}
|
|
|
|
return {
|
|
labels: labelStore,
|
|
actions,
|
|
loading,
|
|
};
|
|
}
|