From f25fa7de83b3e82ff832f94011ff42dc34cb58a3 Mon Sep 17 00:00:00 2001 From: Tola Leng Date: Sun, 15 Jun 2025 21:27:33 +0800 Subject: [PATCH] Fix: Syntax errors in public status page --- .../public/ComponentsStatusSection.tsx | 201 ++++++++++++------ 1 file changed, 135 insertions(+), 66 deletions(-) diff --git a/application/src/components/public/ComponentsStatusSection.tsx b/application/src/components/public/ComponentsStatusSection.tsx index 611a946..0c063c6 100644 --- a/application/src/components/public/ComponentsStatusSection.tsx +++ b/application/src/components/public/ComponentsStatusSection.tsx @@ -1,10 +1,11 @@ import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; -import { Server } from 'lucide-react'; +import { Server, CheckCircle, XCircle, AlertTriangle, Pause, Clock } from 'lucide-react'; import { StatusPageComponentRecord } from '@/types/statusPageComponents.types'; import { Service, UptimeData } from '@/types/service.types'; import { UptimeHistoryRenderer } from './UptimeHistoryRenderer'; +import { format } from 'date-fns'; interface ComponentsStatusSectionProps { components: StatusPageComponentRecord[]; @@ -30,41 +31,106 @@ export const ComponentsStatusSection = ({ components, services, uptimeData }: Co return Math.round((upCount / history.length) * 100 * 100) / 100; }; + const getStatusIcon = (status: string) => { + switch (status) { + case 'up': + return ; + case 'down': + return ; + case 'warning': + return ; + case 'paused': + return ; + default: + return ; + } + }; + + const getStatusBadge = (status: string) => { + switch (status) { + case 'up': + return ( + + + Operational + + ); + case 'down': + return ( + + + Down + + ); + case 'warning': + return ( + + + Degraded + + ); + case 'paused': + return ( + + + Maintenance + + ); + default: + return ( + + Unknown + + ); + } + }; + + const getStatusDotColor = (status: string) => { + switch (status) { + case 'up': + return 'bg-green-500'; + case 'down': + return 'bg-red-500'; + case 'warning': + return 'bg-yellow-500'; + default: + return 'bg-gray-500'; + } + }; + if (components.length === 0) { return ( - Services + + + System Components +
-
-
-

Core Services

-

All core functionality

+ {[ + { name: 'API Services', description: 'Core API endpoints and services', status: 'up' }, + { name: 'Database', description: 'Primary database systems', status: 'up' }, + { name: 'Authentication', description: 'User authentication services', status: 'up' }, + { name: 'File Storage', description: 'Media and file hosting', status: 'up' } + ].map((component, index) => ( +
+
+ {getStatusIcon(component.status)} +
+

{component.name}

+

{component.description}

+
+ 99.9% uptime + + 100ms response +
+
+
+ {getStatusBadge(component.status)}
- - Operational - -
-
-
-

API Services

-

REST and GraphQL APIs

-
- - Operational - -
-
-
-

Database

-

Data storage and retrieval

-
- - Operational - -
+ ))}
@@ -74,10 +140,16 @@ export const ComponentsStatusSection = ({ components, services, uptimeData }: Co return ( - Components + + + System Components + +

+ Real-time status of all monitored components +

-
+
{components .sort((a, b) => a.display_order - b.display_order) .map((component) => { @@ -86,50 +158,47 @@ export const ComponentsStatusSection = ({ components, services, uptimeData }: Co const uptime = service?.id ? getUptimePercentage(component.service_id) : 100; return ( -
-
-
- -
-

{component.name}

+
+
+
+ {getStatusIcon(status)} +
+
+

{component.name}

+ {service?.responseTime && service.responseTime > 0 && ( +
+ + {service.responseTime}ms +
+ )} +
{component.description && ( -

{component.description}

+

{component.description}

)} - {service && ( -
- Uptime: {uptime}% - {service.responseTime > 0 && ( - - Response: {service.responseTime}ms - - )} +
+
+
+ {uptime}% uptime (90 days)
- )} + {service?.lastChecked && ( + Last checked: {format(new Date(service.lastChecked), 'HH:mm:ss')} + )} +
- - {status === 'up' ? 'Operational' : - status === 'down' ? 'Down' : - status === 'paused' ? 'Paused' : 'Warning'} - +
+ {getStatusBadge(status)} +
- {/* Individual component uptime history */} {component.service_id && ( - +
+
90-day uptime history
+ +
)}
);