Skip to content
This repository was archived by the owner on Jun 28, 2025. It is now read-only.

Commit 8925644

Browse files
author
Manuel Proß
committed
feat(FE): adjust spacing of first- and lastname, add validation for email and password confirmation
1 parent 87bd4b1 commit 8925644

File tree

1 file changed

+69
-57
lines changed

1 file changed

+69
-57
lines changed

web/src/app/registration/page.tsx

Lines changed: 69 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use client';
22
import { ChangeEvent, useState } from 'react';
3+
import { getMailValidation } from '@/helpers/validators';
34
import Input from '@/components/Inputs/TextInput';
45

56
type RegistrationFormData = {
@@ -25,75 +26,86 @@ export default function Registration() {
2526
const { name, value } = e.target;
2627
setFormData((prevFormData) => ({ ...prevFormData, [name]: value }));
2728
};
29+
30+
const handlePwValidation = (): string | undefined => {
31+
if (formData.passwordConfirm !== formData.password) return 'Passwords should match';
32+
return undefined;
33+
};
34+
2835
return (
29-
<div className="grid grid-cols-1 xl:grid-cols-2 xl:gap-8">
30-
<form className="flex flex-col items-stretch gap-4">
31-
<Input
32-
type="text"
33-
label="Username"
34-
name="username"
35-
id="username"
36-
value={formData.username}
37-
onChange={handleInputChange}
38-
required
39-
/>
40-
<div className="grid grid-cols-1 xl:grid-cols-2 xl:gap-3">
36+
<div>
37+
<h1 className="h3">My Account</h1>
38+
<div className="grid grid-cols-1 xl:grid-cols-2 xl:gap-8">
39+
<form className="flex flex-col items-stretch gap-4">
4140
<Input
4241
type="text"
43-
label="First Name"
44-
name="firstname"
45-
id="firstname"
46-
value={formData.firstname}
42+
label="Username"
43+
name="username"
44+
id="username"
45+
value={formData.username}
4746
onChange={handleInputChange}
4847
required
4948
/>
49+
<div className="grid grid-cols-1 xl:grid-cols-2 xl:gap-3">
50+
<Input
51+
type="text"
52+
label="First Name"
53+
name="firstname"
54+
id="firstname"
55+
value={formData.firstname}
56+
onChange={handleInputChange}
57+
required
58+
/>
59+
<Input
60+
type="text"
61+
label="Last Name"
62+
name="lastname"
63+
id="lastname"
64+
value={formData.lastname}
65+
onChange={handleInputChange}
66+
required
67+
/>
68+
</div>
5069
<Input
5170
type="text"
52-
label="Last Name"
53-
name="lastname"
54-
id="lastname"
55-
value={formData.lastname}
71+
label="Email Address"
72+
name="email"
73+
id="email"
74+
value={formData.email}
5675
onChange={handleInputChange}
5776
required
77+
validate={(value) => getMailValidation(value)}
5878
/>
59-
</div>
60-
<Input
61-
type="text"
62-
label="Email Address"
63-
name="email"
64-
id="email"
65-
value={formData.email}
66-
onChange={handleInputChange}
67-
required
68-
/>
69-
<Input
70-
type="password"
71-
label="Password"
72-
name="password"
73-
id="password"
74-
value={formData.password}
75-
onChange={handleInputChange}
76-
required
77-
/>
78-
<Input
79-
type="password"
80-
label="Confirm Password"
81-
name="passwordConfirm"
82-
id="passwordConfirm"
83-
value={formData.passwordConfirm}
84-
onChange={handleInputChange}
85-
required
86-
/>
87-
<input className="btn ml-auto hover:cursor-pointer" type="submit" value="Register" />
88-
</form>
89-
<div>
90-
<h2 className="text-secondary">Please note</h2>
79+
<Input
80+
type="password"
81+
label="Password"
82+
name="password"
83+
id="password"
84+
value={formData.password}
85+
onChange={handleInputChange}
86+
required
87+
/>
88+
<Input
89+
type="password"
90+
label="Confirm Password"
91+
name="passwordConfirm"
92+
id="passwordConfirm"
93+
value={formData.passwordConfirm}
94+
onChange={handleInputChange}
95+
required
96+
validate={handlePwValidation}
97+
/>
98+
<input className="btn ml-auto hover:cursor-pointer" type="submit" value="Register" />
99+
</form>
100+
<div>
101+
<h2 className="text-secondary">Please note</h2>
91102

92-
<p>
93-
Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel est adipisci quas, aperiam voluptas,
94-
omnis tempora blanditiis quae fuga eum ullam commodi a perspiciatis provident pariatur sunt
95-
excepturi doloremque! Commodi!
96-
</p>
103+
<p>
104+
Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel est adipisci quas, aperiam
105+
voluptas, omnis tempora blanditiis quae fuga eum ullam commodi a perspiciatis provident pariatur
106+
sunt excepturi doloremque! Commodi!
107+
</p>
108+
</div>
97109
</div>
98110
</div>
99111
);

0 commit comments

Comments
 (0)