2022-03-18 19:40:52 +05:00
|
|
|
|
import { useState, useEffect, memo } from 'react'
|
2022-01-24 17:32:45 +05:00
|
|
|
|
import { useParams } from 'react-router-dom'
|
2021-08-27 14:21:48 +05:00
|
|
|
|
|
2022-01-24 17:32:45 +05:00
|
|
|
|
import { arrayOrDefault } from '@utils'
|
|
|
|
|
import { OperationStatService } from '@api'
|
|
|
|
|
import LoaderPortal from '@components/LoaderPortal'
|
|
|
|
|
import { invokeWebApiWrapperAsync } from '@components/factory'
|
|
|
|
|
|
|
|
|
|
import ClusterWells from './ClusterWells'
|
2021-08-30 11:26:00 +05:00
|
|
|
|
|
2022-03-18 19:40:52 +05:00
|
|
|
|
export const Cluster = memo(() => {
|
2022-01-24 17:32:45 +05:00
|
|
|
|
const { idCluster } = useParams()
|
2021-10-27 11:05:50 +05:00
|
|
|
|
const [data, setData] = useState([])
|
|
|
|
|
const [showLoader, setShowLoader] = useState(false)
|
2021-08-27 14:21:48 +05:00
|
|
|
|
|
2021-10-13 16:32:01 +05:00
|
|
|
|
useEffect(() => invokeWebApiWrapperAsync(
|
|
|
|
|
async () => {
|
2022-01-24 17:32:45 +05:00
|
|
|
|
const clusterData = await OperationStatService.getStatCluster(idCluster)
|
|
|
|
|
setData(arrayOrDefault(clusterData?.statsWells))
|
2021-10-13 16:32:01 +05:00
|
|
|
|
},
|
|
|
|
|
setShowLoader,
|
2022-02-07 17:44:46 +05:00
|
|
|
|
`Не удалось загрузить данные по кусту "${idCluster}"`,
|
|
|
|
|
'Получение данных по кусту'
|
2022-01-24 17:32:45 +05:00
|
|
|
|
), [idCluster])
|
2021-08-27 14:21:48 +05:00
|
|
|
|
|
2021-10-13 16:32:01 +05:00
|
|
|
|
return (
|
|
|
|
|
<LoaderPortal show={showLoader}>
|
|
|
|
|
<ClusterWells statsWells={data} />
|
|
|
|
|
</LoaderPortal>
|
|
|
|
|
)
|
2022-03-18 19:40:52 +05:00
|
|
|
|
})
|
2021-10-27 11:05:50 +05:00
|
|
|
|
|
|
|
|
|
export default Cluster
|