import type { TguPlanDecision } from "../../model/tguTypes"; import type { TguPlanUi } from "../../model/timelineTypes"; import { platformLabel } from "./tguTimelineMapper"; import { statusStyle } from "./tguStatus"; type TguPlanDetailsProps = { plan?: TguPlanUi; decisionInFlight: boolean; notice?: string; error?: string; onDecision: (planId: string, decision: TguPlanDecision, reason?: string) => void; onClose: () => void; }; export function TguPlanDetails({ plan, decisionInFlight, notice, error, onDecision, onClose }: TguPlanDetailsProps) { if (!plan) { return ( ); } const style = statusStyle(plan.status); const duration = formatDuration(plan.endMs - plan.startMs); const reject = () => { const reason = window.prompt("Reason для REJECTED", "UI_TEST_REJECTED"); if (reason === null) return; onDecision(plan.planId, "REJECTED", reason); }; return ( ); } function Detail({ label, value, mono }: { label: string; value?: string; mono?: boolean }) { return (
{label}
{value || "-"}
); } function formatDateTime(value: string): string { return new Date(value).toLocaleString("ru-RU"); } function formatDuration(ms: number): string { const minutes = Math.max(0, Math.round(ms / 60_000)); const hours = Math.floor(minutes / 60); const restMinutes = minutes % 60; if (hours === 0) return `${restMinutes} мин`; return `${hours} ч ${restMinutes} мин`; }