mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-24 15:49:42 +02:00
Consolidate frontend types (#1245)
This commit is contained in:
parent
6a88a59981
commit
479900e912
74 changed files with 261 additions and 582 deletions
|
@ -1,5 +1,5 @@
|
|||
import { BaseCRUDAPI } from "../_base";
|
||||
import { CreatRandomEntry } from "~/types/api-types/meal-plan";
|
||||
import { CreatePlanEntry, CreateRandomEntry, ReadPlanEntry, UpdatePlanEntry } from "~/types/api-types/meal-plan";
|
||||
|
||||
const prefix = "/api";
|
||||
|
||||
|
@ -9,31 +9,12 @@ const routes = {
|
|||
mealplanId: (id: string | number) => `${prefix}/groups/mealplans/${id}`,
|
||||
};
|
||||
|
||||
type PlanEntryType = "breakfast" | "lunch" | "dinner" | "side";
|
||||
|
||||
export interface CreateMealPlan {
|
||||
date: string;
|
||||
entryType: PlanEntryType;
|
||||
title: string;
|
||||
text: string;
|
||||
recipeId?: string;
|
||||
}
|
||||
|
||||
export interface UpdateMealPlan extends CreateMealPlan {
|
||||
id: number;
|
||||
groupId: number;
|
||||
}
|
||||
|
||||
export interface MealPlan extends UpdateMealPlan {
|
||||
recipe: any;
|
||||
}
|
||||
|
||||
export class MealPlanAPI extends BaseCRUDAPI<MealPlan, CreateMealPlan> {
|
||||
export class MealPlanAPI extends BaseCRUDAPI<CreatePlanEntry, ReadPlanEntry, UpdatePlanEntry> {
|
||||
baseRoute = routes.mealplan;
|
||||
itemRoute = routes.mealplanId;
|
||||
|
||||
async setRandom(payload: CreatRandomEntry) {
|
||||
async setRandom(payload: CreateRandomEntry) {
|
||||
console.log(payload);
|
||||
return await this.requests.post<MealPlan>(routes.random, payload);
|
||||
return await this.requests.post<ReadPlanEntry>(routes.random, payload);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue