import React from 'react';
import { Switch } from 'react-router-dom';

import Sidebar from './shared/Sidebar';
import Main from './shared/Main';
import Dashboard from './shared/Dashboard';

import EntryList from './entry/List';
import EntryForm from './entry/Form';
import TagsList from './tags/List';
import TagsForm from './tags/Form';
import GeneralSettings from './settings/General';
import ThemeSettings from './settings/Theme';
import TeamSettings from './settings/Team';
import Profile from './user/Profile';
import Error404 from './errors/404';

import PrivateRoute from '../shared/PrivateRoute';
import { connect } from 'react-redux';

class Admin extends React.Component {

  render() {
    return (
      <React.Fragment>
        <Sidebar/>
        <Main>
          <Switch>
            <PrivateRoute path="/" exact component={Dashboard} />
            <PrivateRoute path="/settings/general" exact component={GeneralSettings} />
            <PrivateRoute path="/settings/theme" exact component={ThemeSettings} />
            <PrivateRoute path="/settings/team" exact component={TeamSettings} />

            <PrivateRoute path="/entries/:type" exact component={EntryList} />
            <PrivateRoute path="/entries/:type/new" exact component={EntryForm} />
            <PrivateRoute path="/entries/:type/:id" exact component={EntryForm} />

            <PrivateRoute path="/tags" exact component={TagsList} />
            <PrivateRoute path="/tags/new" exact component={TagsForm} />
            <PrivateRoute path="/tags/:id" exact component={TagsForm} />

            <PrivateRoute path="/profile" exact component={Profile} />

            <PrivateRoute component={Error404} />
          </Switch>
        </Main>
      </React.Fragment>
    );
  }
}

export default connect(
  (state) => ({ auth: state.auth })
)(Admin)

