diff --git a/src/components/RegistrationForm/index.tsx b/src/components/RegistrationForm/index.tsx index 39881ee..729b8e9 100644 --- a/src/components/RegistrationForm/index.tsx +++ b/src/components/RegistrationForm/index.tsx @@ -1,38 +1,46 @@ -'use client' +"use client"; -import { useState } from 'react' -import { useRouter } from 'next/navigation' -import { addUser } from "@actions/userActions" +import { useState } from "react"; +import { useRouter } from "next/navigation"; +import { addUser } from "@actions/userActions"; export default function RegistrationForm() { - const router = useRouter() - const [error, setError] = useState('') + const router = useRouter(); + const [error, setError] = useState(""); const [formData, setFormData] = useState({ - name: '', - email: '', - password: '', - confirmPassword: '' - }) + first_name: "", + last_name: "", + username: "", + email: "", + password: "", + confirmPassword: "", + }); const handleSubmit = async (e: React.FormEvent) => { - e.preventDefault() - setError('') -alert('in the submit'); -alert(formData.password + ":" + formData.confirmPassword); + e.preventDefault(); + setError(""); + alert("in the submit"); + alert(formData.password + ":" + formData.confirmPassword); if (formData.password !== formData.confirmPassword) { - setError('Passwords do not match') + setError("Passwords do not match"); console.log("password no match"); - alert('password no match'); - return + alert("password no match"); + return; } try { - addUser(formData.name, formData.name, formData.name, formData.email, formData.password); - console.log('Form submitted:', formData) - router.push('/signin') // Redirect to login after successful registration + addUser( + formData.first_name, + formData.last_name, + formData.username, + formData.email, + formData.password + ); + console.log("Form submitted:", formData); + router.push("/signin"); // Redirect to login after successful registration } catch (err) { - setError('Failed to register user') + setError("Failed to register user"); } - } + }; return (