mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-05 13:35:23 +02:00
feat: Migrate to Nuxt 3 framework (#5184)
Co-authored-by: Michael Genson <71845777+michael-genson@users.noreply.github.com> Co-authored-by: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com>
This commit is contained in:
parent
89ab7fac25
commit
c24d532608
403 changed files with 23959 additions and 19557 deletions
|
@ -1,6 +1,5 @@
|
|||
import { computed, ref, Ref, useAsync } from "@nuxtjs/composition-api";
|
||||
import { useAdminApi, useUserApi } from "~/composables/api";
|
||||
import { HouseholdCreate, HouseholdInDB } from "~/lib/api/types/household";
|
||||
import type { HouseholdCreate, HouseholdInDB } from "~/lib/api/types/household";
|
||||
|
||||
const householdSelfRef = ref<HouseholdInDB | null>(null);
|
||||
const loading = ref(false);
|
||||
|
@ -53,15 +52,16 @@ export const useAdminHouseholds = function () {
|
|||
function getAllHouseholds() {
|
||||
loading.value = true;
|
||||
const asyncKey = String(Date.now());
|
||||
const households = useAsync(async () => {
|
||||
const { data } = await api.households.getAll(1, -1, {orderBy: "name, group.name", orderDirection: "asc"});
|
||||
const { data: households } = useAsyncData(asyncKey, async () => {
|
||||
const { data } = await api.households.getAll(1, -1, { orderBy: "name, group.name", orderDirection: "asc" });
|
||||
|
||||
if (data) {
|
||||
return data.items;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}, asyncKey);
|
||||
});
|
||||
|
||||
loading.value = false;
|
||||
return households;
|
||||
|
@ -69,12 +69,13 @@ export const useAdminHouseholds = function () {
|
|||
|
||||
async function refreshAllHouseholds() {
|
||||
loading.value = true;
|
||||
const { data } = await api.households.getAll(1, -1, {orderBy: "name, group.name", orderDirection: "asc"});;
|
||||
const { data } = await api.households.getAll(1, -1, { orderBy: "name, group.name", orderDirection: "asc" }); ;
|
||||
|
||||
if (data) {
|
||||
households.value = data.items;
|
||||
} else {
|
||||
households.value = null;
|
||||
}
|
||||
else {
|
||||
households.value = null;
|
||||
}
|
||||
|
||||
loading.value = false;
|
||||
|
@ -93,7 +94,7 @@ export const useAdminHouseholds = function () {
|
|||
const { data } = await api.households.createOne(payload);
|
||||
|
||||
if (data && households.value) {
|
||||
households.value.push(data);
|
||||
households.value.push(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,8 +103,8 @@ export const useAdminHouseholds = function () {
|
|||
return computed(
|
||||
() => {
|
||||
return (households.value && groupIdRef.value)
|
||||
? households.value.filter((h) => h.groupId === groupIdRef.value)
|
||||
: [];
|
||||
? households.value.filter(h => h.groupId === groupIdRef.value)
|
||||
: [];
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue