Use API status for loading

This commit is contained in:
“himanshu” 2021-01-19 06:01:57 +05:30
parent b7dea68ff5
commit 2a039150a8

View File

@ -1,4 +1,4 @@
import React, { useEffect } from "react"; import React, { useEffect, useState } from "react";
import { useLocation } from "react-router-dom"; import { useLocation } from "react-router-dom";
import { NavLink } from "react-router-dom"; import { NavLink } from "react-router-dom";
import { Spin, Table } from "antd"; import { Spin, Table } from "antd";
@ -80,16 +80,19 @@ const columns = [
const _ServicesTable = (props: ServicesTableProps) => { const _ServicesTable = (props: ServicesTableProps) => {
const search = useLocation().search; const search = useLocation().search;
const time_interval = new URLSearchParams(search).get("time"); const time_interval = new URLSearchParams(search).get("time");
const [dataFetched, setDataFetched] = useState(false)
useEffect(() => { useEffect(() => {
/* /*
@Note - Change this from action to thunk @Note - Change this from action to thunk
*/ */
props.getServicesList(props.globalTime); props.getServicesList(props.globalTime).then(()=>{
setDataFetched(true)
}).catch((e:string)=>{
alert(e)
});
}, [props.globalTime]); }, [props.globalTime]);
const isDataAvailable = props.servicesList.length > 1; if(!dataFetched){
if(!isDataAvailable){
return ( return (
<TableLoadingWrapper> <TableLoadingWrapper>
<Spin/> <Spin/>