+ Unable to load dashboard summary. Please refresh and try again.
+
+ );
+ }
+
+ const {
+ department_scope,
+ effective_today,
+ kpis,
+ complaints_by_status,
+ complaints_by_department,
+ monthly_downtime_trend,
+ pm_planned_vs_completed,
+ needs_attention,
+ recent_complaints,
+ } = data;
+
+ const kpiCards = [
+ {
+ label: "Total Assets",
+ value: kpis.total_assets,
+ to: "/assets",
+ icon: Package,
+ tone: "text-[#1e3a8a] bg-blue-50 border-blue-200",
+ },
+ {
+ label: "Under Repair",
+ value: kpis.assets_under_repair,
+ to: "/assets?status=under_repair",
+ icon: Wrench,
+ tone: "text-amber-800 bg-amber-50 border-amber-200",
+ },
+ {
+ label: "Open Complaints",
+ value: kpis.open_complaints,
+ to: "/complaints",
+ icon: AlertCircle,
+ tone: "text-red-800 bg-red-50 border-red-200",
+ },
+ {
+ label: "PM Due This Month",
+ value: kpis.pm_due_this_month,
+ to: "/pm",
+ icon: CalendarCheck,
+ tone: "text-indigo-800 bg-indigo-50 border-indigo-200",
+ },
+ {
+ label: "Calibrations Due",
+ value: kpis.calibrations_due,
+ to: "/calibration",
+ icon: Gauge,
+ tone: "text-orange-800 bg-orange-50 border-orange-200",
+ },
+ {
+ label: "Contracts Expiring",
+ value: kpis.contracts_expiring,
+ to: "/contracts",
+ icon: FileText,
+ tone: "text-purple-800 bg-purple-50 border-purple-200",
+ },
+ {
+ label: "Equipment on Demo",
+ value: kpis.equipment_on_demo,
+ to: "/demo-equipment",
+ icon: Truck,
+ tone: "text-teal-800 bg-teal-50 border-teal-200",
+ },
+ ];
+
+ const statusChartData = complaints_by_status.map((item) => ({
+ name: STATUS_COLORS[item.status]?.label ?? item.status,
+ value: item.count,
+ color: STATUS_COLORS[item.status]?.color ?? "#6b7280",
+ }));
+
+ return (
+
+ {/* Header */}
+
+
+
Hospital Operations Dashboard
+
+ Live equipment health, breakdown downtime, PM compliance, and expiry alerts as of{" "}
+ {formatDate(effective_today)}
+
+
+ {department_scope && (
+
+
+ Viewing department scope: {department_scope}
+
+ )}
+
+
+ {/* 7 KPI Cards */}
+
+ {kpiCards.map((card) => {
+ const Icon = card.icon;
+ return (
+
+
+ {card.label}
+
+
+
{card.value}
+
+ );
+ })}
+
+
+ {/* 4 Charts Grid */}
+
+ {/* Chart 1: Complaints by Status */}
+
+
+ Complaints by Status
+
+
+
+
+
+ {statusChartData.map((entry, idx) => (
+ |
+ ))}
+
+
+
+
+
+
+
+
+ {/* Chart 2: Complaints by Department */}
+
+
+ Complaints by Department
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {/* Chart 3: Monthly Downtime Trend */}
+
+
+ Monthly Downtime Trend (Hours)
+
+
+
+
+ {/* Chart 4: PM Planned vs Completed */}
+
+
+ PM Planned vs Completed (Last 6 Months)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {/* Bottom Panels: Needs Attention & Recent Complaints */}
+
+ {/* Needs Attention */}
+
+
+
+
+ Needs Attention
+
+
+ View all →
+
+
+
+ {needs_attention.length === 0 ? (
+
+ No urgent red-severity alerts right now.
+
+ ) : (
+
+ {needs_attention.map((item) => (
+
+
+
+ {item.title}
+
+
+ {item.message}
+
+ {item.due_date && (
+
+ Due: {formatDate(item.due_date)}
+
+ )}
+
+
+
+ ))}
+
+ )}
+
+
+ {/* Recent Complaints */}
+
+
+
+ Recent Complaints
+
+
+ All complaints →
+
+
+
+ {recent_complaints.length === 0 ? (
+
+ No complaints recorded yet.
+
+ ) : (
+
+
+
+
+ |
+ Complaint
+ |
+
+ Asset
+ |
+
+ Status
+ |
+
+ Priority
+ |
+
+ Downtime
+ |
+
+
+
+ {recent_complaints.map((c) => (
+
+ |
+
+ {c.complaint_no}
+
+ |
+
+
+ {c.asset_code}
+
+
+ {c.asset_name}
+
+ |
+
+
+ |
+
+
+ |
+
+
+ {formatDuration(c.downtime_minutes)}
+ {c.downtime_is_ongoing && (
+
+ Ongoing
+
+ )}
+
+ |
+
+ ))}
+
+
+
+ )}
+
+
+
+ );
+}
diff --git a/frontend/src/pages/NotificationsPage.tsx b/frontend/src/pages/NotificationsPage.tsx
new file mode 100644
index 0000000..ac27088
--- /dev/null
+++ b/frontend/src/pages/NotificationsPage.tsx
@@ -0,0 +1,254 @@
+import { useState } from "react";
+import { useNavigate } from "react-router-dom";
+import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
+import {
+ Bell,
+ CheckCheck,
+ AlertTriangle,
+ Clock,
+ Info,
+ ExternalLink,
+ Check,
+} from "lucide-react";
+import {
+ notificationsApi,
+ type NotificationItem,
+ type NotificationType,
+} from "@/api/notifications";
+import { formatDate, formatDateTime } from "@/lib/format";
+import { Button } from "@/components/ui/button";
+import { Badge } from "@/components/ui/badge";
+import { toast } from "@/components/ToastProvider";
+
+const TYPE_OPTIONS: { value: NotificationType | ""; label: string }[] = [
+ { value: "", label: "All Types" },
+ { value: "amc_expiry", label: "AMC / CMC Expiry" },
+ { value: "calibration_due", label: "Calibration Due" },
+ { value: "pm_due", label: "PM Due" },
+ { value: "insurance_expiry", label: "Insurance Expiry" },
+ { value: "warranty_expiry", label: "Warranty Expiry" },
+ { value: "demo_overdue", label: "Demo Overdue" },
+ { value: "critical_complaint", label: "Critical Complaint" },
+];
+
+const TYPE_LABELS: Record