import { cn } from '@/lib/utils' interface Props { testName: string timeLeft: number // seconds remaining; -1 = no limit (count-up mode) timeUsed: number // seconds elapsed (used when no limit) onSubmit: () => void } function formatTime(s: number): string { const h = Math.floor(s / 3600) const m = Math.floor((s % 3600) / 60) const sec = s % 60 if (h > 0) return `${String(h).padStart(2, '0')}:${String(m).padStart(2, '0')}:${String(sec).padStart(2, '0')}` return `${String(m).padStart(2, '0')}:${String(sec).padStart(2, '0')}` } export function TestSessionHeader({ testName, timeLeft, timeUsed, onSubmit }: Props) { const isUnlimited = timeLeft === -1 const displaySeconds = isUnlimited ? timeUsed : timeLeft const isUrgent = !isUnlimited && timeLeft < 300 // last 5 min return (
{testName} {isUnlimited ? : formatTime(displaySeconds)}
) }