'use client'; import React, { useState, useEffect } from 'react'; import { usePathname } from 'next/navigation'; import { motion, AnimatePresence } from 'framer-motion'; import { Scan, GlassWater, Users, Settings, ArrowRight, X, Sparkles } from 'lucide-react'; import { useI18n } from '@/i18n/I18nContext'; import { useAuth } from '@/context/AuthContext'; const ONBOARDING_KEY = 'dramlog_onboarding_complete'; interface OnboardingStep { id: string; icon: React.ReactNode; title: string; description: string; } const getSteps = (t: (path: string) => string): OnboardingStep[] => [ { id: 'welcome', icon: , title: t('tutorial.steps.welcome.title'), description: t('tutorial.steps.welcome.desc'), }, { id: 'scan', icon: , title: t('tutorial.steps.scan.title'), description: t('tutorial.steps.scan.desc'), }, { id: 'taste', icon: , title: t('tutorial.steps.taste.title'), description: t('tutorial.steps.taste.desc'), }, { id: 'activity', icon: , title: t('tutorial.steps.activity.title'), description: t('tutorial.steps.activity.desc'), }, { id: 'ready', icon: , title: t('tutorial.steps.ready.title'), description: t('tutorial.steps.ready.desc'), }, ]; export default function OnboardingTutorial() { const { t } = useI18n(); const { user, isLoading } = useAuth(); const STEPS = getSteps(t); const [isOpen, setIsOpen] = useState(false); const [currentStep, setCurrentStep] = useState(0); const pathname = usePathname(); useEffect(() => { // Don't show if auth is still loading if (isLoading) return; // Don't show if no user is logged in if (!user) { setIsOpen(false); return; } // Don't show on login/auth pages if (pathname === '/login' || pathname === '/auth' || pathname === '/register') { return; } // Check if onboarding was completed const completed = localStorage.getItem(ONBOARDING_KEY); if (!completed) { // Small delay to not overwhelm on first load const timer = setTimeout(() => setIsOpen(true), 1000); return () => clearTimeout(timer); } }, [pathname]); const handleNext = () => { if (currentStep < STEPS.length - 1) { setCurrentStep(prev => prev + 1); } else { handleComplete(); } }; const handleComplete = () => { localStorage.setItem(ONBOARDING_KEY, 'true'); setIsOpen(false); }; const handleSkip = () => { localStorage.setItem(ONBOARDING_KEY, 'true'); setIsOpen(false); }; if (!isOpen) return null; const step = STEPS[currentStep]; const isLastStep = currentStep === STEPS.length - 1; return ( {/* Close button */} {/* Icon */}
{step.icon}
{/* Content */}

{step.title}

{step.description}

{/* Progress dots */}
{STEPS.map((_, index) => (
))}
{/* Buttons */}
{!isLastStep && ( )}
); }