"use client"; import { useMemo, useState } from "react"; import { useRouter } from "next/navigation"; import Link from "next/link"; import Image from "next/image"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Checkbox } from "@/components/ui/checkbox"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { Textarea } from "@/components/ui/textarea"; import { User, Mail, Lock, Eye, EyeOff, Phone, MapPin, Calendar, GraduationCap, Briefcase, ArrowLeft, } from "lucide-react"; import { Alert, AlertDescription } from "@/components/ui/alert"; import { motion } from "framer-motion"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; import { useTranslation } from "@/lib/i18n"; const createCandidateSchema = (t: (key: string, params?: Record) => string) => z.object({ fullName: z.string().min(2, t("register.candidate.validation.fullName")), email: z.string().email(t("register.candidate.validation.email")), password: z.string().min(6, t("register.candidate.validation.password")), confirmPassword: z.string(), phone: z.string().min(10, t("register.candidate.validation.phone")), birthDate: z.string().min(1, t("register.candidate.validation.birthDate")), address: z.string().min(5, t("register.candidate.validation.address")), city: z.string().min(2, t("register.candidate.validation.city")), state: z.string().min(2, t("register.candidate.validation.state")), zipCode: z.string().min(8, t("register.candidate.validation.zipCode")), education: z.string().min(1, t("register.candidate.validation.education")), experience: z.string().min(1, t("register.candidate.validation.experience")), skills: z.string().optional(), objective: z.string().optional(), acceptTerms: z .boolean() .refine(val => val === true, t("register.candidate.validation.acceptTerms")), acceptNewsletter: z.boolean().optional(), }).refine(data => data.password === data.confirmPassword, { message: t("register.candidate.validation.passwordMismatch"), path: ["confirmPassword"], }); type CandidateFormData = z.infer>; export default function CandidateRegisterPage() { const router = useRouter(); const { t } = useTranslation(); const [loading, setLoading] = useState(false); const [showPassword, setShowPassword] = useState(false); const [showConfirmPassword, setShowConfirmPassword] = useState(false); const [currentStep, setCurrentStep] = useState(1); const candidateSchema = useMemo(() => createCandidateSchema(t), [t]); const { register, handleSubmit, formState: { errors }, setValue, watch, } = useForm({ resolver: zodResolver(candidateSchema), }); const acceptTerms = watch("acceptTerms"); const acceptNewsletter = watch("acceptNewsletter"); const onSubmit = async (data: CandidateFormData) => { setLoading(true); try { // Simular cadastro await new Promise(resolve => setTimeout(resolve, 2000)); console.log("Dados do candidato:", data); // Redirecionar para login após cadastro router.push(`/login?message=${encodeURIComponent(t("register.candidate.success"))}`); } catch (error) { console.error("Erro no cadastro:", error); } finally { setLoading(false); } }; const nextStep = () => { if (currentStep < 3) setCurrentStep(currentStep + 1); }; const prevStep = () => { if (currentStep > 1) setCurrentStep(currentStep - 1); }; const stepVariants = { hidden: { opacity: 0, x: 20 }, visible: { opacity: 1, x: 0 }, exit: { opacity: 0, x: -20 } }; return (
{/* Left Panel - Informações */}
GoHorse Jobs

{t("register.candidate.hero.title")}

{t("register.candidate.hero.subtitle")}

{t("register.candidate.hero.bullets.jobs")}
{t("register.candidate.hero.bullets.fastApplications")}
{t("register.candidate.hero.bullets.profile")}
{t("register.candidate.hero.bullets.notifications")}
{/* Right Panel - Formulário */}
{/* Header */}
{t("register.candidate.actions.backToLogin")}

{t("register.candidate.title")}

{t("register.candidate.subtitle")}

{/* Progress Indicator */}
{t("register.candidate.progress.step", { current: currentStep, total: 3 })} {currentStep === 1 && t("register.candidate.steps.personal")} {currentStep === 2 && t("register.candidate.steps.address")} {currentStep === 3 && t("register.candidate.steps.professional")}
{/* Step 1: Dados Pessoais */} {currentStep === 1 && (
{errors.fullName && ( {errors.fullName.message} )}
{errors.email && ( {errors.email.message} )}
{errors.password && ( {errors.password.message} )}
{errors.confirmPassword && ( {errors.confirmPassword.message} )}
{errors.birthDate && ( {errors.birthDate.message} )}
)} {/* Step 2: Endereço e Contato */} {currentStep === 2 && (
{errors.phone && ( {errors.phone.message} )}
{errors.address && ( {errors.address.message} )}
{errors.city && ( {errors.city.message} )}
{errors.state && ( {errors.state.message} )}
{errors.zipCode && ( {errors.zipCode.message} )}
)} {/* Step 3: Perfil Profissional */} {currentStep === 3 && (
{errors.education && ( {errors.education.message} )}
{errors.experience && ( {errors.experience.message} )}