Login.jsx
1.96 KB
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
import React from 'react';
import { Form, Icon, Input, Button } from 'antd';
import 'antd/dist/antd.css';
import './resources/style/css/login.css';
class Login extends React.Component {
_validateFromSubmitFn = e => {
e.preventDefault();
this.props.form.validateFields((err, values) => {
if (!err) {
this._getFormSubmit(values);
}
});
};
_getFormSubmit = value => {
this.props.getFormSubmitFn(value);
};
render() {
const { getFieldDecorator } = this.props.form;
return (
<React.Fragment>
<Form onSubmit={this._validateFromSubmitFn} className="login-form">
<Form.Item>
{getFieldDecorator('userName', {
rules: [
{ required: true, message: 'Please input your username !!!' }
]
})(
<Input
prefix={
<Icon type="user" style={{ color: 'rgba(0,0,0,.25)' }} />
}
placeholder="Username"
autoFocus
autoComplete="off"
/>
)}
</Form.Item>
<Form.Item>
{getFieldDecorator('password', {
rules: [
{ required: true, message: 'Please input your Password!' }
]
})(
<Input
prefix={
<Icon type="lock" style={{ color: 'rgba(0,0,0,.25)' }} />
}
type="password"
placeholder="Password"
autoComplete="off"
/>
)}
</Form.Item>
<Form.Item>
<Button
type="primary"
htmlType="submit"
className="login-form-button"
>
Log in
</Button>
</Form.Item>
</Form>
</React.Fragment>
);
}
}
const WrappedLoginForm = Form.create({ name: 'normal_login' })(Login);
export default WrappedLoginForm;