"use client"; import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, Legend } from "recharts"; export interface TodaySample { recordedAt: string; localTime: string; isOpen: boolean; waitMinutes: number | null; fastLaneMinutes: number | null; } interface Props { samples: TodaySample[]; hasFastLane: boolean; } const TIME_FMT = new Intl.DateTimeFormat([], { hour: "2-digit", minute: "2-digit", hour12: false, }); export default function WaitTimeTodayChart({ samples, hasFastLane }: Props) { // Map samples: closed periods → null so Recharts breaks the line. // X-axis time is rendered in the viewer's local timezone (Intl with no // tz arg) so an Eastern-time user sees ET regardless of which park. const data = samples.map((s) => ({ time: TIME_FMT.format(new Date(s.recordedAt)), wait: s.isOpen ? s.waitMinutes : null, fl: s.isOpen ? s.fastLaneMinutes : null, })); // Show every Nth tick on the X axis so labels don't overlap. const tickInterval = Math.max(1, Math.floor(data.length / 8)); return (
{ if (value === null || value === undefined) return ["—", name]; return [`${value} min`, name]; }} /> {hasFastLane && ( )}
); }