centralize all routes

This commit is contained in:
Anika Raemer 2025-09-13 10:19:11 +02:00
parent 5726bdb154
commit a10f3e37c2
5 changed files with 53 additions and 24 deletions

View file

@ -3,6 +3,7 @@ import { useEffect, useState } from "react"
import type { Recipe } from "../../types/recipe"
import RecipeEditor from "./RecipeEditor"
import { fetchRecipe, createRecipe, updateRecipe } from "../../api/recipePoint"
import { getRecipeDetailUrl, getRecipeListUrl, getRootUrl } from "../../routes"
export default function RecipeEditPage() {
// Extract recipe ID from route params
@ -62,10 +63,10 @@ export default function RecipeEditPage() {
const navigateBack = () => {
if(recipe && recipe.id){
console.log("navigating to recipe with id", recipe.id)
navigate("/recipe/" + recipe.id) // go back to detail view
navigate(getRecipeDetailUrl(recipe.id)) // go back to detail view
} else {
console.log("navigating back to list as no recipe was selected")
navigate("/") // no recipe -> go back to list
navigate(getRecipeListUrl()) // no recipe -> go back to list
}
}
// error handling -> if there is no recipe, we cannot open edit view