From 8aba89043a5bd1fba6da92b76ac0bd077929a456 Mon Sep 17 00:00:00 2001 From: Isabella Hauan-Zamora Date: Thu, 8 Oct 2026 13:02:16 +0200 Subject: [PATCH] Fullfort steg 2 og 3 i ny oppskrift --- .../src/components/new-recipe/RecipeStep1.tsx | 288 +++++------------- .../src/components/new-recipe/RecipeStep2.tsx | 281 +++++++++++++++-- .../src/components/new-recipe/RecipeStep3.tsx | 185 +++++++++-- .../new-recipe/RecipeStepIndicator.tsx | 135 +++++--- client/src/components/ui/Field.tsx | 35 +++ client/src/components/ui/Input.tsx | 23 ++ client/src/index.css | 19 ++ client/src/routes/NewRecipePage.tsx | 75 ++++- 8 files changed, 729 insertions(+), 312 deletions(-) create mode 100644 client/src/components/ui/Field.tsx create mode 100644 client/src/components/ui/Input.tsx diff --git a/client/src/components/new-recipe/RecipeStep1.tsx b/client/src/components/new-recipe/RecipeStep1.tsx index 17eda16..b5040d4 100644 --- a/client/src/components/new-recipe/RecipeStep1.tsx +++ b/client/src/components/new-recipe/RecipeStep1.tsx @@ -1,286 +1,166 @@ -import { useState } from 'react' +import type { Dispatch, SetStateAction } from 'react' import Rating from '@mui/material/Rating' import { Button } from '../ui/Button' +import { Field } from '../ui/Field' +import { Input, Textarea } from '../ui/Input' import { Tag } from '../ui/Tag' +import type { RecipeFormData } from '../../routes/NewRecipePage' -const CATEGORIES = [ - 'Frokost', - 'Lunsj', - 'Middag', - 'Dessert', - 'Annet', -] - -const TAGS = [ - 'Vegetar', - 'Vegan', - 'Glutenfri', - 'Laktosefri', - 'Under 30 min', -] - +// Sånn at informasjonen blir lagret mellom stegene type RecipeStep1Props = { + data: RecipeFormData + setData: Dispatch> onNext: () => void } -export default function RecipeStep1({ - onNext, -}: RecipeStep1Props) { - const [category, setCategory] = useState('Middag') +const categories = ['Frokost', 'Lunsj', 'Middag', 'Dessert', 'Snacks', 'Drikke'] - const [selectedTags, setSelectedTags] = useState([ - 'Vegetar', - 'Glutenfri', - ]) +const dietaryTags = ['Vegetar', 'Vegansk', 'Pescetar', 'Glutenfri', 'Laktosefri', 'Annet +'] - const [servings, setServings] = useState(4) +export default function RecipeStep1({ data, setData, onNext }: RecipeStep1Props) { + // Oppdaterer ETT felt i oppskriften, f.eks. update('title', 'Pasta'). + // Erstatter alle setData({ ...data, felt: verdi }) og sørger for at resten beholdes. + const update = (key: K, value: RecipeFormData[K]) => + setData((prev) => ({ ...prev, [key]: value })) - // Velger eller fjerner en tag - const toggleTag = (tag: string) => { - if (selectedTags.includes(tag)) { - setSelectedTags( - selectedTags.filter((item) => item !== tag), - ) - } else { - setSelectedTags([...selectedTags, tag]) - } - } + // Klikk på en valgt tag fjerner den, klikk på en ikke-valgt tag legger den til + const toggleTag = (tag: string) => + update( + 'tags', + data.tags.includes(tag) ? data.tags.filter((item) => item !== tag) : [...data.tags, tag], + ) return (
+

Lag din egen oppskrift og del den med andre.

- {/* TO KOLONNER */} -
- +
{/* VENSTRE SIDE */} -
- - {/* Bilde */} -
-

Bilde av retten

- - -
- - {/* Rating */} - - - {/* Kort beskrivelse */} -
- + -