small refactoring

This commit is contained in:
SleepWalker 2016-05-28 00:36:22 +03:00
parent 0816e7a848
commit 232cf0465c
3 changed files with 24 additions and 25 deletions

View File

@ -8,7 +8,7 @@ import { LangMenu } from 'components/langMenu';
import styles from './footerMenu.scss';
import messages from './footerMenu.intl.json';
export default class FooterMenu extends Component {
class FooterMenu extends Component {
static displayName = 'FooterMenu';
static propTypes = {

View File

@ -1,7 +1,6 @@
import React, { Component, PropTypes } from 'react';
import { FormattedMessage as Message } from 'react-intl';
import { Link } from 'react-router';
import classNames from 'classnames';
import Helmet from 'react-helmet';
import { Motion, spring } from 'react-motion';

View File

@ -69,29 +69,29 @@ export default connect(null, {
return Promise.resolve({requirePassword});
}
})
.then((resp) => new Promise((resolve) => {
if (resp.requirePassword) {
dispatch(createPopup(PasswordRequestForm, (props) => ({
form,
onSubmit: () => {
form.beginLoading();
sendData()
.catch((resp) => {
if (resp.errors) {
form.setErrors(resp.errors);
}
return Promise.reject(resp);
})
.then(resolve)
.then(props.onClose)
.finally(() => form.endLoading());
}
})));
} else {
resolve();
}
}))
.then((resp) => !resp.requirePassword || requestPassword(form))
.finally(() => form.endLoading());
function requestPassword(form) {
return new Promise((resolve) => {
dispatch(createPopup(PasswordRequestForm, (props) => ({
form,
onSubmit: () => {
form.beginLoading();
sendData()
.catch((resp) => {
if (resp.errors) {
form.setErrors(resp.errors);
}
return Promise.reject(resp);
})
.then(resolve)
.then(props.onClose)
.finally(() => form.endLoading());
}
})));
});
}
}
})(ProfilePage);