import { memo, useMemo } from 'react'
import {
  FolderOutlined,
  FundViewOutlined,
  FilePdfOutlined,
  ExperimentOutlined,
  DeploymentUnitOutlined,
} from '@ant-design/icons'
import { Layout } from 'antd'
import { Switch, useParams } from 'react-router-dom'

import { PrivateRoute, PrivateDefaultRoute, PrivateMenu } from '@components/Private'

import Report from './Report'
import Measure from './Measure'
import Analytics from './Analytics'
import Documents from './Documents'
import Telemetry from './Telemetry'
import WellOperations from './WellOperations'
import DrillingProgram from './DrillingProgram'
import TelemetryAnalysis from './TelemetryAnalysis'

import '@styles/index.css'

const { Content } = Layout

export const Well = memo(() => {
  const { idWell, tab } = useParams()
  const rootPath = useMemo(() => `/well/${idWell}`, [idWell])

  return (
    <Layout>
      <PrivateMenu root={rootPath} mode={'horizontal'} selectable={true} selectedKeys={[tab]} className={'well_menu'}>
        <PrivateMenu.Link key={'telemetry'} icon={<FundViewOutlined />} title={'Телеметрия'}/>
        <PrivateMenu.Link key={'report'} icon={<FilePdfOutlined />} title={'Рапорт'} />
        <PrivateMenu.Link key={'analytics'} icon={<DeploymentUnitOutlined />} title={'Аналитика'} />
        <PrivateMenu.Link key={'operations'} icon={<FolderOutlined />} title={'Операции по скважине'} />
        {/* <PrivateMenu.Link key={'telemetryAnalysis'} icon={<FundProjectionScreenOutlined />} title={'Операции по телеметрии'} /> */}
        <PrivateMenu.Link key={'document'} icon={<FolderOutlined />} title={'Документы'} />
        <PrivateMenu.Link key={'measure'} icon={<ExperimentOutlined />} title={'Измерения'} />
        <PrivateMenu.Link key={'drillingProgram'} icon={<FolderOutlined />} title={'Программа бурения'} />
      </PrivateMenu>

      <Layout>
        <Content className={'site-layout-background'}>
          <Switch>
            <PrivateRoute path={`${rootPath}/telemetry/:tab?`}>
              <Telemetry idWell={idWell} />
            </PrivateRoute>
            <PrivateRoute path={`${rootPath}/report`}>
              <Report idWell={idWell} />
            </PrivateRoute>
            <PrivateRoute path={`${rootPath}/analytics/:tab?`}>
              <Analytics idWell={idWell} rootPath={`${rootPath}/analytics`}/>
            </PrivateRoute>
            <PrivateRoute path={`${rootPath}/operations/:tab?`}>
              <WellOperations idWell={idWell} />
            </PrivateRoute>
            <PrivateRoute path={`${rootPath}/telemetryAnalysis/:tab?`}>
              <TelemetryAnalysis idWell={idWell} />
            </PrivateRoute>
            <PrivateRoute path={`${rootPath}/document/:category?`}>
              <Documents idWell={idWell} />
            </PrivateRoute>
            <PrivateRoute path={`${rootPath}/measure`}>
              <Measure idWell={idWell}/>
            </PrivateRoute>
            <PrivateRoute path={`${rootPath}/drillingProgram`}>
              <DrillingProgram idWell={idWell}/>
            </PrivateRoute>
            <PrivateDefaultRoute urls={[
              `${rootPath}/telemetry`,
              `${rootPath}/report`,
              `${rootPath}/analytics`,
              `${rootPath}/operations`,
              `${rootPath}/telemetryAnalysis`,
              `${rootPath}/document`,
              `${rootPath}/measure`,
              `${rootPath}/drillingProgram`,
            ]}/>
          </Switch>
        </Content>
      </Layout>
    </Layout>
  )
})

export default Well
