From 232cf0465cda66682241daa50e08815ddc608477 Mon Sep 17 00:00:00 2001 From: SleepWalker Date: Sat, 28 May 2016 00:36:22 +0300 Subject: [PATCH] small refactoring --- src/components/footerMenu/FooterMenu.jsx | 2 +- .../profile/changeEmail/ChangeEmail.jsx | 1 - src/pages/profile/ProfilePage.jsx | 46 +++++++++---------- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/components/footerMenu/FooterMenu.jsx b/src/components/footerMenu/FooterMenu.jsx index 5d65b57..2ac5725 100644 --- a/src/components/footerMenu/FooterMenu.jsx +++ b/src/components/footerMenu/FooterMenu.jsx @@ -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 = { diff --git a/src/components/profile/changeEmail/ChangeEmail.jsx b/src/components/profile/changeEmail/ChangeEmail.jsx index 3257da9..9bfdde2 100644 --- a/src/components/profile/changeEmail/ChangeEmail.jsx +++ b/src/components/profile/changeEmail/ChangeEmail.jsx @@ -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'; diff --git a/src/pages/profile/ProfilePage.jsx b/src/pages/profile/ProfilePage.jsx index e4dee36..3a4c460 100644 --- a/src/pages/profile/ProfilePage.jsx +++ b/src/pages/profile/ProfilePage.jsx @@ -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);