-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUserForm.tsx
46 lines (43 loc) · 994 Bytes
/
UserForm.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { FormWrapper } from './FormWrapper';
type UserData = {
firstName: string;
lastName: string;
age: string;
};
type UserFormProps = UserData & {
updateFields: (fields: Partial<UserData>) => void;
};
export function UserForm({
firstName,
lastName,
age,
updateFields,
}: UserFormProps) {
return (
<FormWrapper title="User Details">
<label htmlFor="">First Name</label>
<input
autoFocus
required
type="text"
value={firstName}
onChange={(e) => updateFields({ firstName: e.target.value })}
/>
<label htmlFor="">Last Name</label>
<input
required
type="text"
value={lastName}
onChange={(e) => updateFields({ lastName: e.target.value })}
/>
<label htmlFor="">Age</label>
<input
required
min={1}
type="number"
value={age}
onChange={(e) => updateFields({ age: e.target.value })}
/>
</FormWrapper>
);
}