renamed models, added mapper for recipes
This commit is contained in:
parent
7a6f5b5bcd
commit
8027fce80d
21 changed files with 164 additions and 61 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import type { Recipe } from "../../types/recipe"
|
||||
import type { RecipeDto } from "../dtos/RecipeDto";
|
||||
import { get, postJson, putJson } from "../utils/requests";
|
||||
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ const RECIPE_URL = `${BASE_URL}/recipe`
|
|||
* @param id ID of the recipe to load
|
||||
* @returns A single recipe
|
||||
*/
|
||||
export async function fetchRecipe(id: string): Promise<Recipe> {
|
||||
export async function fetchRecipe(id: string): Promise<RecipeDto> {
|
||||
const res = await get(`${RECIPE_URL}/${id}`)
|
||||
return res.json()
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ export async function fetchRecipe(id: string): Promise<Recipe> {
|
|||
* @param recipe Recipe to create
|
||||
* @returns Saved recipe
|
||||
*/
|
||||
export async function createRecipe(recipe: Recipe): Promise<Recipe> {
|
||||
export async function createRecipe(recipe: RecipeDto): Promise<RecipeDto> {
|
||||
const res = await postJson(RECIPE_URL, JSON.stringify(recipe));
|
||||
return res.json();
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ export async function createRecipe(recipe: Recipe): Promise<Recipe> {
|
|||
* @param recipe Recipe to save. This recipe must have an ID!
|
||||
* @returns Saved recipe
|
||||
*/
|
||||
export async function updateRecipe(recipe: Recipe): Promise<Recipe> {
|
||||
export async function updateRecipe(recipe: RecipeDto): Promise<RecipeDto> {
|
||||
const res = await putJson(`${RECIPE_URL}/${recipe.id}`, JSON.stringify(recipe));
|
||||
return res.json();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue