Commit f6c98b2e authored by 2breakegg's avatar 2breakegg

reformat code

parent e32291a9
...@@ -99,7 +99,7 @@ class EmailForm extends React.Component { ...@@ -99,7 +99,7 @@ class EmailForm extends React.Component {
} }
function mapStateToProps(state, props) { function mapStateToProps(state) {
const { const {
user: { user }, user: { user },
auth: { isEmailExists, checkEmail }, auth: { isEmailExists, checkEmail },
......
...@@ -72,7 +72,7 @@ class EmailForm extends React.Component { ...@@ -72,7 +72,7 @@ class EmailForm extends React.Component {
} }
function mapStateToProps(state, props) { function mapStateToProps(state) {
const { const {
user: { user }, user: { user },
auth: { isEmailExists, checkEmail, isSendEmailActive }, auth: { isEmailExists, checkEmail, isSendEmailActive },
......
...@@ -166,7 +166,6 @@ export default { ...@@ -166,7 +166,6 @@ export default {
} }
}, },
*checkEmail({ payload }, { call, put }) { *checkEmail({ payload }, { call, put }) {
if (!payload.email) { if (!payload.email) {
yield put({ type: 'check', payload: { checkEmail: 'error' } }); yield put({ type: 'check', payload: { checkEmail: 'error' } });
return; return;
......
...@@ -17,7 +17,7 @@ export default { ...@@ -17,7 +17,7 @@ export default {
effects: {}, effects: {},
subscriptions: { subscriptions: {
setup({ dispatch }) { setup({ dispatch }) {
let language = localStorage.getItem('locale') || navigator.language || (navigator.languages && navigator.languages[0]) || navigator.userLanguage; const language = localStorage.getItem('locale') || navigator.language || (navigator.languages && navigator.languages[0]) || navigator.userLanguage;
const languageWithoutRegionCode = language.toLowerCase().split(/[_-]+/)[0]; const languageWithoutRegionCode = language.toLowerCase().split(/[_-]+/)[0];
const messages = i18n[languageWithoutRegionCode]; const messages = i18n[languageWithoutRegionCode];
......
...@@ -118,7 +118,7 @@ export default { ...@@ -118,7 +118,7 @@ export default {
const { token } = payload; const { token } = payload;
try { try {
let { data } = yield call(getAuthUser, { token }); const { data } = yield call(getAuthUser, { token });
if (data) { if (data) {
yield put({ type: 'getAuthUserSuccess', payload: { user: data, token } }); yield put({ type: 'getAuthUserSuccess', payload: { user: data, token } });
} }
...@@ -135,7 +135,7 @@ export default { ...@@ -135,7 +135,7 @@ export default {
} }
try { try {
let { data } = yield call(getAuthUser, { token }); const { data } = yield call(getAuthUser, { token });
if (data) { if (data) {
if (handleSSO(data)) { if (handleSSO(data)) {
return; return;
...@@ -155,10 +155,10 @@ export default { ...@@ -155,10 +155,10 @@ export default {
*updateProfile({ payload }, { call, put, select }) { *updateProfile({ payload }, { call, put, select }) {
message.destroy(); message.destroy();
let token = yield select(state => state.user.token); const token = yield select(state => state.user.token);
let { messages } = yield select(state => state.common); const { messages } = yield select(state => state.common);
try { try {
let { data } = yield call(updateProfile, { ...payload, token }); const { data } = yield call(updateProfile, { ...payload, token });
if (data) { if (data) {
yield put({ type: 'updateProfileSuccess', payload: { user: data, token } }); yield put({ type: 'updateProfileSuccess', payload: { user: data, token } });
...@@ -170,10 +170,10 @@ export default { ...@@ -170,10 +170,10 @@ export default {
} }
}, },
*updateEmail({ payload }, { call, put, select }) { *updateEmail({ payload }, { call, put, select }) {
let { messages } = yield select(state => state.common); const { messages } = yield select(state => state.common);
try { try {
let token = yield select(state => state.user.token); const token = yield select(state => state.user.token);
let { data } = yield call(updateAccount, { ...payload, token }); const { data } = yield call(updateAccount, { ...payload, token });
if (data) { if (data) {
yield put({ type: 'updateAccountSuccess', payload: { user: data, token } }); yield put({ type: 'updateAccountSuccess', payload: { user: data, token } });
message.info(messages['A-verification-email-has-been-sent-to-you,please-check-the-mail-to-complete.']); message.info(messages['A-verification-email-has-been-sent-to-you,please-check-the-mail-to-complete.']);
...@@ -185,10 +185,10 @@ export default { ...@@ -185,10 +185,10 @@ export default {
}, },
*updateAccount({ payload }, { call, put, select }) { *updateAccount({ payload }, { call, put, select }) {
let { messages } = yield select(state => state.common); const { messages } = yield select(state => state.common);
try { try {
let token = yield select(state => state.user.token); const token = yield select(state => state.user.token);
let { data } = yield call(updateAccount, { ...payload, token }); const { data } = yield call(updateAccount, { ...payload, token });
if (data) { if (data) {
yield put({ type: 'updateAccountSuccess', payload: { user: data, token } }); yield put({ type: 'updateAccountSuccess', payload: { user: data, token } });
message.info(messages.update_success); message.info(messages.update_success);
...@@ -201,12 +201,12 @@ export default { ...@@ -201,12 +201,12 @@ export default {
}, },
subscriptions: { subscriptions: {
setup({ dispatch, history }) { setup({ dispatch, history }) {
let token = localStorage.getItem('token'); const token = localStorage.getItem('token');
if (token) { if (token) {
dispatch({ type: 'getAuthUser', payload: { token } }); dispatch({ type: 'getAuthUser', payload: { token } });
} }
history.listen(({ pathname }) => { history.listen(({ pathname }) => {
if (pathname == '/') { if (pathname === '/') {
dispatch({ type: 'preLogin', payload: { token } }); dispatch({ type: 'preLogin', payload: { token } });
} }
}); });
......
...@@ -24,10 +24,7 @@ class Active extends React.Component { ...@@ -24,10 +24,7 @@ class Active extends React.Component {
} }
function mapStateToProps(state) { function mapStateToProps(state) {
const {} = state;
const loading = state.loading.global || false; const loading = state.loading.global || false;
return { return {
loading, loading,
}; };
......
import { Button, Form, Icon, Input, Select, Spin, Steps } from 'antd'; import { Button, Form, Icon, Input, Spin, Steps } from 'antd';
import { connect } from 'dva'; import { connect } from 'dva';
import { Link } from 'dva/router'; import { Link } from 'dva/router';
import React, { PropTypes } from 'react'; import React, { PropTypes } from 'react';
......
...@@ -126,7 +126,7 @@ const particleConfig = { ...@@ -126,7 +126,7 @@ const particleConfig = {
function Index({ children, messages }) { function Index({ children, messages }) {
return ( return (
<div style={{ display: 'flex', flexDirection: 'column', flex: 1, height: '100vh' }}> <div style={{ display: 'flex', flexDirection: 'column', flex: 1, height: '100vh' }}>
<DocumentTitle title={messages['title'] || 'Moe Cube'} /> <DocumentTitle title={messages.title || 'Moe Cube'} />
<Header style={{ display: 'flex', alignItems: 'center' }}> <Header style={{ display: 'flex', alignItems: 'center' }}>
<Link to="/" style={{ marginTop: '20px' }}> <Link to="/" style={{ marginTop: '20px' }}>
......
...@@ -41,11 +41,9 @@ class Profiles extends React.Component { ...@@ -41,11 +41,9 @@ class Profiles extends React.Component {
console.log(blob); console.log(blob);
this.props.dispatch({ type: 'upload/upload', payload: { image: blob, user_id: id } }); this.props.dispatch({ type: 'upload/upload', payload: { image: blob, user_id: id } });
}); });
}; };
onGetFile = (e) => { onGetFile = (e) => {
let files; let files;
if (e.dataTransfer) { if (e.dataTransfer) {
files = e.dataTransfer.files; files = e.dataTransfer.files;
...@@ -75,9 +73,9 @@ class Profiles extends React.Component { ...@@ -75,9 +73,9 @@ class Profiles extends React.Component {
}; };
render() { render() {
const { dispatch, form, user, loading, progress, status, imageUrl, isUpload, uploadedImage } = this.props; const { dispatch, form, user, loading, imageUrl, isUpload } = this.props;
const { getFieldDecorator } = form; const { getFieldDecorator } = form;
const { username, name, id, avatar } = user; const { name, avatar } = user;
const { intl: { messages } } = this.context; const { intl: { messages } } = this.context;
const nameProps = { const nameProps = {
...@@ -93,12 +91,6 @@ class Profiles extends React.Component { ...@@ -93,12 +91,6 @@ class Profiles extends React.Component {
}, },
}; };
const crop = {
maxHeight: 80,
width: 30,
aspect: 16 / 16,
};
return ( return (
<Spin spinning={loading} delay={100}> <Spin spinning={loading} delay={100}>
...@@ -127,19 +119,20 @@ class Profiles extends React.Component { ...@@ -127,19 +119,20 @@ class Profiles extends React.Component {
}} style={{ display: 'none' }}/> }} style={{ display: 'none' }}/>
</label> </label>
</Button> </Button>
<Button type="primary" onClick={ this.handleUpload}> <Button type="primary" onClick={this.handleUpload}>
<Icon type="upload"/> upload <Icon type="upload"/> upload
</Button> </Button>
</div> </div>
: :
<img src={ avatar || imageUrl || defaultAvatar } <img src={avatar || imageUrl || defaultAvatar}
onClick={() => dispatch({ type: 'upload/start' })}/> onClick={() => dispatch({ type: 'upload/start' })}
/>
} }
</FormItem> </FormItem>
<FormItem {...nameProps.fromItem}> <FormItem {...nameProps.fromItem}>
{getFieldDecorator(`name`, { ...nameProps.decorator })( {getFieldDecorator('name', { ...nameProps.decorator })(
<Input {...nameProps.input} />, <Input {...nameProps.input} />,
)} )}
</FormItem> </FormItem>
......
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