'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; import { useCreateSaisie } from '@/hooks/useTracker'; import EmotionPicker from '@/components/features/EmotionPicker'; import Slider from '@/components/ui/Slider'; import toast from 'react-hot-toast'; const STEPS = [ { id: 1, title: 'Émotion', description: 'Comment vous sentez-vous ?' }, { id: 2, title: 'Intensité', description: 'À quel point ressentez-vous cette émotion ?' }, { id: 3, title: 'Note', description: 'Souhaitez-vous ajouter un commentaire ?' }, ]; export default function NouvelleSaisiePage() { const router = useRouter(); const createSaisie = useCreateSaisie(); const [step, setStep] = useState(1); const [emotionId, setEmotionId] = useState(); const [intensite, setIntensite] = useState(5); const [note, setNote] = useState(''); const [dateSaisie, setDateSaisie] = useState( new Date().toISOString().split('T')[0] ); const canNext = () => { if (step === 1) return !!emotionId; return true; }; const handleSubmit = async () => { if (!emotionId) return; try { await createSaisie.mutateAsync({ emotion_id: emotionId, intensite, note: note.trim() || undefined, date_saisie: dateSaisie, }); toast.success('Saisie enregistrée !'); router.push('/journal'); } catch { toast.error('Erreur lors de l\'enregistrement'); } }; const nextStep = STEPS[step]?.title; return (

Nouvelle saisie

Enregistrez votre émotion en quelques étapes simples.

{/* Stepper DSFR */}

{STEPS[step - 1].title} Étape {step} sur {STEPS.length}

{nextStep && (

Étape suivante : {nextStep}

)}
{/* Étape actuelle */}

{STEPS[step - 1].description}

{step === 1 && ( )} {step === 2 && (
Faible Modérée Forte
)} {step === 3 && (
setDateSaisie(e.target.value)} />