diff --git a/client/actions/login.js b/client/actions/login.js index cf5b344f..be866b50 100644 --- a/client/actions/login.js +++ b/client/actions/login.js @@ -1,6 +1,5 @@ import { LOGIN, - REGISTER, LOGIN_TYPE } from '../constants/action-types.js'; import axios from 'axios'; @@ -24,9 +23,18 @@ const loginActions = (data) => { } const regActions = (data) => { - return { - type: REGISTER, - data + console.log(data); + const param = { + email: data.email, + password: data.password, + username: data.userName + } + return () => { + axios.get('/user/login', param).then((res) => { + console.log(res); + }).catch((err) => { + console.log(err); + }); } } diff --git a/client/containers/Login/loginWrap.js b/client/containers/Login/login-wrap.js similarity index 97% rename from client/containers/Login/loginWrap.js rename to client/containers/Login/login-wrap.js index 0e616cf8..6fab88b0 100644 --- a/client/containers/Login/loginWrap.js +++ b/client/containers/Login/login-wrap.js @@ -1,4 +1,4 @@ -import './Login.scss' +import './login.scss' import React, { Component } from 'react' import { connect } from 'react-redux' import PropTypes from 'prop-types' diff --git a/client/containers/Login/login.scss b/client/containers/Login/login.scss new file mode 100644 index 00000000..23812370 --- /dev/null +++ b/client/containers/Login/login.scss @@ -0,0 +1,7 @@ +@import '../../styles/common.scss'; + +/* .login-main.css */ +.login-form { + width: 4rem; + margin: 1rem auto; +} diff --git a/client/containers/Login/reg.js b/client/containers/Login/reg.js index 87f25aa0..d95f6287 100644 --- a/client/containers/Login/reg.js +++ b/client/containers/Login/reg.js @@ -18,7 +18,10 @@ const FormItem = Form.Item; class Reg extends Component { constructor(props) { - super(props) + super(props); + this.state = { + confirmDirty: false + } } static propTypes = { @@ -29,17 +32,41 @@ class Reg extends Component { handleSubmit = (e) => { e.preventDefault(); const form = this.props.form; - form.validateFields((err, values) => { + form.validateFieldsAndScroll((err, values) => { if (!err) { this.props.regActions(values); } }); } + handleConfirmBlur = (e) => { + const value = e.target.value; + this.setState({ confirmDirty: this.state.confirmDirty || !!value }); + } + + checkPassword = (rule, value, callback) => { + const form = this.props.form; + if (value && value !== form.getFieldValue('password')) { + callback('Two passwords that you enter is inconsistent!'); + } else { + callback(); + } + } + + checkConfirm = (rule, value, callback) => { + const form = this.props.form; + if (value && this.state.confirmDirty) { + form.validateFields(['confirm'], { force: true }); + } + callback(); + } + render() { const { getFieldDecorator } = this.props.form; return (