/* global window, React */
// ============================================================
// Trip-action modals: Hold, Cancel, Split.
// All three follow the same anatomy:
// 1. Eyebrow + title + sub explaining what status moves where
// 2. Body — context-specific inputs (reason, dates, drop selectors)
// 3. Agent impact panel — what re-runs after you save
// 4. Foot — Cancel | confirm-CTA
// ============================================================
const { useState: useTAState } = React;
// ============================================================
// HoldModal — pauses dispatch; needs reason + when to revisit
// ============================================================
function HoldModal({ trip, onCancel, onConfirm }) {
const [reason, setReason] = useTAState('inventory');
const [until, setUntil] = useTAState('next-wave');
const [note, setNote] = useTAState('');
const reasons = [
{ v: 'inventory', label: 'Inventory pending', hint: 'WMS will release when stock arrives' },
{ v: 'customer', label: 'Customer request', hint: 'Receiver pushed delivery window' },
{ v: 'capacity', label: 'Awaiting capacity', hint: 'No eligible carrier this wave' },
{ v: 'other', label: 'Other', hint: 'Free-text reason required' },
];
const untilOptions = [
{ v: 'next-wave', label: 'Next wave', sub: '~1h' },
{ v: 'today', label: 'End of day', sub: 'this wave + 4 more' },
{ v: 'manual', label: 'Until manually released', sub: 'no auto re-plan' },
];
const canConfirm = reason !== 'other' || note.trim().length > 0;
return (
e.stopPropagation()}>
Hold trip · {trip.id}
{trip.route.from} → {trip.route.to}
Status moves {trip.status} → HELD.
Trip stays in the wave but is excluded from carrier tendering until released.
{reasons.map(r => (
))}
{untilOptions.map(o => (
))}
Agent will: drop {trip.id} from this wave's tender queue ·
re-route pool orders if they have alternatives ·
re-surface at {untilOptions.find(o => o.v === until)?.label.toLowerCase()}.
>
} />
Status moves {trip.status} → CANCELLED.
This will release {orderCount} order{orderCount === 1 ? '' : 's'} (${invoice.toLocaleString()} invoice value) and fire WMS/OMS reversal events.
↩Orders back to pool for next wave{orderCount} orders
$Invoice value affected${invoice.toLocaleString()}