mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-24 23:59:45 +02:00
Consolidate frontend types (#1245)
This commit is contained in:
parent
6a88a59981
commit
479900e912
74 changed files with 261 additions and 582 deletions
|
@ -2,9 +2,7 @@ import { useAsync, ref, Ref, watch } from "@nuxtjs/composition-api";
|
|||
import { format } from "date-fns";
|
||||
import { useAsyncKey } from "./use-utils";
|
||||
import { useUserApi } from "~/composables/api";
|
||||
import { CreateMealPlan, UpdateMealPlan } from "~/api/class-interfaces/group-mealplan";
|
||||
|
||||
export type MealType = "breakfast" | "lunch" | "dinner" | "side";
|
||||
import { CreatePlanEntry, PlanEntryType, UpdatePlanEntry } from "~/types/api-types/meal-plan";
|
||||
|
||||
export const planTypeOptions = [
|
||||
{ text: "Breakfast", value: "breakfast" },
|
||||
|
@ -55,7 +53,7 @@ export const useMealplans = function (range: Ref<DateRange>) {
|
|||
|
||||
loading.value = false;
|
||||
},
|
||||
async createOne(payload: CreateMealPlan) {
|
||||
async createOne(payload: CreatePlanEntry) {
|
||||
loading.value = true;
|
||||
|
||||
const { data } = await api.mealplans.createOne(payload);
|
||||
|
@ -65,13 +63,12 @@ export const useMealplans = function (range: Ref<DateRange>) {
|
|||
|
||||
loading.value = false;
|
||||
},
|
||||
async updateOne(updateData: UpdateMealPlan) {
|
||||
async updateOne(updateData: UpdatePlanEntry) {
|
||||
if (!updateData.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
// @ts-ignore TODO Modify mealpan types to be from auto-generated files
|
||||
const { data } = await api.mealplans.updateOne(updateData.id, updateData);
|
||||
if (data) {
|
||||
this.refreshAll();
|
||||
|
@ -87,8 +84,8 @@ export const useMealplans = function (range: Ref<DateRange>) {
|
|||
}
|
||||
},
|
||||
|
||||
async setType(payload: UpdateMealPlan, typ: MealType) {
|
||||
payload.entryType = typ;
|
||||
async setType(payload: UpdatePlanEntry, type: PlanEntryType) {
|
||||
payload.entryType = type;
|
||||
await this.updateOne(payload);
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue