import React from "react"; import { Usage } from "../types"; interface UsageDetailModalProps { usage: Usage; durationMs: number | null; onClose: () => void; } function UsageDetailModal({ usage, durationMs, onClose }: UsageDetailModalProps) { // Format duration in human-readable format const formatDuration = (ms: number): string => { if (ms < 1000) return `${ms}ms`; if (ms < 60000) return `${(ms / 1000).toFixed(2)}s`; return `${(ms / 60000).toFixed(2)}m`; }; // Format timestamp for display const formatTimestamp = (isoString: string): string => { const date = new Date(isoString); return date.toLocaleString(undefined, { year: "numeric", month: "short", day: "numeric", hour: "2-digit", minute: "2-digit", second: "2-digit", }); }; // Close on escape key React.useEffect(() => { const handleEscape = (e: KeyboardEvent) => { if (e.key === "Escape") { onClose(); } }; document.addEventListener("keydown", handleEscape); return () => document.removeEventListener("keydown", handleEscape); }, [onClose]); return (