import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import { Skeleton } from "@/components/ui/skeleton"; import { Card } from "@/components/ui/card"; import { formatDistanceToNow, format } from "date-fns"; import { Clock, Calendar, Radio } from "lucide-react"; interface ControllerProfileProps { sessions: any[]; loading: boolean; } export function ControllerProfile({ sessions, loading }: ControllerProfileProps) { if (loading) { return ; } const totalTime = sessions.reduce((acc, session) => { const duration = new Date(session.last_seen).getTime() - new Date(session.logon_time).getTime(); return acc + duration; }, 0); const totalHours = Math.floor(totalTime / (1000 * 60 * 60)); const totalMinutes = Math.floor((totalTime % (1000 * 60 * 60)) / (1000 * 60)); // Get unique positions const positions = [...new Set(sessions.map(s => s.facility_type))]; return (

Total Time

{totalHours}h {totalMinutes}m

Total Sessions

{sessions.length}

Positions

{positions.map(position => ( {position} ))}

Session History

Date Callsign Position Airport Frequency Duration {sessions.map((session) => ( {format(new Date(session.logon_time), "MMM d, yyyy")} {session.callsign} {session.facility_type} {session.airport} {session.frequency} {formatSessionDuration(session.logon_time, session.last_seen)} ))}
); } function formatSessionDuration(start: string, end: string) { const duration = new Date(end).getTime() - new Date(start).getTime(); const hours = Math.floor(duration / (1000 * 60 * 60)); const minutes = Math.floor((duration % (1000 * 60 * 60)) / (1000 * 60)); return `${hours}h ${minutes}m`; } function LoadingSkeleton() { return (
{Array.from({ length: 5 }).map((_, i) => (
))}
); }