mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-30 10:42:34 +05:30
#336: add lang attribute for html
This commit is contained in:
parent
3ac62e5eeb
commit
4f38eb2740
2
src/components/user/index.js
Normal file
2
src/components/user/index.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
// @flow
|
||||||
|
export type { User } from './reducer.js';
|
@ -1,5 +1,18 @@
|
|||||||
import { UPDATE, SET, CHANGE_LANG } from './actions';
|
import { UPDATE, SET, CHANGE_LANG } from './actions';
|
||||||
|
|
||||||
|
export type User = {
|
||||||
|
id: number,
|
||||||
|
uuid: string,
|
||||||
|
token: string,
|
||||||
|
username: string,
|
||||||
|
email: string,
|
||||||
|
avatar: string,
|
||||||
|
isGuest: boolean,
|
||||||
|
isActive: boolean,
|
||||||
|
passwordChangedAt: number,
|
||||||
|
hasMojangUsernameCollision: bool,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const defaults = {
|
const defaults = {
|
||||||
id: null,
|
id: null,
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { Component, PropTypes } from 'react';
|
import React, { Component } from 'react';
|
||||||
|
|
||||||
import { FormattedMessage as Message } from 'react-intl';
|
import { FormattedMessage as Message } from 'react-intl';
|
||||||
import { Route, Link, Switch } from 'react-router-dom';
|
import { Route, Link, Switch } from 'react-router-dom';
|
||||||
|
import Helmet from 'react-helmet';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import AuthPage from 'pages/auth/AuthPage';
|
import AuthPage from 'pages/auth/AuthPage';
|
||||||
@ -9,12 +10,14 @@ import ProfilePage from 'pages/profile/ProfilePage';
|
|||||||
import RulesPage from 'pages/rules/RulesPage';
|
import RulesPage from 'pages/rules/RulesPage';
|
||||||
import PageNotFound from 'pages/404/PageNotFound';
|
import PageNotFound from 'pages/404/PageNotFound';
|
||||||
|
|
||||||
|
// @flow
|
||||||
import { restoreScroll } from 'functions';
|
import { restoreScroll } from 'functions';
|
||||||
import PrivateRoute from 'containers/PrivateRoute';
|
import PrivateRoute from 'containers/PrivateRoute';
|
||||||
import AuthFlowRoute from 'containers/AuthFlowRoute';
|
import AuthFlowRoute from 'containers/AuthFlowRoute';
|
||||||
import Userbar from 'components/userbar/Userbar';
|
import Userbar from 'components/userbar/Userbar';
|
||||||
import PopupStack from 'components/ui/popup/PopupStack';
|
import PopupStack from 'components/ui/popup/PopupStack';
|
||||||
import loader from 'services/loader';
|
import loader from 'services/loader';
|
||||||
|
import type { User } from 'components/user';
|
||||||
|
|
||||||
import styles from './root.scss';
|
import styles from './root.scss';
|
||||||
import messages from './RootPage.intl.json';
|
import messages from './RootPage.intl.json';
|
||||||
@ -28,6 +31,15 @@ if (process.env.NODE_ENV === 'production') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class RootPage extends Component {
|
class RootPage extends Component {
|
||||||
|
props: {
|
||||||
|
user: User,
|
||||||
|
isPopupActive: boolean,
|
||||||
|
onLogoClick: Function,
|
||||||
|
location: {
|
||||||
|
pathname: string
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.onPageUpdate();
|
this.onPageUpdate();
|
||||||
}
|
}
|
||||||
@ -43,12 +55,18 @@ class RootPage extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const props = this.props;
|
const props = this.props;
|
||||||
|
const {user} = this.props;
|
||||||
const isRegisterPage = props.location.pathname === '/register';
|
const isRegisterPage = props.location.pathname === '/register';
|
||||||
|
|
||||||
document.body.style.overflow = props.isPopupActive ? 'hidden' : '';
|
if (document && document.body) {
|
||||||
|
document.body.style.overflow = props.isPopupActive ? 'hidden' : '';
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.root}>
|
<div className={styles.root}>
|
||||||
|
<Helmet>
|
||||||
|
<html lang={user.lang} />
|
||||||
|
</Helmet>
|
||||||
<div id="view-port" className={classNames(styles.viewPort, {
|
<div id="view-port" className={classNames(styles.viewPort, {
|
||||||
[styles.isPopupActive]: props.isPopupActive
|
[styles.isPopupActive]: props.isPopupActive
|
||||||
})}>
|
})}>
|
||||||
@ -82,19 +100,6 @@ class RootPage extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RootPage.displayName = 'RootPage';
|
|
||||||
RootPage.propTypes = {
|
|
||||||
location: PropTypes.shape({
|
|
||||||
pathname: PropTypes.string
|
|
||||||
}).isRequired,
|
|
||||||
user: PropTypes.shape({
|
|
||||||
isGuest: PropTypes.boolean
|
|
||||||
}),
|
|
||||||
children: PropTypes.element,
|
|
||||||
onLogoClick: PropTypes.func.isRequired,
|
|
||||||
isPopupActive: PropTypes.bool.isRequired
|
|
||||||
};
|
|
||||||
|
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { resetAuth } from 'components/auth/actions';
|
import { resetAuth } from 'components/auth/actions';
|
||||||
import { withRouter } from 'react-router';
|
import { withRouter } from 'react-router';
|
||||||
|
Loading…
Reference in New Issue
Block a user