|
1 |
| -'use client'; |
2 |
| -import { ChangeEvent, useState } from 'react'; |
3 |
| -import { getMailValidation } from '@/helpers/validators'; |
4 |
| -import Input from '@/components/Inputs/TextInput'; |
| 1 | +"use client"; |
| 2 | +import { ChangeEvent, useState } from "react"; |
| 3 | +import { getMailValidation } from "@/helpers/validators"; |
| 4 | +import Input from "@/components/Inputs/TextInput"; |
5 | 5 |
|
6 | 6 | type RegistrationFormData = {
|
7 |
| - username: string; |
8 |
| - firstname: string; |
9 |
| - lastname: string; |
10 |
| - email: string; |
11 |
| - password: string; |
12 |
| - passwordConfirm: string; |
| 7 | + username: string; |
| 8 | + firstname: string; |
| 9 | + lastname: string; |
| 10 | + email: string; |
| 11 | + password: string; |
| 12 | + passwordConfirm: string; |
13 | 13 | };
|
14 | 14 |
|
15 | 15 | export default function Registration() {
|
16 |
| - const [formData, setFormData] = useState<RegistrationFormData>({ |
17 |
| - username: '', |
18 |
| - firstname: '', |
19 |
| - lastname: '', |
20 |
| - email: '', |
21 |
| - password: '', |
22 |
| - passwordConfirm: '', |
23 |
| - }); |
| 16 | + const [formData, setFormData] = useState<RegistrationFormData>({ |
| 17 | + username: "", |
| 18 | + firstname: "", |
| 19 | + lastname: "", |
| 20 | + email: "", |
| 21 | + password: "", |
| 22 | + passwordConfirm: "", |
| 23 | + }); |
24 | 24 |
|
25 |
| - const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => { |
26 |
| - const { name, value } = e.target; |
27 |
| - setFormData((prevFormData) => ({ ...prevFormData, [name]: value })); |
28 |
| - }; |
| 25 | + const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => { |
| 26 | + const { name, value } = e.target; |
| 27 | + setFormData(prevFormData => ({ ...prevFormData, [name]: value })); |
| 28 | + }; |
29 | 29 |
|
30 |
| - const handlePwValidation = (): string | undefined => { |
31 |
| - if (formData.passwordConfirm !== formData.password) return 'Passwords should match'; |
32 |
| - return undefined; |
33 |
| - }; |
| 30 | + const handlePwValidation = (): string | undefined => { |
| 31 | + if (formData.passwordConfirm !== formData.password) return "Passwords should match"; |
| 32 | + return undefined; |
| 33 | + }; |
34 | 34 |
|
35 |
| - return ( |
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"> |
40 |
| - <Input |
41 |
| - type="text" |
42 |
| - label="Username" |
43 |
| - name="username" |
44 |
| - id="username" |
45 |
| - value={formData.username} |
46 |
| - onChange={handleInputChange} |
47 |
| - required |
48 |
| - /> |
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> |
69 |
| - <Input |
70 |
| - type="text" |
71 |
| - label="Email Address" |
72 |
| - name="email" |
73 |
| - id="email" |
74 |
| - value={formData.email} |
75 |
| - onChange={handleInputChange} |
76 |
| - required |
77 |
| - validate={(value) => getMailValidation(value)} |
78 |
| - /> |
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> |
| 35 | + return ( |
| 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"> |
| 40 | + <Input type="text" label="Username" name="username" id="username" value={formData.username} onChange={handleInputChange} required /> |
| 41 | + <div className="grid grid-cols-1 xl:grid-cols-2 xl:gap-3"> |
| 42 | + <Input type="text" label="First Name" name="firstname" id="firstname" value={formData.firstname} onChange={handleInputChange} required /> |
| 43 | + <Input type="text" label="Last Name" name="lastname" id="lastname" value={formData.lastname} onChange={handleInputChange} required /> |
| 44 | + </div> |
| 45 | + <Input |
| 46 | + type="text" |
| 47 | + label="Email Address" |
| 48 | + name="email" |
| 49 | + id="email" |
| 50 | + value={formData.email} |
| 51 | + onChange={handleInputChange} |
| 52 | + required |
| 53 | + validate={value => getMailValidation(value)} |
| 54 | + /> |
| 55 | + <Input type="password" label="Password" name="password" id="password" value={formData.password} onChange={handleInputChange} required /> |
| 56 | + <Input |
| 57 | + type="password" |
| 58 | + label="Confirm Password" |
| 59 | + name="passwordConfirm" |
| 60 | + id="passwordConfirm" |
| 61 | + value={formData.passwordConfirm} |
| 62 | + onChange={handleInputChange} |
| 63 | + required |
| 64 | + validate={handlePwValidation} |
| 65 | + /> |
| 66 | + <input className="btn ml-auto hover:cursor-pointer" type="submit" value="Register" /> |
| 67 | + </form> |
| 68 | + <div> |
| 69 | + <h2 className="text-secondary">Please note</h2> |
102 | 70 |
|
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> |
109 |
| - </div> |
110 |
| - </div> |
111 |
| - ); |
| 71 | + <p> |
| 72 | + Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel est adipisci quas, aperiam voluptas, omnis tempora blanditiis quae fuga eum ullam |
| 73 | + commodi a perspiciatis provident pariatur sunt excepturi doloremque! Commodi! |
| 74 | + </p> |
| 75 | + </div> |
| 76 | + </div> |
| 77 | + </div> |
| 78 | + ); |
112 | 79 | }
|
0 commit comments