switch to createOrUpdate endpoint
This commit is contained in:
parent
8027fce80d
commit
47ffe8c74d
3 changed files with 9 additions and 31 deletions
|
|
@ -2,7 +2,7 @@ import { useParams, useNavigate } from "react-router-dom"
|
|||
import { useEffect, useState } from "react"
|
||||
import type { RecipeModel } from "../../models/RecipeModel"
|
||||
import RecipeEditor from "./RecipeEditor"
|
||||
import { fetchRecipe, createRecipe, updateRecipe } from "../../api/points/RecipePoint"
|
||||
import { fetchRecipe, createOrUpdateRecipe } from "../../api/points/RecipePoint"
|
||||
import { getRecipeDetailUrl, getRecipeListUrl } from "../../routes"
|
||||
import { mapRecipeDtoToModel, mapRecipeModelToDto } from "../../mappers/recipeMapper"
|
||||
import type { RecipeDto } from "../../api/dtos/RecipeDto"
|
||||
|
|
@ -45,11 +45,7 @@ export default function RecipeEditPage() {
|
|||
const handleSave = async (updated: RecipeModel) => {
|
||||
try {
|
||||
const dto = mapRecipeModelToDto(updated);
|
||||
if (updated.id) {
|
||||
await updateRecipe(dto)
|
||||
} else {
|
||||
await createRecipe(dto)
|
||||
}
|
||||
await createOrUpdateRecipe(dto);
|
||||
navigateBack();
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue