import React, { useState } from 'react'; import { register } from "@/utils/api/auth"; import useRoutes from "@/hooks/useRoutes"; import SectionTitle from "@/components/ui/SectionTitle"; import SolidButton from "@/components/ui/Buttons/SolidButton"; import { Link, useNavigate } from "react-router" const RegisterForm = () => { const routes = useRoutes(); const [name, setName] = useState(''); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [passwordAgain, setPasswordAgain] = useState(''); const [error, setError] = useState(''); const [isLoading, setIsLoading] = useState(false); const [isRegistered, setIsRegistered] = useState(false); const navigate = useNavigate(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (password !== passwordAgain) { setError("Passwords do not match."); return; } try { setIsLoading(true); await register(name, email, password, passwordAgain); // navigate('/login?registered=true', { replace: true }); } catch (err) { const errorMessage = err instanceof Error ? err.message : 'Registration\n failed'; setError(errorMessage); } finally { setIsRegistered(true); setIsLoading(false); } }; if (isRegistered) { return