Enhance farm dashboard components by refactoring to accept data props, improving API integration for dynamic data rendering. Updated FarmDashboardWrapper to fetch and manage card data, ensuring components like EconomicOverview, AnomalyDetectionCard, and others utilize the new data structure. Removed hardcoded values and added error handling for better resilience.
This commit is contained in:
@@ -34,36 +34,13 @@ type AlertItem = {
|
||||
color: 'primary' | 'warning' | 'error' | 'info' | 'success'
|
||||
}
|
||||
|
||||
const alerts: AlertItem[] = [
|
||||
{
|
||||
title: 'Water Shortage Risk',
|
||||
description:
|
||||
'Soil moisture at 10cm depth (42%) is below optimal. AI predicts stress in 2-3 days if no irrigation. Recommended: irrigate within 24h.',
|
||||
time: '15 min ago',
|
||||
color: 'warning'
|
||||
},
|
||||
{
|
||||
title: 'Fungal Disease Risk',
|
||||
description:
|
||||
'High humidity (65%) + temp 24°C creates favorable conditions for fungal growth. Consider preventive fungicide or reduce irrigation.',
|
||||
time: '1 hour ago',
|
||||
color: 'error'
|
||||
},
|
||||
{
|
||||
title: 'Irrigation Suggestion',
|
||||
description: 'Optimal watering window: 6:00-8:00 AM. Suggested amount: 450 m³ for Zone A. Expected efficiency gain: 12%.',
|
||||
time: '2 hours ago',
|
||||
color: 'info'
|
||||
},
|
||||
{
|
||||
title: 'Soil Salinity Check',
|
||||
description: 'EC reading 1.2 dS/m is within range. No action needed. Next check recommended in 5 days.',
|
||||
time: '4 hours ago',
|
||||
color: 'success'
|
||||
}
|
||||
]
|
||||
interface FarmAlertsTimelineProps {
|
||||
data?: Record<string, unknown>
|
||||
}
|
||||
|
||||
const FarmAlertsTimeline = ({ data }: FarmAlertsTimelineProps) => {
|
||||
const alerts = (data?.alerts as AlertItem[] | undefined) ?? []
|
||||
|
||||
const FarmAlertsTimeline = () => {
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader
|
||||
|
||||
Reference in New Issue
Block a user