Commit 8e6b18fc authored by nano's avatar nano

fix

parents f7d1fb60 7ae37291
This diff is collapsed.
......@@ -48,7 +48,6 @@
"You can use this E-mail address.": "You can use this E-mail address.",
"This user name has been token.": "This user name has been token.",
"You can use this user name.": "You can use this user name.",
"Password is not correct.": "Password is not correct.",
"User does not exisit.": "User does not exisit.",
"Incorrect password.": "Incorrect password.",
"Please check your registration info again.": "Please check your registration info again.",
......@@ -68,12 +67,16 @@
"Please input your account!":"Please input your email or username!",
"Please input your Password!":"Please input your Password!",
"verify email":"verify email",
"verify-email":"verify email",
"account-info":"Account Info",
"reset-username":"Reset Username",
"reset-email":"Reset Email",
"reset-password":"Reset Password"
"reset-password":"Reset Password",
"old-password":"old password",
"new-password":"new password",
"Password length must be between 8 and 24 characters":"Password length must be between 8 and 24 characters",
"没毛用":"防逗号报错,上线删"
},
"zh": {
"language": "english",
......@@ -84,7 +87,7 @@
"user-info": "用户信息",
"reset-info": "修改信息",
"avatar": "头像",
"nickname": "昵称[选填]",
"nickname": "昵称",
"reset-account-info": "修改账户信息",
"current_password": "原密码",
"password-again": "再次输入密码",
......@@ -124,7 +127,6 @@
"You can use this E-mail address.": "邮箱可以使用",
"This user name has been token.": "该用户名已被注册",
"You can use this user name.": "用户名可以使用",
"Password is not correct.": "密码不一致",
"User does not exisit.": "用户不存在",
"Incorrect password.": "密码不正确",
"Please check your registration info again.": "请填写正确的注册信息。",
......@@ -144,13 +146,18 @@
"Please input your account!":"请填写你的邮箱或用户名!",
"Please input your Password!":"请填写你的密码!",
"verify email":"验证邮箱",
"verify-email":"验证邮箱",
"account-info":"账户信息",
"reset-username":"修改用户名",
"reset-email":"修改邮箱",
"reset-password":"修改密码",
"old-password":"原密码",
"new-password":"新密码",
"Password length must be between 8 and 24 characters":"密码必须为8-24位",
"Please confirm your password":"",
"密码至少为8-24位":"密码至少为8-24位"
"密码至少为8-24位":"密码至少为8-24位",
"没毛用":"防逗号报错,上线删"
}
}
import React from 'react';
import React, { PropTypes } from 'react';
import styles from './EmailForm.css';
import {connect} from 'react-redux'
import { Form, Input, Icon, Button } from 'antd'
......@@ -13,6 +13,9 @@ const formItemLayout = {
class EmailForm extends React.Component {
static contextTypes = {
intl: PropTypes.object.isRequired,
}
onSubmit = (e) => {
const { form, dispatch, user: {id} } = this.props
......@@ -20,7 +23,7 @@ class EmailForm extends React.Component {
form.validateFieldsAndScroll((err, values) => {
if (!err) {
console.log('Received values of form: ', values);
const { email, password } = values
dispatch({type: "user/updateEmail", payload: { email, password, user_id: id }})
......@@ -32,53 +35,54 @@ class EmailForm extends React.Component {
const {form, dispatch, user, checkEmail, isEmailExists} = this.props
const {getFieldDecorator} = form
const {id, email} = user
const {id, email} = data;
const { intl: {messages} } = this.context;
const emailProps = {
fromItem: {
label: "email",
label: messages.email,
hasFeedback: true,
validateStatus: checkEmail,
help: isEmailExists ? 'email exists' : '',
...formItemLayout
},
decorator: {
initialValue: email
initialValue: email
},
input: {
placeholder: "email"
placeholder: messages.email
}
}
const passwordProps = {
fromItem: {
label: "passwrod",
label: messages.password,
...formItemLayout
},
decorator: {
rules: [
{ required: true, message: '密码至少为8-24位', pattern: /^.{8,24}$/ }
{ required: true, message: messages['Password length must be between 8 and 24 characters'], pattern: /^.{8,24}$/ }
]
},
input: {
placeholder: "password",
placeholder: messages.password,
type: 'password'
}
}
return (
<Form onSubmit={this.onSubmit}>
<FormItem {...emailProps.fromItem}>
{getFieldDecorator(`email`, {...emailProps.decorator})(
<Input
{...emailProps.input}
<Input
{...emailProps.input}
onBlur = {() => dispatch({type: 'auth/checkEmail', payload: { ...form.getFieldsValue(), id} })}/>
)}
</FormItem>
<FormItem {...passwordProps.fromItem}>
{getFieldDecorator(`password`, {...passwordProps.decorator})(
{getFieldDecorator('password')(
<Input {...passwordProps.input} />
)}
</FormItem>
......
import React from 'react';
import React, { PropTypes } from 'react';
import styles from './EmailForm.css';
import {connect} from 'react-redux'
import { Form, Input, Icon, Button } from 'antd'
import { Form, Input, Icon, Button } from 'antd';
import SubmitButton from './SubmitButton';
const FormItem = Form.Item;
import SubmitButton from './SubmitButton'
const formItemLayout = {
labelCol: { span: 4 },
......@@ -13,6 +16,9 @@ const formItemLayout = {
class EmailForm extends React.Component {
static contextTypes = {
intl: PropTypes.object.isRequired,
}
checkPassword = (rule, value, callback) => {
const form = this.props.form;
if (value && value !== form.getFieldValue('new_password')) {
......@@ -37,7 +43,7 @@ class EmailForm extends React.Component {
form.validateFieldsAndScroll((err, values) => {
if (!err) {
console.log('Received values of form: ', values);
const { new_password, password } = values
dispatch({type: "user/updateAccount", payload: { new_password, password, user_id: id }})
......@@ -48,53 +54,58 @@ class EmailForm extends React.Component {
render(){
const {form } = this.props
const {getFieldDecorator} = form
const {getFieldDecorator} = form;
const { intl: { messages } } = this.context
const passwordProps = {
fromItem: {
label: "passwrod",
label: 'old passwrod',
...formItemLayout
},
decorator: {
rules: [
{ required: true, message: '密码至少为8-24位', pattern: /^.{8,24}$/ },
{ required: true, message: messages['Password length must be between 8 and 24 characters'], pattern: /^.{8,24}$/ },
{ validator: this.checkConfirm }
]
],
},
input: {
placeholder: "password",
placeholder: messages['old-password'],
type: 'password'
},
input2: {
placeholder: messages['new-password'],
type: 'password'
}
}
const confirmProps = {
fromItem: {
label: "comfirm",
label: messages['password-again'],
...formItemLayout
},
decorator: {
rules: [
{ required: true, message: '密码至少为8-24位', pattern: /^.{8,24}$/},
{ required: true, message: messages['Password length must be between 8 and 24 characters'], pattern: /^.{8,24}$/},
{ validator: this.checkPassword}
]
],
},
input: {
placeholder: "confirm",
placeholder: messages['password-again'],
type: 'password'
}
}
return (
<Form onSubmit={this.onSubmit}>
<FormItem {...passwordProps.fromItem} label="old password">
{getFieldDecorator(`password`, {...passwordProps.decorator})(
<Form onSubmit={this.onSubmit}>
<FormItem {...passwordProps.fromItem} label={messages['old-password']}>
{getFieldDecorator('password')(
<Input {...passwordProps.input} />
)}
</FormItem>
<FormItem {...passwordProps.fromItem} label="new password">
{getFieldDecorator(`new_password`, {...passwordProps.decorator})(
<Input {...passwordProps.input} />
<FormItem {...passwordProps.fromItem} label={messages['new-password']}>
{getFieldDecorator('new_password', {...passwordProps.decorator})(
<Input {...passwordProps.input2} />
)}
</FormItem>
......
import React from 'react';
import React, { PropTypes } from 'react';
import styles from './EmailForm.css';
import { connect } from 'react-redux'
import { Form, Input, Icon, Button, Modal } from 'antd'
import { Form, Input, Icon, Button, Modal } from 'antd';
const FormItem = Form.Item;
import SubmitButton from './SubmitButton'
import SubmitButton from './SubmitButton';
const formItemLayout = {
labelCol: { span: 4 },
......@@ -13,6 +13,10 @@ const formItemLayout = {
class EmailForm extends React.Component {
static contextTypes = {
intl: PropTypes.object.isRequired,
}
onSubmit = (e) => {
const { form, dispatch, user: { id } } = this.props
......@@ -32,11 +36,12 @@ class EmailForm extends React.Component {
const { form, dispatch, user, checkEmail, isEmailExists, isSendEmailActive } = this.props
const { getFieldDecorator } = form;
const { id, email } = user;
const { id, email } = data;
const { intl: { messages } } = this.context;
const emailProps = {
fromItem: {
label: "email",
label: messages.email,
hasFeedback: true,
validateStatus: checkEmail,
help: isEmailExists ? 'email exists' : '',
......@@ -46,22 +51,22 @@ class EmailForm extends React.Component {
initialValue: email
},
input: {
placeholder: "email"
placeholder: messages.email
}
}
const passwordProps = {
fromItem: {
label: "passwrod",
label: messages.passwrod,
...formItemLayout
},
decorator: {
rules: [
{ required: true, message: '密码至少为8-24位', pattern: /^.{8,24}$/ }
{ required: true, message: messages['Password length must be between 8 and 24 characters'], pattern: /^.{8,24}$/ }
]
},
input: {
placeholder: "password",
placeholder: messages.password,
type: 'password'
}
}
......
import { Form, Input } from 'antd';
import React from 'react';
import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
import SubmitButton from './SubmitButton';
const FormItem = Form.Item;
const FormItem = Form.Item;
const formItemLayout = {
labelCol: { span: 4 },
wrapperCol: { span: 15 },
......@@ -12,6 +12,9 @@ const formItemLayout = {
class EmailForm extends React.Component {
static contextTypes = {
intl: PropTypes.object.isRequired,
}
onSubmit = (e) => {
const { form, dispatch, user: { id } } = this.props;
......@@ -31,11 +34,12 @@ class EmailForm extends React.Component {
const { form, dispatch, user, checkUsername, isUserNameExists } = this.props;
const { getFieldDecorator } = form;
const { id, username } = user;
const { id, username } = data;
const { intl: { messages } } = this.context;
const usernameProps = {
fromItem: {
label: 'username',
label: messages.username,
hasFeedback: true,
validateStatus: checkUsername,
help: isUserNameExists ? 'username exists' : '',
......@@ -45,23 +49,23 @@ class EmailForm extends React.Component {
initialValue: username,
},
input: {
placeholder: 'username',
placeholder: messages.username,
onBlur: () => dispatch({ type: 'auth/checkUsername', payload: { ...form.getFieldsValue(), user_id: id } }),
},
};
const passwordProps = {
fromItem: {
label: 'passwrod',
label: messages.password,
...formItemLayout
},
decorator: {
rules: [
{ required: true, message: '密码至少为8-24位', pattern: /^.{8,24}$/ },
{ required: true, message: messages['Password length must be between 8 and 24 characters'], pattern: /^.{8,24}$/ },
],
},
input: {
placeholder: 'password',
placeholder: messages.password,
type: 'password',
},
};
......@@ -69,13 +73,13 @@ class EmailForm extends React.Component {
return (
<Form onSubmit={this.onSubmit}>
<FormItem {...usernameProps.fromItem}>
{getFieldDecorator(`username`, { ...usernameProps.decorator })(
{getFieldDecorator('username', { ...usernameProps.decorator })(
<Input {...usernameProps.input}/>,
)}
</FormItem>
<FormItem {...passwordProps.fromItem}>
{getFieldDecorator(`password`, { ...passwordProps.decorator })(
{getFieldDecorator('password')(
<Input {...passwordProps.input} />,
)}
</FormItem>
......
......@@ -51,16 +51,13 @@ app.router(require('./router'));
addLocaleData([...en, ...zh]);
/*eslint-disable */
let language = navigator.language || (navigator.languages && navigator.languages[0]) || navigator.userLanguage;
let language =localStorage.getItem('locale') || navigator.language || (navigator.languages && navigator.languages[0]) || navigator.userLanguage;
/*eslint-enable */
const languageWithoutRegionCode = language.toLowerCase().split(/[_-]+/)[0];
const languageWithoutRegionCode = language.toLowerCase().split(/[_-]+/)[0];
language = (localeData[languageWithoutRegionCode] || localeData[language]) ? language : 'zh-CN';
const messages = localeData[languageWithoutRegionCode] || localeData[language] || localeData.zh;
if(localStorage.getItem('locale')){
language = JSON.parse(localStorage.getItem('locale'))
}
const App = app.start();
ReactDOM.render(
<IntlProvider locale={language} messages={messages}>
......@@ -69,5 +66,3 @@ ReactDOM.render(
document.getElementById('root'),
);
console.log(language);
......@@ -16,7 +16,7 @@ class Active extends React.Component {
return (
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', minHeight: '100%' }}>
<Button type="primary" icon="poweroff" loading={loading} onClick={this.handleClick}>
<Format id={'verify email'} />
<Format id={'verify-email'} />
</Button>
</div>
);
......
......@@ -51,8 +51,8 @@ class Login extends React.Component {
<Form onSubmit={this.onSubmitLogin} className="login-form">
<Steps size="large" current={0}>
<Step title="Sent Email" icon={<Icon type="solution" />} />
<Step title="Verify Email" icon={<Icon type="mail" />} />
<Step title={messages['send-email']} icon={<Icon type="solution" />} />
<Step title={messages['verify-email']} icon={<Icon type="mail" />} />
</Steps>
<FormItem style={{ marginTop: '28px'}}>
......@@ -62,13 +62,12 @@ class Login extends React.Component {
<Input prefix={<Icon type="user" style={{ fontSize: 13 }}/>} placeholder={messages['email-address-or-username']} />,
)}
</FormItem>
<Button type="primary" htmlType="submit" className="login-form-button">
<Format id={'send-email'} />
</Button>
<FormItem>
<Link to="/signin"><Format id={'sign-in'} /></Link>
</FormItem>
<div>
<Link to="/signin"><Format id={'sign-in'} /></Link>
</div>
</Form>
</Spin>
</div>
......
......@@ -53,15 +53,15 @@ class Login extends React.Component {
)}
</FormItem>
<FormItem>
<Button type="primary" htmlType="submit" className="login-form-button">
<Format id={'sign-in'} />
</Button>
</FormItem>
<Form>
<div>
<Link to="/signup"><Format id={'sign-up'} /></Link>
<Link to="/forgot" className="login-form-forgot"><Format id={'forgot-password'} /></Link>
</Form>
</div>
</Form>
</Spin>
</div>
......
......@@ -83,14 +83,14 @@ class Profiles extends React.Component {
const nameProps = {
fromItem: {
label: 'name',
label: messages['nickname'],
...formItemLayout
},
decorator: {
initialValue: name
},
input: {
placeholder: 'name',
placeholder: messages['nickname'],
}
}
......
......@@ -78,15 +78,15 @@ class Register extends React.Component {
return (
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', height: '100%' }}>
<Spin spinning={loading} delay={100}>
<Steps size="large" current={0}>
<Step title="register" icon={<Icon type="solution" />} />
<Step title="verify Email" icon={<Icon type="mail" />} />
<Step title={messages['sign-up']} icon={<Icon type="solution" />} />
<Step title={messages['verify-email']} icon={<Icon type="mail" />} />
</Steps>
<Form onSubmit={this.onSubmitLogin} className="login-form" style={{ marginTop: '24px'}}>
<FormItem {...emailProps} >
<FormItem {...emailProps} >
{getFieldDecorator('email', {
rules: [{
required: true,
......@@ -112,7 +112,7 @@ class Register extends React.Component {
<FormItem hasFeedback>
{getFieldDecorator('password', {
rules: [{ required: true, message: '密码至少为8-24位', pattern: /^.{8,24}$/ }],
rules: [{ required: true, message: messages['Password length must be between 8 and 24 characters'], pattern: /^.{8,24}$/ }],
}, {
validator: this.checkConfirm,
})(
......@@ -126,7 +126,7 @@ class Register extends React.Component {
<FormItem hasFeedback>
{getFieldDecorator('confirm', {
rules: [{
required: true, message: '密码至少为8-24位', pattern: /^.{8,24}$/,
required: true, message: messages['Password length must be between 8 and 24 characters'], pattern: /^.{8,24}$/,
}, {
validator: this.checkPassword,
}],
......@@ -142,9 +142,9 @@ class Register extends React.Component {
<Button type="primary" htmlType="submit" className="login-form-button">
<Format id={'sign-up'} />
</Button>
<FormItem>
<div>
<Link to="/signin"><Format id={'sign-in'} /></Link>
</FormItem>
</div>
</Form>
</Spin>
</div>
......
import { Button, Form, Icon, Input, Select, Spin } from 'antd';
import { connect } from 'dva';
import React, { PropTypes } from 'react';
import { FormattedMessage as Format } from 'react-intl';
import React from 'react';
const FormItem = Form.Item;
const Option = Select.Option;
class Reset extends React.Component {
static contextTypes = {
intl: PropTypes.object.isRequired,
};
onSubmitReset = (e) => {
const { form, dispatch, location: { query: { key, user_id } } } = this.props;
......@@ -43,35 +48,40 @@ class Reset extends React.Component {
render() {
const { getFieldDecorator } = this.props.form;
const { isResetSubmit = false } = this.props;
const { intl: { messages } } = this.context;
return (
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100%' }}>
<Spin spinning={isResetSubmit} delay={100}>
<Form onSubmit={this.onSubmitReset} className="login-form">
<FormItem>
<h1><Format id='reset-password'/></h1>
</FormItem>
<FormItem>
{getFieldDecorator('password', {
rules: [{ required: true, message: 'Please input your Password!' }],
rules: [{ required: true, message: messages['Password can not be blank'] }],
}, {
validator: this.checkConfirm,
})(
<Input prefix={<Icon type="lock" style={{ fontSize: 13 }}/>} type="password" placeholder="Password"/>,
<Input prefix={<Icon type="lock" style={{ fontSize: 13 }}/>} type="password"
placeholder={messages.password}/>,
)}
</FormItem>
<FormItem>
{getFieldDecorator('confirm', {
rules: [{
required: true, message: 'Please confirm your password!',
required: true, message: messages['Incorrect password.2'],
}, {
validator: this.checkPassword,
}],
})(
<Input type="password" onBlur={this.handleConfirmBlur} placeholder="Password Again"/>,
<Input type="password" onBlur={this.handleConfirmBlur} placeholder={messages['password-again']}/>,
)}
</FormItem>
<Button type="primary" htmlType="submit" className="login-form-button">
Submit
<Format id='reset-password'/>
</Button>
</Form>
</Spin>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment