import { lazy, memo, useCallback, useEffect, useMemo, useState } from 'react'
import { Navigate, Route, Routes, useLocation, useParams } from 'react-router-dom'
import { WellContext, RootPathContext, useRootPath, useLayoutProps, TopRightBlockContext } from '@asb/context'
import { invokeWebApiWrapperAsync } from '@components/factory'
import { MenuBreadcrumbItems } from '@components/MenuBreadcrumb'
import { NoAccessComponent, withPermissions } from '@utils'
import { WellService } from '@api'
import { NavigationMenu, menuItems } from './NavigationMenu'
import '@styles/index.css'
const Measure = lazy(() => import('./Measure'))
const Reports = lazy(() => import('./Reports'))
const WellCase = lazy(() => import('./WellCase'))
const Analytics = lazy(() => import('./Analytics'))
const Documents = lazy(() => import('./Documents'))
const Telemetry = lazy(() => import('./Telemetry'))
const WellOperations = lazy(() => import('./WellOperations'))
const DrillingProgram = lazy(() => import('./DrillingProgram'))
const Tvd = lazy(() => import('./WellOperations/Tvd'))
const WellDrillParams = lazy(() => import('./WellOperations/WellDrillParams'))
const DrillProcessFlow = lazy(() => import('./WellOperations/DrillProcessFlow'))
const WellSectionsStat = lazy(() => import('./WellOperations/WellSectionsStat'))
const WellOperationsEditorFact = lazy(() => import('./WellOperations/OperationEditor/Fact'))
const WellOperationsEditorPlan = lazy(() => import('./WellOperations/OperationEditor/Plan'))
const Archive = lazy(() => import('./Telemetry/Archive'))
const Messages = lazy(() => import('./Telemetry/Messages'))
const Operations = lazy(() => import('./Telemetry/Operations'))
const DashboardNNB = lazy(() => import('./Telemetry/DashboardNNB'))
const TelemetryView = lazy(() => import('./Telemetry/TelemetryView'))
const OperationTime = lazy(() => import('./Telemetry/OperationTime'))
const DailyReport = lazy(() => import('./Reports/DailyReport'))
const DiagramReport = lazy(() => import('./Reports/DiagramReport'))
const Statistics = lazy(() => import('./Analytics/Statistics'))
const WellCompositeEditor = lazy(() => import('./Analytics/WellCompositeEditor'))
const Well = memo(() => {
const { idWell } = useParams()
const location = useLocation()
const [well, setWell] = useState({ id: idWell })
const [topRightBlock, setTopRightBlock] = useState()
const root = useRootPath()
const rootPath = useMemo(() => `${root}/well/${idWell}`, [root, idWell])
const setLayoutProps = useLayoutProps()
const updateWell = useCallback((data) => invokeWebApiWrapperAsync(
async () => {
const newWell = { ...well, ...data }
await WellService.updateWell(newWell)
setWell(newWell)
},
undefined,
`Не удалось изменить данные скважины`,
{ actionName: 'Изменение данных скважины', well }
), [well])
useEffect(() => {
invokeWebApiWrapperAsync(
async () => {
const well = await WellService.get(idWell)
setWell(well ?? { id: idWell })
},
undefined,
'Не удалось получить данные по скважине'
)
}, [idWell])
useEffect(() => setLayoutProps({
sider: ,
breadcrumb: ,
topRightBlock: topRightBlock,
}), [well, setLayoutProps, topRightBlock])
useEffect(() => setTopRightBlock(undefined), [location])
return (
} />
} />
}>
} />
} />
} />
} />
} />
} />
} />
} />
}>
} />
} />
} />
} />
}>
} />
} />
} />
} />
}>
} />
} />
} />
} />
} />
} />
} />
} />
} />
} />
} />
} />
)
})
export default withPermissions(Well)