import { ClockIcon, AlertTriangleIcon } from "lucide-react"; import { estimateRunDuration } from "@/lib/run-eta"; interface RunEtaPillProps { targetCount: number; fireAt: Date; /** Optional. When omitted (or when the operator picked "no * deadline"), the pill renders a neutral ETA without the * green/amber fit indicator. */ windowEndAt?: Date; timezone: string; } /** * Visible at the wizard's review step and on the per-section edit * pages that change ETA inputs (groups, when). Advisory only — does * NOT block submission. The operator can still schedule a run that's * likely to pause; pause-and-resume covers that case. The pill just * removes the surprise. */ export function RunEtaPill({ targetCount, fireAt, windowEndAt, timezone, }: RunEtaPillProps) { if (targetCount <= 0) return null; const { durationMinutes, estimatedFinishAt } = estimateRunDuration({ targetCount, fireAt, }); const finishLocal = new Intl.DateTimeFormat("en-GB", { hour: "numeric", minute: "2-digit", hour12: true, timeZone: timezone, }).format(estimatedFinishAt); // No deadline → neutral ETA, no green/amber comparison. if (!windowEndAt) { return (
~{durationMinutes} min · finishes ~{finishLocal}
); } const fits = estimatedFinishAt.getTime() <= windowEndAt.getTime(); if (fits) { return (
~{durationMinutes} min · finishes ~{finishLocal} · Fits before deadline
); } return (
~{durationMinutes} min · finishes ~{finishLocal} · Likely to pause
Push the deadline later or split into smaller runs.
); }