1
0
Fork 0
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:
Philipp Fischbeck 2022-05-21 21:22:02 +02:00 committed by GitHub
parent 6a88a59981
commit 479900e912
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
74 changed files with 261 additions and 582 deletions

View file

@ -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);
},
};