import * as React from 'react';
import classNames from 'classnames/bind';
import Header from 'components/global/Header';
import Content from 'components/routes/Content';
import Paragraph from 'components/layouts/Paragraph';
import OtherLayout from 'components/layouts/OtherLayout';
import Resource from 'components/layouts/Resource';
import Account from 'components/layouts/Account';
import Forms from 'components/layouts/Forms';
import Blog from 'components/layouts/Blog';
import Message from 'components/layouts/Message';
import Event from 'components/layouts/Event';
import Settings from 'components/layouts/Settings';
import Lists from 'components/layouts//Lists';
import Shop from 'components/layouts/Shop';

import Stats from 'components/routes/Stats';
// import TextItem from 'components/items/TextItem';

import { Switch } from 'react-router';
import { Route, Redirect } from 'react-router-dom';
import { config } from 'config/general';
import styleIdentifiers from './logged.scss';
import Cms from '../Cms';

const styles = classNames.bind(styleIdentifiers);

export interface LoggedProps {
  session: {};
  location: {};
}

interface LoggedState {}

export default class Logged extends React.Component<LoggedProps, LoggedState> {
  render() {
    const { session, profileData } = this.props;

    if (!config.noLogin && (!session || !profileData)) return <Redirect to="/login" />;

    return (
      <div className={styles('Logged')}>
        <Header />
        <div className={styles('content')}>
          <Switch>
            {/* CMS part */}
            <Route path="/cms" component={Cms} />
            {/* Settings part */}
            <Route path="/settings" component={Settings} />
            {/* Shop part  */}
            <Route path="/shop" component={Shop} />
            {/* Event part */}
            <Route path="/event" component={Event} />
            {/* Message part */}
            <Route path="/message" component={Message} />
            {/* Blog part  */}
            <Route path="/blog" component={Blog} />
            {/* Forms part  */}
            <Route path="/forms" component={Forms} />
            {/* Resource part */}
            <Route path={`/${config.resourcePath}`} component={Resource} />
            {/* Paragraph part */}
            <Route path="/paragraph" component={Paragraph} />
            {/* Account part */}
            <Route path="/account" component={Account} />
            {/* CMS part */}
            <Route path={`/${config.contentPath}/:id`} component={Content} />
            <Route path={`/${config.contentPath}`} component={Content} />
            {/* Stats part */}
            <Route path="/stats" component={Stats} />
            {/* Other part */}
            <Route component={OtherLayout} />
          </Switch>
        </div>
      </div>
    );
  }
}
