centralize all routes
This commit is contained in:
parent
5726bdb154
commit
a10f3e37c2
5 changed files with 53 additions and 24 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue