import React from 'react'; import { connect } from 'react-redux'; import { resetAuth } from 'app/components/auth/actions'; import { withRouter } from 'react-router-dom'; import { FormattedMessage as Message } from 'react-intl'; import { Route, Link, Switch } from 'react-router-dom'; import { Helmet } from 'react-helmet-async'; import clsx from 'clsx'; import { ScrollIntoView } from 'app/components/ui/scroll'; import PrivateRoute from 'app/containers/PrivateRoute'; import AuthFlowRoute from 'app/containers/AuthFlowRoute'; import Userbar from 'app/components/userbar/Userbar'; import PopupStack from 'app/components/ui/popup/PopupStack'; import * as loader from 'app/services/loader'; import { getActiveAccount } from 'app/components/accounts/reducer'; import { User } from 'app/components/user'; import { Account } from 'app/components/accounts/reducer'; import { RootState } from 'app/reducers'; import { ComponentLoader } from 'app/components/ui/loader'; import styles from './root.scss'; import siteName from './siteName.intl'; const ProfilePage = React.lazy(() => import(/* webpackChunkName: "page-profile-all" */ 'app/pages/profile/ProfilePage'), ); const PageNotFound = React.lazy(() => import(/* webpackChunkName: "page-not-found" */ 'app/pages/404/PageNotFound')); const RulesPage = React.lazy(() => import(/* webpackChunkName: "page-rules" */ 'app/pages/rules/RulesPage')); const DevPage = React.lazy(() => import(/* webpackChunkName: "page-dev-applications" */ 'app/pages/dev/DevPage')); const AuthPage = React.lazy(() => import(/* webpackChunkName: "page-auth" */ 'app/pages/auth/AuthPage')); class RootPage extends React.PureComponent<{ account: Account | null; user: User; isPopupActive: boolean; onLogoClick: (event: React.MouseEvent) => void; location: { pathname: string; }; }> { componentDidMount() { this.onPageUpdate(); } componentDidUpdate() { this.onPageUpdate(); } onPageUpdate() { loader.hide(); } render() { const { props } = this; const { user, account, isPopupActive, onLogoClick } = this.props; const isRegisterPage = props.location.pathname === '/register'; if (document && document.body) { document.body.style.overflow = isPopupActive ? 'hidden' : ''; } return (
}>
); } } export default withRouter( connect( (state: RootState) => ({ user: state.user, account: getActiveAccount(state), isPopupActive: state.popup.popups.length > 0, }), { onLogoClick: resetAuth, }, )(RootPage), );