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