From 78f9f1ee34366b54699627981e90ad83ea84d21d Mon Sep 17 00:00:00 2001 From: lyc8503 Date: Wed, 5 Nov 2025 01:22:10 +0800 Subject: [PATCH] fix: page crash when wrong id configured --- components/MaintenanceAlert.tsx | 4 ++-- components/OverallStatus.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/MaintenanceAlert.tsx b/components/MaintenanceAlert.tsx index 30f1bdf..8d76fd9 100644 --- a/components/MaintenanceAlert.tsx +++ b/components/MaintenanceAlert.tsx @@ -9,7 +9,7 @@ export default function MaintenanceAlert({ style, upcoming = false, }: { - maintenance: Omit & { monitors?: MonitorTarget[] } + maintenance: Omit & { monitors?: (MonitorTarget | undefined)[] } style?: React.CSSProperties upcoming?: boolean }) { @@ -81,7 +81,7 @@ export default function MaintenanceAlert({ {maintenance.monitors.map((comp, compIdx) => ( - {comp.name} + {comp?.name ?? '[ERR: MONITOR ID NOT FOUND]'} ))} diff --git a/components/OverallStatus.tsx b/components/OverallStatus.tsx index f9941ac..5212291 100644 --- a/components/OverallStatus.tsx +++ b/components/OverallStatus.tsx @@ -72,7 +72,7 @@ export default function OverallStatus({ })) const upcomingMaintenances: (Omit & { - monitors?: MonitorTarget[] + monitors?: (MonitorTarget | undefined)[] })[] = maintenances .filter((m) => now < new Date(m.start)) .map((maintenance) => ({