router-dashboard/frontend/src/utils/statusHelpers.ts

30 lines
859 B
TypeScript

// src/utils/statusHelpers.ts
// Define all possible status values
export type StatusType =
| 'RUNNING'
| 'STOPPED'
| 'WARNING'
| 'CONNECTED'
| 'DISCONNECTED'
| 'ERROR'
| 'UNKNOWN';
export const STATUS_COLORS: Record<StatusType | string, string> = {
'RUNNING': 'bg-green-100 text-green-700',
'CONNECTED': 'bg-green-100 text-green-700',
'STOPPED': 'bg-red-100 text-red-700',
'DISCONNECTED': 'bg-red-100 text-red-700',
'WARNING': 'bg-yellow-100 text-yellow-700',
'ERROR': 'bg-red-100 text-red-700',
'UNKNOWN': 'bg-gray-100 text-gray-700'
};
export const formatStatus = (status: string): string => {
return status.charAt(0).toUpperCase() + status.slice(1).toLowerCase();
};
// Add this helper function
export const getStatusColor = (status: string): string => {
return STATUS_COLORS[status] || STATUS_COLORS['UNKNOWN'];
};