Skip to content

Commit 20763c9

Browse files
committed
🐛 Minor fixes.
1 parent 4063f7e commit 20763c9

File tree

2 files changed

+59
-40
lines changed

2 files changed

+59
-40
lines changed

app/containers/LoginPage/index.js

Lines changed: 59 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,37 @@
44
*
55
*/
66

7-
import React from "react";
8-
import { Form, InputNumber, Input, Icon, Checkbox, Button } from "antd";
7+
import React from 'react';
8+
import { Form, InputNumber, Input, Icon, Checkbox, Button } from 'antd';
99

10-
import PropTypes from "prop-types";
11-
import { connect } from "react-redux";
12-
import { Link } from "react-router-dom";
13-
import { push } from "react-router-redux";
14-
import { createStructuredSelector } from "reselect";
15-
import { compose } from "redux";
10+
import PropTypes from 'prop-types';
11+
import { connect } from 'react-redux';
12+
import { Link } from 'react-router-dom';
13+
import { push } from 'react-router-redux';
14+
import { createStructuredSelector } from 'reselect';
15+
import { compose } from 'redux';
1616

17-
import injectSaga from "utils/injectSaga";
18-
import injectReducer from "utils/injectReducer";
19-
import makeSelectLoginPage, { makeSelectLogin } from "./selectors";
20-
import reducer from "./reducer";
21-
import saga from "./saga";
17+
import injectSaga from 'utils/injectSaga';
18+
import injectReducer from 'utils/injectReducer';
19+
import makeSelectLoginPage, { makeSelectLogin } from './selectors';
20+
import reducer from './reducer';
21+
import saga from './saga';
2222

2323
// Css
24-
import "./login-page.css";
24+
import './login-page.css';
2525

2626
// Constants
2727
const FormItem = Form.Item;
28-
28+
const formItemLayout = {
29+
labelCol: {
30+
xs: { span: 24 },
31+
sm: { span: 24 }
32+
},
33+
wrapperCol: {
34+
xs: { span: 24 },
35+
sm: { span: 24 }
36+
}
37+
};
2938

3039
class LoginPage extends React.Component {
3140
state = {};
@@ -34,11 +43,20 @@ class LoginPage extends React.Component {
3443
e.preventDefault();
3544
this.props.form.validateFields((err, values) => {
3645
if (!err) {
37-
console.log("Received values of form: ", values);
46+
console.log('Received values of form: ', values);
3847
this.props.dispatchRoute('/dashboard');
3948
}
4049
});
4150
};
51+
52+
checkConfirm = (rule, value, callback) => {
53+
const form = this.props.form;
54+
if (value && this.state.confirmDirty) {
55+
form.validateFields(["confirm"], { force: true });
56+
}
57+
callback();
58+
};
59+
4260
render() {
4361
const { getFieldDecorator } = this.props.form;
4462
return (
@@ -52,26 +70,39 @@ class LoginPage extends React.Component {
5270
</div>
5371
</div>
5472
<div className="login-main">
55-
<Form onSubmit={this.handleSubmit} className="login-form">
56-
<FormItem>
57-
{getFieldDecorator("userName", {
73+
<Form onSubmit={this.handleSubmit}>
74+
<FormItem {...formItemLayout}>
75+
{getFieldDecorator('email', {
5876
rules: [
59-
{ required: true, message: "Please input your username!" }
77+
{
78+
type: 'email',
79+
message: 'The input is not valid E-mail!'
80+
},
81+
{
82+
required: true,
83+
message: 'Please input your E-mail!'
84+
}
6085
]
6186
})(
6287
<Input
6388
size="large"
6489
prefix={
6590
<Icon type="user" style={{ color: "rgba(0,0,0,.25)" }} />
6691
}
67-
placeholder="Username"
92+
placeholder="Email"
6893
/>
6994
)}
7095
</FormItem>
71-
<FormItem>
72-
{getFieldDecorator("password", {
96+
<FormItem {...formItemLayout}>
97+
{getFieldDecorator('password', {
7398
rules: [
74-
{ required: true, message: "Please input your Password!" }
99+
{
100+
required: true,
101+
message: 'Please input your password!'
102+
},
103+
{
104+
validator: this.checkConfirm
105+
}
75106
]
76107
})(
77108
<Input
@@ -85,8 +116,8 @@ class LoginPage extends React.Component {
85116
)}
86117
</FormItem>
87118
<FormItem>
88-
{getFieldDecorator("remember", {
89-
valuePropName: "checked",
119+
{getFieldDecorator('remember', {
120+
valuePropName: 'checked',
90121
initialValue: true
91122
})(<Checkbox>Remember me</Checkbox>)}
92123
<Link className="login-form-forgot" to="/forgot-password">
@@ -122,7 +153,7 @@ const withForm = Form.create();
122153

123154
const withConnect = connect(mapStateToProps, mapDispatchToProps);
124155

125-
const withReducer = injectReducer({ key: "loginPage", reducer });
126-
const withSaga = injectSaga({ key: "loginPage", saga });
156+
const withReducer = injectReducer({ key: 'loginPage', reducer });
157+
const withSaga = injectSaga({ key: 'loginPage', saga });
127158

128159
export default compose(withReducer, withSaga, withConnect, withForm)(LoginPage);

app/containers/SignupPage/index.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,6 @@ export class SignupPage extends React.Component {
7070
sm: { span: 24 }
7171
}
7272
};
73-
const tailFormItemLayout = {
74-
wrapperCol: {
75-
xs: {
76-
span: 24,
77-
offset: 0
78-
},
79-
sm: {
80-
span: 24,
81-
offset: 0
82-
}
83-
}
84-
};
8573

8674
return (
8775
<div className="register-wrap">

0 commit comments

Comments
 (0)