-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
NiceygyLive
committed
Feb 8, 2024
1 parent
4f20a24
commit d9a4703
Showing
5 changed files
with
61 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,35 @@ | ||
import { getRecipe } from "@/api/recipe/functions"; | ||
import { useRouter } from "next/router"; | ||
import { useEffect, useState } from "react"; | ||
import { Recipe } from "@/api/recipe/functions"; | ||
|
||
|
||
export default function View() { | ||
const router = useRouter(); | ||
const { id } = router.query; | ||
if (!id) { | ||
return <h1>Invalid recipe ID</h1>; | ||
} else { | ||
let rid = id.toString().split("-")[0]; | ||
let uid = id.toString().split("-")[1]; | ||
|
||
const [recipe, setRecipe] = useState<Recipe | null>(null); | ||
useEffect(() => { | ||
if (id) { | ||
getRecipe(rid.toString(), uid).then((recipe) => { | ||
setRecipe(recipe); | ||
}); | ||
} | ||
}, [id]); | ||
} | ||
return ( | ||
<div> | ||
<h1>View</h1> | ||
<p>Recipe ID: {id}</p> | ||
<p>Recipe: {Recipe?.name}</p> | ||
<p>Ingredents:{Recipe?.ingredents}</p> | ||
<p>Instructions:{Recipe?.instructions[0]}</p> | ||
|
||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters