"use client"; import { useState } from "react"; import Link from "next/link"; import { useRouter } from "next/navigation"; import Button from "@/components/ui/Button"; import Input, { Textarea } from "@/components/ui/Input"; // Étapes du formulaire type Step = 1 | 2 | 3; interface FormData { firstname: string; email: string; phone: string; persona: string; age: string; experience: string; time_daily: string; availability: string; start_date: string; motivation: string; monthly_goal: string; biggest_fear: string; tiktok_username: string; } const initialFormData: FormData = { firstname: "", email: "", phone: "", persona: "", age: "", experience: "", time_daily: "", availability: "", start_date: "", motivation: "", monthly_goal: "", biggest_fear: "", tiktok_username: "", }; export default function CandidaturePage() { const router = useRouter(); const [step, setStep] = useState(1); const [formData, setFormData] = useState(initialFormData); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const updateField = (field: keyof FormData, value: string) => { setFormData((prev) => ({ ...prev, [field]: value })); }; const canGoNext = (): boolean => { switch (step) { case 1: return !!( formData.firstname && formData.email && formData.phone && formData.persona && formData.age ); case 2: return !!( formData.experience && formData.time_daily && formData.availability && formData.start_date ); case 3: return !!( formData.motivation && formData.monthly_goal && formData.biggest_fear ); default: return false; } }; const handleSubmit = async () => { setLoading(true); setError(null); try { const res = await fetch("/api/candidature", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ ...formData, age: parseInt(formData.age, 10), }), }); if (!res.ok) { const data = await res.json(); throw new Error(data.error || "Erreur lors de l'envoi"); } router.push("/merci"); } catch (err) { setError(err instanceof Error ? err.message : "Erreur inattendue"); } finally { setLoading(false); } }; return (
{/* Header */}
H
HookLab

Candidature HookLab

Reponds a quelques questions pour qu'on puisse evaluer ton profil.

{/* Progress bar */}
{[1, 2, 3].map((s) => (
))}
{/* Formulaire */}
{/* Étape 1 : Informations personnelles */} {step === 1 && (

Informations personnelles

updateField("firstname", e.target.value)} /> updateField("email", e.target.value)} /> updateField("phone", e.target.value)} /> updateField("age", e.target.value)} /> {/* Persona selection */}
{[ { id: "jeune", label: "Etudiant / Jeune", emoji: "🎓", }, { id: "parent", label: "Parent / Reconversion", emoji: "👨‍👩‍👧", }, ].map((p) => ( ))}
)} {/* Étape 2 : Situation actuelle */} {step === 2 && (

Ta situation actuelle

{[ "Debutant complet", "J'ai deja teste des choses", "Je genere deja des revenus en ligne", ].map((opt) => ( ))}
{["1-2 heures", "2-4 heures", "4+ heures", "Temps plein"].map( (opt) => ( ) )}
{[ "Immediatement", "Dans 1-2 semaines", "Dans 1 mois", ].map((opt) => ( ))}
{[ "Cette semaine", "La semaine prochaine", "Ce mois-ci", ].map((opt) => ( ))}
)} {/* Étape 3 : Motivation */} {step === 3 && (

Ta motivation