asb_cloud_front/src/pages/Cluster/index.jsx

34 lines
1.0 KiB
React
Raw Normal View History

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