import { useActiveTradeEvents } from '../crm/hooks'; import { useEventCountdown, type EventCountdown } from '../hooks/useEventCountdown'; import type { TradeEvent } from '../crm/types'; import styles from './EventCountdownTiles.module.css'; // ============================================================ // Helpers // ============================================================ function formatDateRange(start: string, end: string): string { const s = new Date(start).toLocaleDateString('de-DE', { day: '2-digit', month: '2-digit', year: 'numeric', }); const e = new Date(end).toLocaleDateString('de-DE', { day: '2-digit', month: '2-digit', year: 'numeric', }); return `${s} โ ${e}`; } /** Hide events that ended more than 24h ago */ function isStillRelevant(event: TradeEvent): boolean { const endDay = new Date(event.endDate); endDay.setHours(23, 59, 59, 999); const cutoff = new Date(endDay.getTime() + 24 * 60 * 60 * 1000); return new Date() < cutoff; } // ============================================================ // Single Tile // ============================================================ function CountdownTile({ event }: { event: TradeEvent }) { const countdown: EventCountdown = useEventCountdown(event); const borderColor = countdown.status === 'upcoming' ? '#3b82f6' : countdown.status === 'ongoing' ? '#22c55e' : '#9ca3af'; return (