renamed models, added mapper for recipes

This commit is contained in:
Anika Raemer 2025-10-07 20:53:31 +02:00
parent 7a6f5b5bcd
commit 8027fce80d
21 changed files with 164 additions and 61 deletions

View file

@ -0,0 +1,19 @@
import type { IngredientModel } from "./IngredientModel"
/**
* A group of ingredients
* Consisting of title and ingredient list, this interface is used to group
* the ingredients for a specific part of the dish, e.g., dough, filling and
* icing of a cake
*/
export interface IngredientGroupModel {
id?: string
/**
* Title of the group describing its purpose
* The title is optional as recipes consisting of a single ingredient group usually don't
* supply a title
*/
title? : string
/** Ingredients */
ingredientList : IngredientModel[]
}

View file

@ -0,0 +1,16 @@
/**
* Represents a single ingredient in a recipe.
*/
export interface IngredientModel {
id?: string
/** Name of the ingredient (e.g. "Spaghetti") */
name: string
/** Quantity required (e.g. 200, 1.5) */
amount: number
/** Unit of measurement (e.g. "g", "tbsp", "cups").
* Optional for cases like "1 egg".
*/
unit?: string
}

View file

@ -0,0 +1,35 @@
import type { IngredientGroupModel } from "./IngredientGroupModel"
import type { ServingsModel } from "./ServingsModel"
/**
* Represents a recipe object in the application.
*/
/*
* @todo ingredient groups! There may be serveral ingredient lists, each with a title.
* e.g. for the dough, for the filling, for the icing,...
* - add type ingredient group with an optional title and a list of ingredients
* - adapt RecipeDetailView
* - add an IngredientGroupListEditor for handling IngredientGroups
*/
export interface RecipeModel {
/** Unique identifier for the recipe */
id?: string
/** Title of the recipe */
title: string
/** List of ingredients groups containing the ingredients of the recipe */
ingredientGroupList: IngredientGroupModel[]
/** Preparation instructions */
instructions: string
/** Number of servings, e.g., for 4 person, 12 cupcakes, 2 glasses */
servings: ServingsModel
/** Unit for the quantity */
/** Optional image URL for the recipe */
imageUrl?: string
}

View file

@ -0,0 +1,12 @@
/**
* Defines how many servings of the dish are prepared when following the recipe
*/
export interface ServingsModel{
/** Amount of servings */
amount: number,
/** Unit, e.g. 4 persons, 2 glasses, 12 cupcakes */
unit: string
}