Add loading spinner to ThingsHistory component

This commit is contained in:
Mo Tarbin 2025-02-02 10:47:47 -05:00
parent 568f86acd0
commit d56c7a3bb4

View file

@ -22,6 +22,7 @@ import {
YAxis, YAxis,
} from 'recharts' } from 'recharts'
import { GetThingHistory } from '../../utils/Fetcher' import { GetThingHistory } from '../../utils/Fetcher'
import LoadingComponent from '../components/Loading'
const ThingsHistory = () => { const ThingsHistory = () => {
const { id } = useParams() const { id } = useParams()
@ -75,6 +76,11 @@ const ThingsHistory = () => {
return `${timeValue} ${unit}${timeValue !== 1 ? 's' : ''}` return `${timeValue} ${unit}${timeValue !== 1 ? 's' : ''}`
} }
// if loading show loading spinner:
if (thingsHistory.length === 0) {
return <LoadingComponent />
}
if (errLoading || !thingsHistory || thingsHistory.length === 0) { if (errLoading || !thingsHistory || thingsHistory.length === 0) {
return ( return (
<Container <Container