UPDATE
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
// React Imports
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useFarmHub } from '@/hooks/useFarmHub'
|
||||
|
||||
// MUI Imports
|
||||
import Grid from '@mui/material/Grid2'
|
||||
@@ -39,16 +40,25 @@ const CARD_COMPONENTS: Partial<Record<CardId, React.ComponentType<{ data?: Recor
|
||||
}
|
||||
|
||||
const WaterDataDashboardWrapper = () => {
|
||||
const { farmHub } = useFarmHub()
|
||||
const farmUuid = farmHub?.farm_uuid
|
||||
const [cardsData, setCardsData] = useState<Partial<Record<CardId, Record<string, unknown>>>>({})
|
||||
const [loading, setLoading] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
if (!farmUuid) {
|
||||
setCardsData({})
|
||||
setLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
setLoading(true)
|
||||
farmDashboardService
|
||||
.getAllCards()
|
||||
.getAllCards(farmUuid)
|
||||
.then(cards => setCardsData(cards ?? {}))
|
||||
.catch(() => setCardsData({}))
|
||||
.finally(() => setLoading(false))
|
||||
}, [])
|
||||
}, [farmUuid])
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user