"use client"; import React from "react"; interface PredictionData { time: string; predictedLevel: number | null; currentLevel: number; status: string; currentStatus: string; risk: string; color: string; } interface PredictionTableProps { data: PredictionData[]; } export default function TabelPrediksi({ data }: PredictionTableProps) { if (data.length === 0) return null; const item = data[0]; const hasPrediction = item.predictedLevel !== null; const trendValue = hasPrediction ? item.predictedLevel! - item.currentLevel : null; return (
| Lokasi | Status Saat Ini | Elevasi Saat Ini | Prediksi Elevasi | Tren | Status Prediksi | Tingkat Risiko |
|---|---|---|---|---|---|---|
| Sungai Tegal Bal Karangrejo | {item.currentStatus.charAt(0).toUpperCase() + item.currentStatus.slice(1).toLowerCase()} | {item.currentLevel} cm | {hasPrediction ? `${item.predictedLevel} cm` : "-"} |
{hasPrediction && trendValue !== null ? (
) : (
-
)}
|
{!hasPrediction ? "Menunggu" : item.status.charAt(0).toUpperCase() + item.status.slice(1).toLowerCase()} | {!hasPrediction ? "-" : item.risk} |