diff --git a/frontend/src/components/dashboard/PulseSensorCard.tsx b/frontend/src/components/dashboard/PulseSensorCard.tsx index 4a9ab1e..d4a9b04 100644 --- a/frontend/src/components/dashboard/PulseSensorCard.tsx +++ b/frontend/src/components/dashboard/PulseSensorCard.tsx @@ -24,6 +24,12 @@ interface PulseSensorCardProps { export function PulseSensorCard({ reading, history, onClick }: PulseSensorCardProps) { const navigate = useNavigate(); + // Determine offline status (older than 15 mins) + const now = new Date(); + const readingTime = new Date(reading.timestamp); + const diffMinutes = (now.getTime() - readingTime.getTime()) / 1000 / 60; + const isOffline = diffMinutes > 15; + // Determine status color based on VPD (gold standard for crop health) const getStatusColor = (vpd: number) => { if (vpd < 0.8 || vpd > 1.2) return 'text-amber-500'; // Warning @@ -31,7 +37,11 @@ export function PulseSensorCard({ reading, history, onClick }: PulseSensorCardPr return 'text-emerald-500'; // Good }; - const statusColor = getStatusColor(reading.vpd); + // If offline, use neutral/error color for metrics + const statusColor = isOffline ? 'text-slate-400 dark:text-slate-500' : getStatusColor(reading.vpd); + const badgeColor = isOffline + ? 'text-rose-500 bg-rose-500/10 border-rose-500/20' + : cn("bg-slate-100 dark:bg-slate-800 border border-slate-200 dark:border-slate-700", statusColor); // Simple Sparkline const Sparkline = ({ data, color = "#10b981", width = 120, height = 40 }: { data: number[], color?: string, width?: number, height?: number }) => { @@ -74,7 +84,12 @@ export function PulseSensorCard({ reading, history, onClick }: PulseSensorCardPr >
+
{reading.temperature.toFixed(1)}°
+
{reading.humidity.toFixed(0)}%
@@ -116,17 +131,26 @@ export function PulseSensorCard({ reading, history, onClick }: PulseSensorCardPr+
{reading.vpd.toFixed(2)}
-Last Updated
++ {readingTime.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })} +
+