Files
edr-platform/apps/edr-freight-web/backoffice/src/utils/groupBookingsForOperationsQueue.ts
2026-06-23 13:14:06 +00:00

24 lines
729 B
TypeScript

import type { BookingListRow } from "@/types/booking";
import { compareSchedulingPriority } from "./compareSchedulingPriority";
import {
groupBookingsByThreeHourWindow,
type ThreeHourBookingBucket,
} from "./groupBookingsByThreeHourWindow";
export interface OperationsQueueGroups {
government: BookingListRow[];
commercial: ThreeHourBookingBucket<BookingListRow>[];
}
export function groupBookingsForOperationsQueue(
bookings: BookingListRow[],
): OperationsQueueGroups {
const government = bookings
.filter((b) => b.isGovernment)
.sort(compareSchedulingPriority);
const commercial = groupBookingsByThreeHourWindow(
bookings.filter((b) => !b.isGovernment),
);
return { government, commercial };
}