'use client' import { useState, useEffect } from 'react' import { Recipe } from '@/lib/recipe-data' import { Dialog, DialogContent, DialogTitle } from '@/components/ui/dialog' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import { Separator } from '@/components/ui/separator' import { Progress } from '@/components/ui/progress' import { VisuallyHidden } from '@radix-ui/react-visually-hidden' import { Clock, Users, ChefHat, Lightbulb, X, Heart, Share2, Printer, Check, CheckCircle2, PlayCircle, Pause, RotateCcw, Timer } from 'lucide-react' import Image from 'next/image' import { motion, AnimatePresence } from 'framer-motion' import { cn } from '@/lib/utils' interface RecipeDialogProps { recipe: Recipe | null isOpen: boolean onClose: () => void } export default function RecipeDialog({ recipe, isOpen, onClose }: RecipeDialogProps) { const [activeStep, setActiveStep] = useState(0) const [completedSteps, setCompletedSteps] = useState>(new Set()) const [checkedIngredients, setCheckedIngredients] = useState>(new Set()) const [isTimerRunning, setIsTimerRunning] = useState(false) const [timerTime, setTimerTime] = useState(0) const [isFavorited, setIsFavorited] = useState(false) const [activeTab, setActiveTab] = useState<'overview' | 'ingredients' | 'instructions' | 'tips'>('overview') // Timer functionality useEffect(() => { let interval: NodeJS.Timeout if (isTimerRunning && timerTime > 0) { interval = setInterval(() => { setTimerTime(time => { if (time <= 1) { setIsTimerRunning(false) // Could add notification here return 0 } return time - 1 }) }, 1000) } return () => clearInterval(interval) }, [isTimerRunning, timerTime]) // Reset state when dialog opens/closes useEffect(() => { if (!isOpen) { setActiveStep(0) setCompletedSteps(new Set()) setCheckedIngredients(new Set()) setIsTimerRunning(false) setTimerTime(0) setActiveTab('overview') } }, [isOpen]) if (!recipe) return null const getDifficultyColor = (difficulty: string) => { switch (difficulty) { case 'Easy': return 'bg-green-100 text-green-800 border-green-200' case 'Medium': return 'bg-yellow-100 text-yellow-800 border-yellow-200' case 'Hard': return 'bg-red-100 text-red-800 border-red-200' default: return 'bg-gray-100 text-gray-800 border-gray-200' } } const toggleIngredientCheck = (index: number) => { const newChecked = new Set(checkedIngredients) if (newChecked.has(index)) { newChecked.delete(index) } else { newChecked.add(index) } setCheckedIngredients(newChecked) } const toggleStepComplete = (index: number) => { const newCompleted = new Set(completedSteps) if (newCompleted.has(index)) { newCompleted.delete(index) } else { newCompleted.add(index) } setCompletedSteps(newCompleted) } const startTimer = (minutes: number) => { setTimerTime(minutes * 60) setIsTimerRunning(true) } const formatTime = (seconds: number) => { const mins = Math.floor(seconds / 60) const secs = seconds % 60 return `${mins}:${secs.toString().padStart(2, '0')}` } const progress = recipe.instructions.length > 0 ? (completedSteps.size / recipe.instructions.length) * 100 : 0 const ingredientProgress = recipe.ingredients.length > 0 ? (checkedIngredients.size / recipe.ingredients.length) * 100 : 0 return ( {recipe.name} - Recipe Details
{/* Header */}
{/* Hero Image */}
{recipe.name}
{/* Close Button */} {/* Action Buttons */}
{/* Title Overlay */}

{recipe.name}

{recipe.description}

{/* Recipe Meta Info */}
{recipe.cookTime}
{recipe.servings} servings
{recipe.difficulty}
{recipe.category}
{/* Timer */} {timerTime > 0 && (
{formatTime(timerTime)}
)}
{/* Progress Bars */}
Ingredients checked {checkedIngredients.size}/{recipe.ingredients.length}
Steps completed {completedSteps.size}/{recipe.instructions.length}
{/* Tab Navigation */}
{/* Main Content */}
{activeTab === 'overview' && ( {/* Nutrition Info */} {recipe.nutritionInfo && (

📊
Nutrition Information (per serving)

{recipe.nutritionInfo.calories}
Calories
{recipe.nutritionInfo.protein}
Protein
{recipe.nutritionInfo.carbs}
Carbs
{recipe.nutritionInfo.fat}
Fat
)} {/* Quick Actions */}
)} {activeTab === 'ingredients' && (

🥘
Ingredients

Check off ingredients as you gather them

{recipe.ingredients.map((ingredient, index) => ( toggleIngredientCheck(index)} >
{checkedIngredients.has(index) && ( )}
{ingredient}
))}
)} {activeTab === 'instructions' && (

📝
Cooking Instructions

Follow these steps to create your delicious meal

{recipe.instructions.map((instruction, index) => (

{instruction}

{index === activeStep && (
)}
))}
)} {activeTab === 'tips' && recipe.tips && recipe.tips.length > 0 && (

Chef's Tips & Tricks

Professional insights to elevate your cooking

{recipe.tips.map((tip, index) => ( 💡

{tip}

))}
)}
) }