"use client"; import React, { useState } from "react"; import Link from "next/link"; import { useAuth } from "@/hooks/useAuth"; import { useTranslations } from "next-intl"; import CommonGridShape from "@/components/common/CommonGridShape"; import { Eye, EyeOff } from "lucide-react"; import axios from "@/lib/axios"; import { Turnstile } from "@marsidev/react-turnstile"; export default function SignupClient() { const t = useTranslations("Auth"); const { login } = useAuth({ middleware: "guest", redirectIfAuthenticated: "/dashboard", }); const [firstName, setFirstName] = useState(""); const [lastName, setLastName] = useState(""); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [terms, setTerms] = useState(false); const [showPassword, setShowPassword] = useState(false); const [errors, setErrors] = useState([]); const [isLoading, setIsLoading] = useState(false); const [turnstileToken, setTurnstileToken] = useState(null); const submitForm = async (e: React.FormEvent) => { e.preventDefault(); setIsLoading(true); setErrors([]); await axios.get("/sanctum/csrf-cookie"); axios .post("/register", { fname: firstName, lname: lastName, email, password, password_confirmation: password, // Depending on backend validation terms, }) .then(() => { // Login user after successful registration login({ email, password, setErrors, remember: true }); }) .catch((error) => { if (error.response?.status === 422) { setErrors(error.response.data.errors); } else { setErrors({ email: ["Something went wrong. Please try again."] }); } }) .finally(() => setIsLoading(false)); }; const socialLogin = (provider: string) => { window.location.href = `${process.env.NEXT_PUBLIC_API_URL}/api/auth/${provider}/redirect?context=signup`; }; return (
{/* Form Section */}
{/* Header elements removed as they are provided by Public Layout */}

{t('signup_title')}

{t('signup_subtitle')}

{t('social_login_divider')}
{/* First Name */}
setFirstName(e.target.value)} placeholder={t('first_name_placeholder')} className="dark:bg-gray-900 shadow-sm focus:border-brand-300 focus:ring-brand-500/10 dark:focus:border-brand-800 h-11 w-full rounded-lg border border-gray-300 bg-transparent px-4 py-2.5 text-sm text-gray-800 placeholder:text-gray-400 focus:ring-3 focus:outline-hidden dark:border-gray-700 dark:text-white/90 dark:placeholder:text-white/30" /> {errors.fname &&

{errors.fname}

}
{/* Last Name */}
setLastName(e.target.value)} placeholder={t('last_name_placeholder')} className="dark:bg-gray-900 shadow-sm focus:border-brand-300 focus:ring-brand-500/10 dark:focus:border-brand-800 h-11 w-full rounded-lg border border-gray-300 bg-transparent px-4 py-2.5 text-sm text-gray-800 placeholder:text-gray-400 focus:ring-3 focus:outline-hidden dark:border-gray-700 dark:text-white/90 dark:placeholder:text-white/30" /> {errors.lname &&

{errors.lname}

}
setEmail(e.target.value)} placeholder={t('email_placeholder')} className="dark:bg-gray-900 shadow-sm focus:border-brand-300 focus:ring-brand-500/10 dark:focus:border-brand-800 h-11 w-full rounded-lg border border-gray-300 bg-transparent px-4 py-2.5 text-sm text-gray-800 placeholder:text-gray-400 focus:ring-3 focus:outline-hidden dark:border-gray-700 dark:text-white/90 dark:placeholder:text-white/30" /> {errors.email &&

{errors.email}

}
setPassword(e.target.value)} placeholder={t('password_placeholder')} className="dark:bg-gray-900 shadow-sm focus:border-brand-300 focus:ring-brand-500/10 dark:focus:border-brand-800 h-11 w-full rounded-lg border border-gray-300 bg-transparent py-2.5 pr-11 pl-4 text-sm text-gray-800 placeholder:text-gray-400 focus:ring-3 focus:outline-hidden dark:border-gray-700 dark:text-white/90 dark:placeholder:text-white/30" />
{errors.password &&

{errors.password}

}
setTerms(e.target.checked)} className="mr-3 h-5 w-5 rounded-md border-gray-300 dark:border-gray-700 text-brand-500 focus:ring-brand-500" />

{t('agree_to_signup_text')} {t('terms_link')} {t('and_text')} {t('privacy_policy_link')}.

{errors.terms &&

{errors.terms}

}
{/* Turnstile Disabled for Verification */} {false && ( setTurnstileToken(token)} /> )}
{errors['cf-turnstile-response'] &&

{errors['cf-turnstile-response']}

}

{t('already_have_account')} {t('signin_link')}

{/* Right Side Branding & Background */}
{/* Background Decoration */}
{/* Branding Content */}
TrustLab Logo

{t('join_title')}

{t('join_desc')}

{/* Decorative element */}
); }