Skip to content

Commit 20f9110

Browse files
committed
feat: split name field into first/last name & add on form
1 parent b1e1825 commit 20f9110

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

src/pages/Signup.tsx

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import { useToast } from "@/components/ui/use-toast";
88
import { useAuth } from '@/contexts/AuthContext';
99

1010
export default function Signup() {
11-
const [name, setName] = useState('');
11+
const [firstName, setFirstName] = useState('');
12+
const [lastName, setLastName] = useState('');
1213
const [email, setEmail] = useState('');
1314
const [password, setPassword] = useState('');
1415
const [confirmPassword, setConfirmPassword] = useState('');
@@ -19,7 +20,7 @@ export default function Signup() {
1920
const handleSubmit = async (e: React.FormEvent) => {
2021
e.preventDefault();
2122

22-
if (!name || !email || !password || !confirmPassword) {
23+
if (!firstName || !lastName || !email || !password || !confirmPassword) {
2324
toast({
2425
title: "Error",
2526
description: "Please fill in all fields.",
@@ -37,6 +38,8 @@ export default function Signup() {
3738
return;
3839
}
3940

41+
// Combine first name and last name into a single name field
42+
const name = `${firstName} ${lastName}`;
4043
const success = await signup(name, email, password);
4144
if (success) {
4245
// Redirect to login page after successful signup
@@ -55,6 +58,30 @@ export default function Signup() {
5558
</CardHeader>
5659
<CardContent>
5760
<form onSubmit={handleSubmit} className="space-y-4">
61+
<div className="grid grid-cols-2 gap-4">
62+
<div className="space-y-2">
63+
<Label htmlFor="firstName">First Name</Label>
64+
<Input
65+
id="firstName"
66+
type="text"
67+
placeholder="John"
68+
value={firstName}
69+
onChange={(e) => setFirstName(e.target.value)}
70+
required
71+
/>
72+
</div>
73+
<div className="space-y-2">
74+
<Label htmlFor="lastName">Last Name</Label>
75+
<Input
76+
id="lastName"
77+
type="text"
78+
placeholder="Doe"
79+
value={lastName}
80+
onChange={(e) => setLastName(e.target.value)}
81+
required
82+
/>
83+
</div>
84+
</div>
5885
<div className="space-y-2">
5986
<Label htmlFor="email">Email</Label>
6087
<Input

0 commit comments

Comments
 (0)