import { Anchor, Badge, Button, Group, Paper, Stack, Tabs, Text, } from "@mantine/core"; import { Link } from "react-router-dom"; import { ArrowRight, Building2, FileText, Landmark, MapPin, Package, Train, } from "lucide-react"; import type { EligibleContainerBooking, FreightType } from "@/types/trainScheduling"; import { EligibleBookingsPanel } from "./EligibleBookingsPanel"; export type AssignedBookingRow = { id: string; reference: string; /** Who booked it — staff scan this list by customer, not by reference. */ customer?: string | null; weightTons?: number; isGovernment?: boolean; wagonsRequired?: number | null; contractReference?: string | null; origin?: string | null; destination?: string | null; }; export function ScheduleBookingsStep({ assignedBookings, eligibleItems, eligibleLoading, selectedIds, onSelectionChange, assignedIds, freightType, canRemove, onRemove, onSwitch, }: { assignedBookings: AssignedBookingRow[]; eligibleItems: EligibleContainerBooking[]; eligibleLoading?: boolean; selectedIds: string[]; onSelectionChange: (ids: string[]) => void; assignedIds?: string[]; freightType?: FreightType; canRemove?: boolean; onRemove?: (bookingId: string) => void; onSwitch?: (booking: EligibleContainerBooking) => void; }) { return ( } rightSection={ assignedBookings.length ? ( {assignedBookings.length} ) : undefined } > On this train }> Add bookings {assignedBookings.length ? ( {assignedBookings.map((booking) => ( {/* Only the reference is the link — the row also carries a Remove button, so an interactive control must not nest inside the anchor. */} {booking.reference} {booking.weightTons != null ? ( {booking.weightTons}T ) : null} {booking.wagonsRequired != null ? ( } > {booking.wagonsRequired} wagon{booking.wagonsRequired === 1 ? "" : "s"} ) : null} {booking.isGovernment ? ( } > Government ) : null} {booking.customer ? ( {booking.customer} ) : null} {booking.contractReference || booking.origin || booking.destination ? ( {booking.contractReference ? ( {booking.contractReference} ) : null} {booking.origin || booking.destination ? ( {booking.origin ?? "?"} → {booking.destination ?? "?"} ) : null} ) : null} Assigned to this consist Ready for wagon plan {canRemove && onRemove ? ( ) : null} ))} ) : ( No bookings on this train yet. Use the Add bookings tab to select eligible cargo. )} ); }