mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-07 21:15:41 +00:00
enhance train scheduling and booking management
This commit is contained in:
@@ -33,6 +33,7 @@ import {
|
||||
RefreshCw,
|
||||
Ruler,
|
||||
TrainFront,
|
||||
Trophy,
|
||||
Weight,
|
||||
XCircle,
|
||||
} from "lucide-react";
|
||||
@@ -55,6 +56,8 @@ import {
|
||||
WindowStatusPill,
|
||||
} from "@/components/trainScheduling/batchVisuals";
|
||||
import { RouteCorridor } from "@/components/trainScheduling/scheduleVisuals";
|
||||
import { PriorityTrackingTab } from "@/components/trainScheduling/PriorityTrackingTab";
|
||||
import { useBookingWindowSocket } from "@/features/bookingWindows/useBookingWindowSocket";
|
||||
import { BookingsManager } from "./BookingsManager";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { api } from "@/services/api";
|
||||
@@ -578,9 +581,23 @@ export default function BatchScheduleDetailPage() {
|
||||
api.trainScheduling.batchBoardDetail.queryOptions({
|
||||
input: { scheduleId: scheduleId ?? "" },
|
||||
enabled: Boolean(scheduleId),
|
||||
refetchInterval: 30_000,
|
||||
// Poll fast while a window cycle is actively moving (open / doc-review /
|
||||
// payment) so the priority ranking + pay countdowns stay live; back off to
|
||||
// 30s once the cycle is idle (pre-window / closed / done).
|
||||
refetchInterval: (query) => {
|
||||
const phase = (query.state.data as BatchBoardScheduleDetail | undefined)
|
||||
?.windowPhase;
|
||||
return phase === "OPEN" ||
|
||||
phase === "DOC_REVIEW" ||
|
||||
phase === "PAYMENT"
|
||||
? 5_000
|
||||
: 30_000;
|
||||
},
|
||||
}),
|
||||
);
|
||||
// Keep the board in sync with server-pushed window-phase transitions too
|
||||
// (invalidates the batch-board list + patches window carousels).
|
||||
useBookingWindowSocket(Boolean(scheduleId));
|
||||
const runAllocation = useMutation(
|
||||
api.trainScheduling.runAllocation.mutationOptions(),
|
||||
);
|
||||
@@ -735,6 +752,13 @@ export default function BatchScheduleDetailPage() {
|
||||
<Tabs value={activeTab} onChange={setActiveTab}>
|
||||
<Tabs.List>
|
||||
<Tabs.Tab value="overview">Overview</Tabs.Tab>
|
||||
<Tabs.Tab
|
||||
value="priority"
|
||||
leftSection={<Trophy size={14} />}
|
||||
>
|
||||
Priority Tracking{" "}
|
||||
{allBookings.length > 0 && `(${allBookings.length})`}
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab value="composition">
|
||||
Train Composition{" "}
|
||||
{scheduleDetailQuery.data?.trainSet?.wagons &&
|
||||
@@ -1095,6 +1119,10 @@ export default function BatchScheduleDetailPage() {
|
||||
</Stack>
|
||||
</Tabs.Panel>
|
||||
|
||||
<Tabs.Panel value="priority" pt="lg">
|
||||
<PriorityTrackingTab data={data} bookings={allBookings} />
|
||||
</Tabs.Panel>
|
||||
|
||||
<Tabs.Panel value="composition" pt="lg">
|
||||
{scheduleDetailQuery.data && scheduleDetailQuery.data.trainSet ? (
|
||||
<Group align="stretch" gap="md" wrap="nowrap">
|
||||
|
||||
Reference in New Issue
Block a user