import { useEffect, useState } from 'react' import { Link, useNavigate, useParams } from 'react-router-dom' import apiClient from '../api/client' import ProductFoundModal from '../components/ProductFoundModal' import ConfirmDialog from '../components/ConfirmDialog' import DishShareManager from '../components/DishShareManager' import ThemeToggle from '../components/ThemeToggle' export default function DishDetailPage() { const { id } = useParams() const navigate = useNavigate() const [dish, setDish] = useState(null) const [isLogging, setIsLogging] = useState(false) const [isDeleting, setIsDeleting] = useState(false) useEffect(() => { apiClient.get(`/api/dishes/${id}`).then((res) => setDish(res.data)) }, [id]) async function handleConfirmDelete() { await apiClient.delete(`/api/dishes/${id}`) navigate('/cookbook') } if (!dish) { return (
Lädt…
) } return (

{dish.name}

Zurück

Ergibt insgesamt {Math.round(dish.total_weight_g)}g · Nährwerte pro 100g

Kcal
{Math.round(dish.calories)}
Carbs
{Math.round(dish.carbs)}g
Protein
{Math.round(dish.protein)}g
Fett
{Math.round(dish.fat)}g

Zutaten

    {dish.ingredients.map((ing) => (
  • {ing.name} {Math.round(ing.amount_g)}g
  • ))}
{dish.instructions && ( <>

Zubereitung

{dish.instructions}

)}
{dish.is_owner ? ( <>
Bearbeiten
) : (

Geteilt von {dish.owner_username}

)}
{isLogging && ( navigate('/dashboard')} onClose={() => setIsLogging(false)} /> )} {isDeleting && ( setIsDeleting(false)} /> )}
) }