"use client"; import { useState } from "react"; import { Input } from "../../component/ui/input"; import { Button } from "../../component/ui/button"; import Link from "next/link"; export default function RegisterPage() { const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(""); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setIsLoading(true); setError(""); const formData = new FormData(e.currentTarget); const email = formData.get("email"); const password = formData.get("password"); const firstName = formData.get("firstName"); const lastName = formData.get("lastName"); try { const response = await fetch("http://localhost:3000/api/auth/register", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ email, password, firstName, lastName }), }); if (!response.ok) { throw new Error("Registration failed"); } const data = await response.json(); localStorage.setItem("token", data.access_token); window.location.href = "/dashboard"; } catch (err) { setError("Registration failed. Please try again."); } finally { setIsLoading(false); } }; return (

Create an account

Get started with your account

{error && (
{error}
)}

Already have an account?{" "} Sign in

); }