/* eslint-disable react/no-unescaped-entities */ "use client"; import { useState } from "react"; import { useI18n } from "../../components/I18nProvider"; export default function RegisterPage() { const { t } = useI18n(); const [email, setEmail] = useState(""); const [name, setName] = useState(""); const [password, setPassword] = useState(""); const [message, setMessage] = useState(null); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); async function onSubmit(e: React.FormEvent) { e.preventDefault(); setError(null); setMessage(null); setLoading(true); try { const res = await fetch("/api/auth/register", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email, name, password }), }); const data = await res.json(); if (!res.ok) { setError(data.error || "Registration failed"); } else { setMessage(t("registerSuccess")); setEmail(""); setPassword(""); } } catch (err) { setError("Registration failed"); } finally { setLoading(false); } } return (

{t("registerTitle")}

{t("registerLead")}

{message ? (

{message}

) : null} {error ?

{error}

: null}
); }