/** * @file app/(auth)/register/page.tsx * @description Client component rendering the registration page, handling form submissions, client-side validation, error handling, autocomplete, and navigation. */ "use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import Link from "next/link"; import Image from "next/image"; import { registerUser } from "@/lib/services/auth.service"; /** Renders the user registration interface and manages sign-up form state. */ export default function RegisterPage() { const [error, setError] = useState(null); const [loading, setLoading] = useState(false); const router = useRouter(); /** Clears active error state when user modifies input fields. */ const handleInputChange = () => { if (error) { setError(null); } }; /** Handles user registration form submission, validates form data via auth service, and navigates to summary page on successful registration. */ async function handleSubmit(event: React.FormEvent) { event.preventDefault(); setError(null); const formData = new FormData(event.currentTarget); const payload = Object.fromEntries(formData.entries()); // Client-side password matching validation if (payload.password !== payload.confirmPassword) { setError("Passwords do not match."); return; } setLoading(true); const result = await registerUser(payload); if (result.error) { setError(result.error); setLoading(false); } else { router.push("/"); } } return (
Waveform Logo

Create an Account

Get started with Waveform now.

{/* Error Message */} {error && (
{error}
)} {/* Form */}

Already have an account?{" "} Sign In

); }