1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-05 05:25:26 +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:
Hoa (Kyle) Trinh 2025-06-20 00:09:12 +07:00 committed by GitHub
parent 89ab7fac25
commit c24d532608
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
403 changed files with 23959 additions and 19557 deletions

View file

@ -1,27 +1,26 @@
import { useAsync, ref, Ref, watch, useContext } from "@nuxtjs/composition-api";
import { format } from "date-fns";
import { useAsyncKey } from "./use-utils";
import { useUserApi } from "~/composables/api";
import { CreatePlanEntry, PlanEntryType, UpdatePlanEntry } from "~/lib/api/types/meal-plan";
import type { CreatePlanEntry, PlanEntryType, UpdatePlanEntry } from "~/lib/api/types/meal-plan";
type PlanOption = {
text: string;
value: PlanEntryType;
};
export function usePlanTypeOptions() {
const { i18n } = useContext();
const i18n = useI18n();
return [
{ text: i18n.tc("meal-plan.breakfast"), value: "breakfast" },
{ text: i18n.tc("meal-plan.lunch"), value: "lunch" },
{ text: i18n.tc("meal-plan.dinner"), value: "dinner" },
{ text: i18n.tc("meal-plan.side"), value: "side" },
{ text: i18n.t("meal-plan.breakfast"), value: "breakfast" },
{ text: i18n.t("meal-plan.lunch"), value: "lunch" },
{ text: i18n.t("meal-plan.dinner"), value: "dinner" },
{ text: i18n.t("meal-plan.side"), value: "side" },
] as PlanOption[];
}
export function getEntryTypeText(value: PlanEntryType) {
const { i18n } = useContext();
return i18n.tc("meal-plan." + value);
const i18n = useI18n();
return i18n.t("meal-plan." + value);
}
export interface DateRange {
start: Date;
@ -36,7 +35,7 @@ export const useMealplans = function (range: Ref<DateRange>) {
const actions = {
getAll() {
loading.value = true;
const units = useAsync(async () => {
const { data: units } = useAsyncData(useAsyncKey(), async () => {
const query = {
start_date: format(range.value.start, "yyyy-MM-dd"),
end_date: format(range.value.end, "yyyy-MM-dd"),
@ -45,15 +44,16 @@ export const useMealplans = function (range: Ref<DateRange>) {
if (data) {
return data.items;
} else {
}
else {
return null;
}
}, useAsyncKey());
});
loading.value = false;
return units;
},
async refreshAll(this: void) {
async refreshAll() {
loading.value = true;
const query = {
start_date: format(range.value.start, "yyyy-MM-dd"),