Files
pulse/lib/utils/notifications.tsx
Usman Baig 25210013d3 feat: centralise date/time formatting with European conventions
All dates now use day-first ordering (14 Mar 2025) and 24-hour time
(14:30) via a single formatDate.ts module, replacing scattered inline
toLocaleDateString/toLocaleTimeString calls across 12 files.
2026-03-14 13:31:30 +01:00

20 lines
748 B
TypeScript

import { AlertTriangleIcon, CheckCircleIcon } from '@ciphera-net/ui'
import { formatRelativeTime } from './formatDate'
/**
* Formats a date string as a human-readable relative time (e.g. "5m ago", "2h ago").
*/
export function formatTimeAgo(dateStr: string): string {
return formatRelativeTime(dateStr)
}
/**
* Returns the icon for a notification type (alert for down/degraded/billing, check for success).
*/
export function getTypeIcon(type: string) {
if (type.includes('down') || type.includes('degraded') || type.startsWith('billing_')) {
return <AlertTriangleIcon className="w-4 h-4 shrink-0 text-amber-500" aria-hidden="true" />
}
return <CheckCircleIcon className="w-4 h-4 shrink-0 text-emerald-500" aria-hidden="true" />
}