import React, { useState } from 'react'; import { useAuth } from './context/AuthContext'; import { useNavigate, Link } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { UserPlus, ArrowLeft } from 'lucide-react'; export default function Register() { const { t } = useTranslation(); const { register, startGoogleLogin } = useAuth(); const navigate = useNavigate(); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [username, setUsername] = useState(''); const [displayName, setDisplayName] = useState(''); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); const handleSubmit = async (e) => { e.preventDefault(); setError(null); setLoading(true); // Call the register function const result = await register(email, password, username, displayName); setLoading(false); if (result.success) { // Upon successful registration, usually redirect to login page navigate('/login'); } else { setError(result.message); } }; const handleGoogleAuth = async () => { setError(null); const result = await startGoogleLogin(); if (result && !result.success) { setError(result.message); } }; return (
Join the AI verification platform
{error && (