From 056508b68b48fee2a5ee4157f81db794dc6589d9 Mon Sep 17 00:00:00 2001 From: Amalie Date: Thu, 1 Oct 2026 12:53:45 +0200 Subject: [PATCH] Legg til oppskriftsside med ingredienser, steg og tags (#28) --- client/src/components/recipe/RecipeDetail.tsx | 55 +++++++++++++++++++ client/src/routes/RecipeDetailPage.tsx | 8 ++- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 client/src/components/recipe/RecipeDetail.tsx diff --git a/client/src/components/recipe/RecipeDetail.tsx b/client/src/components/recipe/RecipeDetail.tsx new file mode 100644 index 0000000..2ab59c5 --- /dev/null +++ b/client/src/components/recipe/RecipeDetail.tsx @@ -0,0 +1,55 @@ +import type { Recipe } from '../../types/recipe'; + +// Sier hva komponenten får inn. +type RecipeDetailProps = { + recipe: Recipe; +}; + +export function RecipeDetail({ recipe }: RecipeDetailProps) { + return ( +
+
+

{recipe.title}

+
+

{recipe.prepTime} minutter

+

{recipe.portions} porsjoner

+
+
+

{recipe.description}

+
+
    + {recipe.tags.map((tag) => ( +
  • + {tag.tagName} +
  • + ))} +
+
+
+ {recipe.title}/ +
+
+

Ingredienser

+
    + {recipe.ingredients.map((ingredient) => ( +
  • + +
  • + ))} +
+
+
+

Steg

+
    + {recipe.steps.map((step) => ( +
  1. + {step.instruction} +
  2. + ))} +
+
+
+ ); +} \ No newline at end of file diff --git a/client/src/routes/RecipeDetailPage.tsx b/client/src/routes/RecipeDetailPage.tsx index 1eacd42..1eeb6fb 100644 --- a/client/src/routes/RecipeDetailPage.tsx +++ b/client/src/routes/RecipeDetailPage.tsx @@ -1,8 +1,14 @@ import { useParams } from 'react-router'; +import { recipes } from '../mocks/recipes'; +import { RecipeDetail } from '../components/recipe/RecipeDetail'; // Placeholder for en oppskrift. Henter id fra URL-en. som /recipes/5 gir id = 5 export default function RecipeDetailPage() { const { id } = useParams(); + const recipe = recipes.find((r) => r.recipeId === id); + if (!recipe) { + return

Fant ikke oppskriften.

+ } - return

Oppskrift {id}

; + return ; }