asb_cloud_front/src/pages/Cluster/index.jsx

31 lines
981 B
React
Raw Normal View History

import { useParams } from "react-router-dom";
2021-08-27 14:21:48 +05:00
import { useState, useEffect } from "react";
import ClusterWells from "./ClusterWells";
import LoaderPortal from "../../components/LoaderPortal";
import { invokeWebApiWrapperAsync } from "../../components/factory";
import { WellOperationStatService } from "../../services/api";
2021-08-27 14:21:48 +05:00
export default function Cluster() {
let { idClaster } = useParams();
2021-08-27 14:21:48 +05:00
const [data, setData] = useState([]);
const [showLoader, setShowLoader] = useState(false);
useEffect(() => invokeWebApiWrapperAsync(
async () => {
const clusterData = await WellOperationStatService.getStatCluster(idClaster);
setData(clusterData?.statsWells ?? []);
},
setShowLoader,
`Не удалось загрузить данные по кусту "${idClaster}"`
), [idClaster]);
2021-08-27 14:21:48 +05:00
useEffect(() => console.log(data), [data])
2021-08-27 14:21:48 +05:00
return (
<LoaderPortal show={showLoader}>
<ClusterWells statsWells={data} />
</LoaderPortal>
)
2021-08-27 14:21:48 +05:00
}