-
Notifications
You must be signed in to change notification settings - Fork 0
/
EditAccountModal.tsx
60 lines (58 loc) · 2.5 KB
/
EditAccountModal.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { Button, Col, Form, Input, Modal } from "antd"
import { useState } from "react"
import { EditAccountModalProps } from "../../../types"
import { useAppDispatch } from "../../../hooks"
import { updateUserData } from "../../../accountUtils"
const EditAccountModal = ({ visible, setVisible, user }: EditAccountModalProps) => {
const dispatch = useAppDispatch()
const [name, setName] = useState<string>(user.name)
const [surname, setSurname] = useState<string>(user.surname)
const [email, setEmail] = useState<string>(user.email)
return (
<Modal
open={visible} style={{ borderRadius: 210 }}
onCancel={() => setVisible(false)}
footer={[
<Button key="back" onClick={() => setVisible(false)}>Cancel</Button>,
<Button key="submit" type="primary" onClick={() =>
updateUserData(user, name, surname, email, dispatch, setVisible)
}>Update</Button>
]}
title="Edit your personal data">
<Col>
<p>Name</p>
<Form.Item
style={{ marginTop: "10px" }}
rules={[{ required: true, message: 'Please input your name!' }]}
>
<Input style={{ height: 50, borderRadius: 8 }}
placeholder="Name"
defaultValue={user.name}
onChange={(val) => setName(val.target.value)}
/>
</Form.Item>
</Col>
<Col>
<p>Surname</p>
<Form.Item rules={[{ required: true, message: 'Please input your surname!' }]}>
<Input allowClear style={{ height: 50, borderRadius: 8 }}
placeholder="Surname"
defaultValue={user.surname}
onChange={(val) => setSurname(val.target.value)}
/>
</Form.Item>
</Col>
<Col>
<p>Email</p>
<Form.Item rules={[{ required: true, message: 'Please input your email!' }]}>
<Input
allowClear
style={{ height: 50, borderRadius: 8 }}
placeholder="Email"
defaultValue={user.email} onChange={(val) => setEmail(val.target.value)}
/>
</Form.Item>
</Col>
</Modal>)
}
export default EditAccountModal