import type { AuditLogRange } from '@admin/actions/audit/types' const AXIS_LABEL_COUNTS = { '24h': 5, '7d': 7, '30d': 6 } satisfies Record function formatAxisLabel(range: AuditLogRange, date: Date): string { if (range === '24h') { return new Intl.DateTimeFormat('en-US', { hour: 'numeric' }).format(date) } if (range === '7d') { return new Intl.DateTimeFormat('en-US', { weekday: 'short' }).format(date) } return new Intl.DateTimeFormat('en-US', { month: 'short', day: 'numeric' }).format(date) } export function getAuditActivityAxis(range: AuditLogRange, from: string, to: string): string[] { const start = new Date(from).getTime() const end = new Date(to).getTime() const count = AXIS_LABEL_COUNTS[range] const step = (end - start) / (count - 1) return Array.from({ length: count }, (_, index) => index === count - 1 ? range === '24h' ? 'Now' : 'Today' : formatAxisLabel(range, new Date(start + step * index)) ) }