import { Redirect, Route, Switch } from 'react-router-dom'
import { PrivateRoute } from '../components/Private'
import { AdminLayoutPortal, LayoutPortal } from '../components/Layout'
import Deposit from './Deposit'
import Cluster from './Cluster'
import Well from './Well'
import AdminPanel from './AdminPanel'

export const Main = () => (
    <Switch>
        <PrivateRoute path={'/admin/:tab?'} permission={'admin_panel'}>
            <AdminLayoutPortal title={'Администраторская панель'}>
                <AdminPanel />
            </AdminLayoutPortal>
        </PrivateRoute>
        <Route path={'/deposit'}>
            <LayoutPortal noSheet title='Месторождение'>
                <Deposit />
            </LayoutPortal>
        </Route>
        <Route path={'/cluster/:idClaster/:tab?'}>
            <LayoutPortal title={'Анализ скважин куста'}>
                <Cluster />
            </LayoutPortal>
        </Route>
        <Route path={'/well/:idWell/:tab?'}>
            <LayoutPortal>
                <Well />
            </LayoutPortal>
        </Route>
        <Route path={'/'}>
            <Redirect to={{ pathname: `/deposit` }} />
        </Route>
    </Switch>
)

export default Main
