"use client"; import Link from "next/link"; import { EmptyState, Spinner } from "@/src/Components/UI"; import { ENTITY_KPI_CONFIG } from "@/src/types/dashboard"; import type { DashboardAlert } from "@/src/types/dashboard"; function fmtRelative(iso: string): string { const diffMs = Date.now() - new Date(iso).getTime(); const mins = Math.floor(diffMs / 60000); if (mins < 1) return "الآن"; if (mins < 60) return `منذ ${mins} د`; const hours = Math.floor(mins / 60); if (hours < 24) return `منذ ${hours} س`; return `منذ ${Math.floor(hours / 24)} يوم`; } function AlertListItem({ alert }: { alert: DashboardAlert }) { const entityCfg = ENTITY_KPI_CONFIG.find((e) => e.key === alert.entity); const isCritical = alert.severity === "critical"; return ( {alert.message} {entityCfg && ( {entityCfg.label} )} {fmtRelative(alert.createdAt)} ); } interface AlertsSectionProps { alerts: DashboardAlert[]; loading: boolean; } export function AlertsSection({ alerts, loading }: AlertsSectionProps) { return (

تنبيهات عاجلة

يحتاج انتباهك

{loading && }
{!loading && alerts.length === 0 && } {alerts.map((alert) => ( ))}
); }