import { lazy, memo, Suspense, useCallback, useEffect, useMemo, useState } from 'react' import { Navigate, Route, Routes, useParams } from 'react-router-dom' import { WellContext, RootPathContext, useRootPath } from '@asb/context' import { LayoutPortal } from '@components/LayoutPortal' import SuspenseFallback from '@components/SuspenseFallback' import { invokeWebApiWrapperAsync } from '@components/factory' import { NoAccessComponent, wrapPrivateComponent } from '@utils' import { WellService } from '@api' import NavigationMenu 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 [well, setWell] = useState({ id: idWell }) const root = useRootPath() const rootPath = useMemo(() => `${root}/well/${idWell}`, [root, idWell]) useEffect(() => { invokeWebApiWrapperAsync( async () => { const well = await WellService.get(idWell) setWell(well ?? { id: idWell }) }, undefined, 'Не удалось получить данные по скважине' ) }, [idWell]) const updateWell = useCallback((data) => invokeWebApiWrapperAsync( async () => { const newWell = { ...well, ...data } await WellService.updateWell(newWell) setWell(newWell) }, undefined, `Не удалось изменить данные скважины`, { actionName: 'Изменение данных скважины', well } ), [well]) return ( }> }> } /> } /> }> } /> } /> } /> } /> } /> } /> } /> } /> }> } /> } /> } /> } /> }> } /> } /> } /> } /> }> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> ) }) export default wrapPrivateComponent(Well, { requirements: [], title: 'Скважина', route: 'well/:idWell/*', key: 'well', })