-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
Copy pathProfileAdminForm.jsx
85 lines (81 loc) · 2.05 KB
/
ProfileAdminForm.jsx
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import { Form, Input, Select } from 'antd';
import { UploadOutlined, CloseOutlined, CheckOutlined } from '@ant-design/icons';
import { message, Upload, Button, Switch } from 'antd';
import useLanguage from '@/locale/useLanguage';
const beforeUpload = (file) => {
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
if (!isJpgOrPng) {
message.error('You can only upload JPG/PNG file!');
}
const isLt2M = file.size / 1024 / 1024 < 5;
if (!isLt2M) {
message.error('Image must smaller than 5MB!');
}
return false;
};
export default function AdminForm({ isUpdateForm = false }) {
const translate = useLanguage();
return (
<>
<Form.Item
label={translate('first Name')}
name="name"
rules={[
{
required: true,
},
{
pattern: /^[A-Za-z][A-Za-z'-]+$/,
message: 'Please enter a valid First Name',
}
]}
>
<Input autoComplete="off" />
</Form.Item>
<Form.Item
label={translate('last Name')}
name="surname"
rules={[
{
required: true,
},
{
pattern: /^[A-Za-z][A-Za-z'-]+$/,
message: 'Please enter a valid Last Name',
}
]}
>
<Input autoComplete="off" />
</Form.Item>
<Form.Item
label={translate('email')}
name="email"
rules={[
{
required: true,
},
{
type: 'email',
},
]}
>
<Input autoComplete="off" />
</Form.Item>
<Form.Item
name="file"
label={translate('Photo')}
valuePropName="fileList"
getValueFromEvent={(e) => e.fileList}
>
<Upload
beforeUpload={beforeUpload}
listType="picture"
accept="image/png, image/jpeg"
maxCount={1}
>
<Button icon={<UploadOutlined />}>{translate('click_to_upload')}</Button>
</Upload>
</Form.Item>
</>
);
}