From d12f32c3e1a4a97cd3c5db4de864164b1d57de16 Mon Sep 17 00:00:00 2001 From: SABELOMAWELA Date: Wed, 23 Oct 2024 18:19:59 +0200 Subject: [PATCH] "Refactored RecipeDetail component: updated console logs, changed recipe data rendering, and removed nutrition tab" --- app/recipes/[id]/page.jsx | 59 ++++++++++++--------------------------- 1 file changed, 18 insertions(+), 41 deletions(-) diff --git a/app/recipes/[id]/page.jsx b/app/recipes/[id]/page.jsx index 59c2473..8c06f7d 100644 --- a/app/recipes/[id]/page.jsx +++ b/app/recipes/[id]/page.jsx @@ -11,13 +11,13 @@ const formatTime = (minutes) => { const RecipeDetail = ({ params }) => { const { id } = params; - const router = useRouter(); + const router = useRouter(); const [recipe, setRecipe] = useState(null); const [activeTab, setActiveTab] = useState("ingredients"); - - console.log("Recipe ID from params:", id); + // Log the ID to make sure it's correctly passed + console.log("Recipe ID from params:", id); // Log ID to verify it's correct useEffect(() => { const getRecipe = async () => { @@ -31,7 +31,7 @@ const RecipeDetail = ({ params }) => { throw new Error("Failed to fetch recipe"); } const data = await response.json(); - console.log(data.recipe, 'data') + console.log(data.recipe,'data') setRecipe(data.recipe); } catch (error) { console.error("Error fetching recipe:", error); @@ -69,25 +69,26 @@ const RecipeDetail = ({ params }) => {

{recipe.title}

- Discover how to make this delicious {recipe.title}. - {recipe.description || "any occasion"}. + Discover how to make this delicious {recipe.title}. Perfect for{" "} + {recipe.mealType || "any occasion"}.

- Prep Time: {formatTime(recipe.prep)} + Prep Time: {formatTime(recipe.prepTimeMinutes)}

- Cook Time: {formatTime(recipe.cook)} + Cook Time: {formatTime(recipe.cookTimeMinutes)} +

+

+ Total Time: {formatTime(totalTime)}

-

Category: {recipe.category}

Servings: {recipe.servings} servings

-

Published: {new Date(recipe.published).toLocaleDateString()}

-