import { useCallback, useRef } from "react"; import { useNavigate } from "react-router-dom"; import { ArrowRight, Calendar, Package, User } from "lucide-react"; import { Group } from "@mantine/core"; import { BookingActionsMenu } from "@/components/bookings/BookingActionsMenu"; import { BookingPriorityBadge } from "@/components/bookings/BookingPriorityBadge"; import { BookingStatusBadge } from "@/components/bookings/BookingStatusBadge"; import { SchedulingStatusBadge } from "@/components/trainScheduling/ScheduleStatusBadge"; import { bookingTable } from "@/components/bookings/booking-ui.styles"; import type { BookingListRow } from "@/types/booking"; import { cn } from "@/lib/utils"; import { Badge, DataTable, type ColumnDef } from "@edr/ui-common"; export function OperationsBookingQueue({ bookings, isLoading, onAllocate, }: { bookings: BookingListRow[]; isLoading?: boolean; onAllocate: (bookingIds: string[]) => void; }) { const navigate = useNavigate(); const suppressRowClickRef = useRef(false); const suppressRowClick = useCallback(() => { suppressRowClickRef.current = true; window.setTimeout(() => { suppressRowClickRef.current = false; }, 400); }, []); const handleRowClick = useCallback( (row: BookingListRow) => { if (suppressRowClickRef.current) return; navigate(`/dashboard/booking-requests/${row.id}`); }, [navigate], ); const columns: ColumnDef[] = [ { id: "booking", header: () => Booking, cell: ({ row }) => { const booking = row.original; return (

{booking.reference}

{booking.isGovernment ? ( Government ) : null}

{booking.customerLabel}

); }, }, { id: "route", header: () => Route, cell: ({ row }) => { const booking = row.original; return (
{booking.originLabel} {booking.destinationLabel}
{booking.tradeDirection} {booking.freightType}
); }, }, { id: "status", header: () => Status, cell: ({ row }) => (
{row.original.schedulingStatus ? ( ) : null}
), }, { id: "scheduled", header: () => Scheduled, cell: ({ row }) => ( {row.original.scheduledDate} ), }, { id: "priority", header: () => Priority, cell: ({ row }) => , }, { id: "amount", header: () => Amount, cell: ({ row }) => ( {row.original.paymentCurrency}{" "} {row.original.totalAmount.toLocaleString(undefined, { minimumFractionDigits: 2, })} ), }, { id: "actions", header: () => Actions, cell: ({ row }) => ( onAllocate([row.original.id])} /> ), }, ]; return ( ); }