'use client'; import { useState, useEffect } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { useRouter } from 'next/navigation'; import Link from 'next/link'; import { Home, Search, Rocket, ArrowLeft, ArrowRight } from 'lucide-react'; import { useTranslation } from 'react-i18next'; const STORAGE_KEY = 'sweethome_onboarding_completed'; export default function OnboardingPage() { const { t, i18n } = useTranslation(); const router = useRouter(); const [currentStep, setCurrentStep] = useState(0); const steps = [ { icon: Home, title: t('onboarding.step1.title'), description: t('onboarding.step1.description'), gradient: 'from-amber-500 to-orange-600', }, { icon: Search, title: t('onboarding.step2.title'), description: t('onboarding.step2.description'), gradient: 'from-blue-500 to-indigo-600', }, { icon: Rocket, title: t('onboarding.step3.title'), description: t('onboarding.step3.description'), gradient: 'from-emerald-500 to-teal-600', }, ]; const [direction, setDirection] = useState(0); useEffect(() => { const completed = localStorage.getItem(STORAGE_KEY); if (completed === 'true') { router.replace('/'); } }, [router]); const goToStep = (index) => { setDirection(index > currentStep ? 1 : -1); setCurrentStep(index); }; const nextStep = () => { if (currentStep < steps.length - 1) { goToStep(currentStep + 1); } }; const prevStep = () => { if (currentStep > 0) { goToStep(currentStep - 1); } }; const handleFinish = () => { localStorage.setItem(STORAGE_KEY, 'true'); }; const step = steps[currentStep]; const isLastStep = currentStep === steps.length - 1; const isFirstStep = currentStep === 0; const IconComponent = step.icon; const slideVariants = { enter: (dir) => ({ x: dir > 0 ? 300 : -300, opacity: 0 }), center: { x: 0, opacity: 1 }, exit: (dir) => ({ x: dir > 0 ? -300 : 300, opacity: 0 }), }; return (