mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-10-02 16:27:15 +05:30
#337: improve code style in some places
This commit is contained in:
parent
41661dbea5
commit
ed53c9b564
@ -1,4 +1,5 @@
|
|||||||
import React, { Component, PropTypes } from 'react';
|
// @flow
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
|
||||||
import { FormattedMessage as Message } from 'react-intl';
|
import { FormattedMessage as Message } from 'react-intl';
|
||||||
|
|
||||||
@ -9,12 +10,10 @@ import styles from './appInfo.scss';
|
|||||||
import messages from './AppInfo.intl.json';
|
import messages from './AppInfo.intl.json';
|
||||||
|
|
||||||
export default class AppInfo extends Component {
|
export default class AppInfo extends Component {
|
||||||
static displayName = 'AppInfo';
|
props: {
|
||||||
|
name?: string,
|
||||||
static propTypes = {
|
description?: string,
|
||||||
name: PropTypes.string,
|
onGoToAuth: () => void
|
||||||
description: PropTypes.string,
|
|
||||||
onGoToAuth: PropTypes.func.isRequired
|
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -10,7 +10,6 @@ import messages from './langMenu.intl.json';
|
|||||||
import LANGS from 'i18n/index.json';
|
import LANGS from 'i18n/index.json';
|
||||||
|
|
||||||
class LangMenu extends Component {
|
class LangMenu extends Component {
|
||||||
static displayName = 'LangMenu';
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
showCurrentLang: PropTypes.bool,
|
showCurrentLang: PropTypes.bool,
|
||||||
toggleRef: PropTypes.func,
|
toggleRef: PropTypes.func,
|
||||||
@ -85,6 +84,7 @@ class LangMenu extends Component {
|
|||||||
renderLangLabel(locale, localeData) {
|
renderLangLabel(locale, localeData) {
|
||||||
const {name, progress, isReleased} = localeData;
|
const {name, progress, isReleased} = localeData;
|
||||||
let progressLabel;
|
let progressLabel;
|
||||||
|
|
||||||
if (progress !== 100) {
|
if (progress !== 100) {
|
||||||
progressLabel = (
|
progressLabel = (
|
||||||
<span className={styles.langTranslateUnfinished}>
|
<span className={styles.langTranslateUnfinished}>
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
import { PropTypes } from 'react';
|
// @flow
|
||||||
|
import React from 'react';
|
||||||
import { Route } from 'react-router-dom';
|
import { Route } from 'react-router-dom';
|
||||||
|
|
||||||
import AuthFlowRouteContents from './AuthFlowRouteContents';
|
import AuthFlowRouteContents from './AuthFlowRouteContents';
|
||||||
|
|
||||||
export default function AuthFlowRoute(props) {
|
export default function AuthFlowRoute(props: {
|
||||||
|
component: any,
|
||||||
|
routerProps: Object
|
||||||
|
}) {
|
||||||
const {component: Component, ...routeProps} = props;
|
const {component: Component, ...routeProps} = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -12,8 +16,3 @@ export default function AuthFlowRoute(props) {
|
|||||||
)}/>
|
)}/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthFlowRoute.propTypes = {
|
|
||||||
component: PropTypes.any,
|
|
||||||
routerProps: PropTypes.object
|
|
||||||
};
|
|
||||||
|
@ -1,15 +1,20 @@
|
|||||||
import { Component, PropTypes } from 'react';
|
// @flow
|
||||||
|
import React, { Component } from 'react';
|
||||||
import { Redirect } from 'react-router-dom';
|
import { Redirect } from 'react-router-dom';
|
||||||
|
|
||||||
import authFlow from 'services/authFlow';
|
import authFlow from 'services/authFlow';
|
||||||
|
|
||||||
export default class AuthFlowRouteContents extends Component {
|
type ComponentProps = {
|
||||||
static propTypes = {
|
component: any,
|
||||||
component: PropTypes.any,
|
routerProps: Object
|
||||||
routerProps: PropTypes.object
|
};
|
||||||
};
|
|
||||||
|
|
||||||
state = {
|
export default class AuthFlowRouteContents extends Component {
|
||||||
|
props: ComponentProps;
|
||||||
|
|
||||||
|
state: {
|
||||||
|
component: any
|
||||||
|
} = {
|
||||||
component: null
|
component: null
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -17,7 +22,7 @@ export default class AuthFlowRouteContents extends Component {
|
|||||||
this.handleProps(this.props);
|
this.handleProps(this.props);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps: ComponentProps) {
|
||||||
this.handleProps(nextProps);
|
this.handleProps(nextProps);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,7 +30,7 @@ export default class AuthFlowRouteContents extends Component {
|
|||||||
return this.state.component;
|
return this.state.component;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleProps(props) {
|
handleProps(props: ComponentProps) {
|
||||||
const {routerProps} = props;
|
const {routerProps} = props;
|
||||||
|
|
||||||
authFlow.handleRequest({
|
authFlow.handleRequest({
|
||||||
@ -35,13 +40,13 @@ export default class AuthFlowRouteContents extends Component {
|
|||||||
}, this.onRedirect.bind(this), this.onRouteAllowed.bind(this, props));
|
}, this.onRedirect.bind(this), this.onRouteAllowed.bind(this, props));
|
||||||
}
|
}
|
||||||
|
|
||||||
onRedirect(path) {
|
onRedirect(path: string) {
|
||||||
this.setState({
|
this.setState({
|
||||||
component: <Redirect to={path} />
|
component: <Redirect to={path} />
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onRouteAllowed(props) {
|
onRouteAllowed(props: ComponentProps) {
|
||||||
const {component: Component} = props;
|
const {component: Component} = props;
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Component, PropTypes } from 'react';
|
// @flow
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
|
||||||
import { Route, Switch, Redirect } from 'react-router-dom';
|
import { Route, Switch, Redirect } from 'react-router-dom';
|
||||||
|
|
||||||
@ -20,13 +21,12 @@ import Finish from 'components/auth/finish/Finish';
|
|||||||
import styles from './auth.scss';
|
import styles from './auth.scss';
|
||||||
|
|
||||||
class AuthPage extends Component {
|
class AuthPage extends Component {
|
||||||
static displayName = 'AuthPage';
|
props: {
|
||||||
static propTypes = {
|
client: {
|
||||||
client: PropTypes.shape({
|
id: string,
|
||||||
id: PropTypes.string.isRequired,
|
name: string,
|
||||||
name: PropTypes.string.isRequired,
|
description: string
|
||||||
description: PropTypes.string.isRequired
|
}
|
||||||
})
|
|
||||||
};
|
};
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
@ -42,6 +42,7 @@ class AuthPage extends Component {
|
|||||||
<div className={isSidebarHidden ? styles.hiddenSidebar : styles.sidebar}>
|
<div className={isSidebarHidden ? styles.hiddenSidebar : styles.sidebar}>
|
||||||
<AppInfo {...client} onGoToAuth={this.onGoToAuth} />
|
<AppInfo {...client} onGoToAuth={this.onGoToAuth} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={styles.content}>
|
<div className={styles.content}>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/login" render={renderPanelTransition(Login)} />
|
<Route path="/login" render={renderPanelTransition(Login)} />
|
||||||
|
Loading…
Reference in New Issue
Block a user