|
@@ -1,353 +0,0 @@
|
1
|
|
-import {
|
2
|
|
- AutoComplete,
|
3
|
|
- Button,
|
4
|
|
- Cascader,
|
5
|
|
- Checkbox,
|
6
|
|
- Col,
|
7
|
|
- Form,
|
8
|
|
- Input,
|
9
|
|
- InputNumber,
|
10
|
|
- Row,
|
11
|
|
- Select,
|
12
|
|
- Card,
|
13
|
|
-} from 'antd';
|
14
|
|
-import React, { useState } from 'react';
|
15
|
|
-import Page from '@/components/page';
|
16
|
|
-
|
17
|
|
-const { Option } = Select;
|
18
|
|
-const residences = [
|
19
|
|
- {
|
20
|
|
- value: 'zhejiang',
|
21
|
|
- label: 'Zhejiang',
|
22
|
|
- children: [
|
23
|
|
- {
|
24
|
|
- value: 'hangzhou',
|
25
|
|
- label: 'Hangzhou',
|
26
|
|
- children: [
|
27
|
|
- {
|
28
|
|
- value: 'xihu',
|
29
|
|
- label: 'West Lake',
|
30
|
|
- },
|
31
|
|
- ],
|
32
|
|
- },
|
33
|
|
- ],
|
34
|
|
- },
|
35
|
|
- {
|
36
|
|
- value: 'jiangsu',
|
37
|
|
- label: 'Jiangsu',
|
38
|
|
- children: [
|
39
|
|
- {
|
40
|
|
- value: 'nanjing',
|
41
|
|
- label: 'Nanjing',
|
42
|
|
- children: [
|
43
|
|
- {
|
44
|
|
- value: 'zhonghuamen',
|
45
|
|
- label: 'Zhong Hua Men',
|
46
|
|
- },
|
47
|
|
- ],
|
48
|
|
- },
|
49
|
|
- ],
|
50
|
|
- },
|
51
|
|
-];
|
52
|
|
-const formItemLayout = {
|
53
|
|
- labelCol: {
|
54
|
|
- xs: {
|
55
|
|
- span: 24,
|
56
|
|
- },
|
57
|
|
- sm: {
|
58
|
|
- span: 8,
|
59
|
|
- },
|
60
|
|
- },
|
61
|
|
- wrapperCol: {
|
62
|
|
- xs: {
|
63
|
|
- span: 24,
|
64
|
|
- },
|
65
|
|
- sm: {
|
66
|
|
- span: 16,
|
67
|
|
- },
|
68
|
|
- },
|
69
|
|
-};
|
70
|
|
-const tailFormItemLayout = {
|
71
|
|
- wrapperCol: {
|
72
|
|
- xs: {
|
73
|
|
- span: 24,
|
74
|
|
- offset: 0,
|
75
|
|
- },
|
76
|
|
- sm: {
|
77
|
|
- span: 16,
|
78
|
|
- offset: 8,
|
79
|
|
- },
|
80
|
|
- },
|
81
|
|
-};
|
82
|
|
-
|
83
|
|
-
|
84
|
|
-const BasicForm = () => {
|
85
|
|
- const [form] = Form.useForm();
|
86
|
|
-
|
87
|
|
- const onFinish = (values) => {
|
88
|
|
- console.log('Received values of form: ', values);
|
89
|
|
- };
|
90
|
|
-
|
91
|
|
- const prefixSelector = (
|
92
|
|
- <Form.Item name="prefix" noStyle>
|
93
|
|
- <Select
|
94
|
|
- style={{
|
95
|
|
- width: 70,
|
96
|
|
- }}
|
97
|
|
- >
|
98
|
|
- <Option value="86">+86</Option>
|
99
|
|
- <Option value="87">+87</Option>
|
100
|
|
- </Select>
|
101
|
|
- </Form.Item>
|
102
|
|
- );
|
103
|
|
- const suffixSelector = (
|
104
|
|
- <Form.Item name="suffix" noStyle>
|
105
|
|
- <Select
|
106
|
|
- style={{
|
107
|
|
- width: 70,
|
108
|
|
- }}
|
109
|
|
- >
|
110
|
|
- <Option value="USD">$</Option>
|
111
|
|
- <Option value="CNY">¥</Option>
|
112
|
|
- </Select>
|
113
|
|
- </Form.Item>
|
114
|
|
- );
|
115
|
|
- const [autoCompleteResult, setAutoCompleteResult] = useState([]);
|
116
|
|
-
|
117
|
|
- const onWebsiteChange = (value) => {
|
118
|
|
- if (!value) {
|
119
|
|
- setAutoCompleteResult([]);
|
120
|
|
- } else {
|
121
|
|
- setAutoCompleteResult(['.com', '.org', '.net'].map((domain) => `${value}${domain}`));
|
122
|
|
- }
|
123
|
|
- };
|
124
|
|
-
|
125
|
|
- const websiteOptions = autoCompleteResult.map((website) => ({
|
126
|
|
- label: website,
|
127
|
|
- value: website,
|
128
|
|
- }));
|
129
|
|
- return (
|
130
|
|
- <Form
|
131
|
|
- {...formItemLayout}
|
132
|
|
- form={form}
|
133
|
|
- name="register"
|
134
|
|
- onFinish={onFinish}
|
135
|
|
- initialValues={{
|
136
|
|
- residence: ['zhejiang', 'hangzhou', 'xihu'],
|
137
|
|
- prefix: '86',
|
138
|
|
- }}
|
139
|
|
- scrollToFirstError
|
140
|
|
- style={{ background: '#fff', boxSizing: 'border-box', padding: '24px' }}
|
141
|
|
- >
|
142
|
|
- <Form.Item
|
143
|
|
- name="email"
|
144
|
|
- label="E-mail"
|
145
|
|
- rules={[
|
146
|
|
- {
|
147
|
|
- type: 'email',
|
148
|
|
- message: 'The input is not valid E-mail!',
|
149
|
|
- },
|
150
|
|
- {
|
151
|
|
- required: true,
|
152
|
|
- message: 'Please input your E-mail!',
|
153
|
|
- },
|
154
|
|
- ]}
|
155
|
|
- >
|
156
|
|
- <Input />
|
157
|
|
- </Form.Item>
|
158
|
|
-
|
159
|
|
- <Form.Item
|
160
|
|
- name="password"
|
161
|
|
- label="Password"
|
162
|
|
- rules={[
|
163
|
|
- {
|
164
|
|
- required: true,
|
165
|
|
- message: 'Please input your password!',
|
166
|
|
- },
|
167
|
|
- ]}
|
168
|
|
- hasFeedback
|
169
|
|
- >
|
170
|
|
- <Input.Password />
|
171
|
|
- </Form.Item>
|
172
|
|
-
|
173
|
|
- <Form.Item
|
174
|
|
- name="confirm"
|
175
|
|
- label="Confirm Password"
|
176
|
|
- dependencies={['password']}
|
177
|
|
- hasFeedback
|
178
|
|
- rules={[
|
179
|
|
- {
|
180
|
|
- required: true,
|
181
|
|
- message: 'Please confirm your password!',
|
182
|
|
- },
|
183
|
|
- ({ getFieldValue }) => ({
|
184
|
|
- validator(_, value) {
|
185
|
|
- if (!value || getFieldValue('password') === value) {
|
186
|
|
- return Promise.resolve();
|
187
|
|
- }
|
188
|
|
-
|
189
|
|
- return Promise.reject(new Error('The two passwords that you entered do not match!'));
|
190
|
|
- },
|
191
|
|
- }),
|
192
|
|
- ]}
|
193
|
|
- >
|
194
|
|
- <Input.Password />
|
195
|
|
- </Form.Item>
|
196
|
|
-
|
197
|
|
- <Form.Item
|
198
|
|
- name="nickname"
|
199
|
|
- label="Nickname"
|
200
|
|
- tooltip="What do you want others to call you?"
|
201
|
|
- rules={[
|
202
|
|
- {
|
203
|
|
- required: true,
|
204
|
|
- message: 'Please input your nickname!',
|
205
|
|
- whitespace: true,
|
206
|
|
- },
|
207
|
|
- ]}
|
208
|
|
- >
|
209
|
|
- <Input />
|
210
|
|
- </Form.Item>
|
211
|
|
-
|
212
|
|
- <Form.Item
|
213
|
|
- name="residence"
|
214
|
|
- label="Habitual Residence"
|
215
|
|
- rules={[
|
216
|
|
- {
|
217
|
|
- type: 'array',
|
218
|
|
- required: true,
|
219
|
|
- message: 'Please select your habitual residence!',
|
220
|
|
- },
|
221
|
|
- ]}
|
222
|
|
- >
|
223
|
|
- <Cascader options={residences} />
|
224
|
|
- </Form.Item>
|
225
|
|
-
|
226
|
|
- <Form.Item
|
227
|
|
- name="phone"
|
228
|
|
- label="Phone Number"
|
229
|
|
- rules={[
|
230
|
|
- {
|
231
|
|
- required: true,
|
232
|
|
- message: 'Please input your phone number!',
|
233
|
|
- },
|
234
|
|
- ]}
|
235
|
|
- >
|
236
|
|
- <Input
|
237
|
|
- addonBefore={prefixSelector}
|
238
|
|
- style={{
|
239
|
|
- width: '100%',
|
240
|
|
- }}
|
241
|
|
- />
|
242
|
|
- </Form.Item>
|
243
|
|
-
|
244
|
|
- <Form.Item
|
245
|
|
- name="donation"
|
246
|
|
- label="Donation"
|
247
|
|
- rules={[
|
248
|
|
- {
|
249
|
|
- required: true,
|
250
|
|
- message: 'Please input donation amount!',
|
251
|
|
- },
|
252
|
|
- ]}
|
253
|
|
- >
|
254
|
|
- <InputNumber
|
255
|
|
- addonAfter={suffixSelector}
|
256
|
|
- style={{
|
257
|
|
- width: '100%',
|
258
|
|
- }}
|
259
|
|
- />
|
260
|
|
- </Form.Item>
|
261
|
|
-
|
262
|
|
- <Form.Item
|
263
|
|
- name="website"
|
264
|
|
- label="Website"
|
265
|
|
- rules={[
|
266
|
|
- {
|
267
|
|
- required: true,
|
268
|
|
- message: 'Please input website!',
|
269
|
|
- },
|
270
|
|
- ]}
|
271
|
|
- >
|
272
|
|
- <AutoComplete options={websiteOptions} onChange={onWebsiteChange} placeholder="website">
|
273
|
|
- <Input />
|
274
|
|
- </AutoComplete>
|
275
|
|
- </Form.Item>
|
276
|
|
-
|
277
|
|
- <Form.Item
|
278
|
|
- name="intro"
|
279
|
|
- label="Intro"
|
280
|
|
- rules={[
|
281
|
|
- {
|
282
|
|
- required: true,
|
283
|
|
- message: 'Please input Intro',
|
284
|
|
- },
|
285
|
|
- ]}
|
286
|
|
- >
|
287
|
|
- <Input.TextArea showCount maxLength={100} />
|
288
|
|
- </Form.Item>
|
289
|
|
-
|
290
|
|
- <Form.Item
|
291
|
|
- name="gender"
|
292
|
|
- label="Gender"
|
293
|
|
- rules={[
|
294
|
|
- {
|
295
|
|
- required: true,
|
296
|
|
- message: 'Please select gender!',
|
297
|
|
- },
|
298
|
|
- ]}
|
299
|
|
- >
|
300
|
|
- <Select placeholder="select your gender">
|
301
|
|
- <Option value="male">Male</Option>
|
302
|
|
- <Option value="female">Female</Option>
|
303
|
|
- <Option value="other">Other</Option>
|
304
|
|
- </Select>
|
305
|
|
- </Form.Item>
|
306
|
|
-
|
307
|
|
- <Form.Item label="Captcha" extra="We must make sure that your are a human.">
|
308
|
|
- <Row gutter={8}>
|
309
|
|
- <Col span={12}>
|
310
|
|
- <Form.Item
|
311
|
|
- name="captcha"
|
312
|
|
- noStyle
|
313
|
|
- rules={[
|
314
|
|
- {
|
315
|
|
- required: true,
|
316
|
|
- message: 'Please input the captcha you got!',
|
317
|
|
- },
|
318
|
|
- ]}
|
319
|
|
- >
|
320
|
|
- <Input />
|
321
|
|
- </Form.Item>
|
322
|
|
- </Col>
|
323
|
|
- <Col span={12}>
|
324
|
|
- <Button>Get captcha</Button>
|
325
|
|
- </Col>
|
326
|
|
- </Row>
|
327
|
|
- </Form.Item>
|
328
|
|
-
|
329
|
|
- <Form.Item
|
330
|
|
- name="agreement"
|
331
|
|
- valuePropName="checked"
|
332
|
|
- rules={[
|
333
|
|
- {
|
334
|
|
- validator: (_, value) =>
|
335
|
|
- value ? Promise.resolve() : Promise.reject(new Error('Should accept agreement')),
|
336
|
|
- },
|
337
|
|
- ]}
|
338
|
|
- {...tailFormItemLayout}
|
339
|
|
- >
|
340
|
|
- <Checkbox>
|
341
|
|
- I have read the <a href="">agreement</a>
|
342
|
|
- </Checkbox>
|
343
|
|
- </Form.Item>
|
344
|
|
- <Form.Item {...tailFormItemLayout}>
|
345
|
|
- <Button type="primary" htmlType="submit">
|
346
|
|
- Register
|
347
|
|
- </Button>
|
348
|
|
- </Form.Item>
|
349
|
|
- </Form>
|
350
|
|
- );
|
351
|
|
-};
|
352
|
|
-
|
353
|
|
-export default () => <Page><Card><BasicForm /></Card></Page>;
|