diff --git a/frontend/src/App.css b/frontend/src/App.css index 4efbe93..240b32e 100644 --- a/frontend/src/App.css +++ b/frontend/src/App.css @@ -59,7 +59,7 @@ /* input field */ .input-field { - @apply border p-2 w-full mb-2 rounded placeholder-gray-400; + @apply border p-2 w-full rounded placeholder-gray-400; } .text-area { @@ -72,7 +72,7 @@ } /* lists */ - .default-list-item { + .default-list { @apply list-disc pl-6 mb-6 } diff --git a/frontend/src/components/RecipeDetailView.tsx b/frontend/src/components/RecipeDetailView.tsx index 5b9e7c9..e92e24f 100644 --- a/frontend/src/components/RecipeDetailView.tsx +++ b/frontend/src/components/RecipeDetailView.tsx @@ -1,5 +1,8 @@ import { useParams, Link } from "react-router-dom" import { recipes } from "../mock_data/recipes" +import type { Recipe } from "../types/recipe" +import { useState } from "react" + /** * Displays the full detail of a single recipe, @@ -10,28 +13,66 @@ export default function RecipeDetailView() { const { id } = useParams<{ id: string }>() const recipe = recipes.find((r) => r.id === id) + if (!recipe) { return
Recipe not found.
} - return ( + // Working copy for re-calculating ingredients + const [recipeWorkingCopy, updateRecipeWorkingCopy] = useStateFor {recipeWorkingCopy.servings.amount} {recipeWorkingCopy.servings.unit}
+ { + recalculateIngredients(Number(e.target.value)) + } + } + /> +For {recipe.servings.amount} {recipe.servings.unit}
-{recipe.instructions}
+{recipeWorkingCopy.instructions}
{/* Action buttons */}