mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-05 20:03:39 +00:00
Backend now generates a separate marshalling document per corridor stop where the consist actually coupled/uncoupled/switched something (marshallingStops/marshallingDocumentAt), instead of one 'current position' doc. Wires that into the backoffice: - TrainScheduleV2DetailPage: the single Intercity Marshalling menu item becomes one item per stop with a logged change, falling back to the old single item when nothing has happened yet. - TrainScheduleTrackPage: same fallback/menu treatment on its own marshalling button. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
289 lines
11 KiB
TypeScript
289 lines
11 KiB
TypeScript
import type { FleetResourceSlug } from "@/pages/fleet/config/resources";
|
|
import type { BookingListFilter } from "@/services/bookings.service";
|
|
import type { ContractListFilter } from "@/services/contracts.service";
|
|
import type { RuleEngineListParams } from "@/services/ruleEngine/ruleEngine.service";
|
|
import type { CompanyListFilter } from "@/types/customer";
|
|
import type { InvoiceListFilter } from "@/types/invoice";
|
|
import type { RuleEngineResourceSlug } from "@/types/rule-engine";
|
|
import type { TrainScheduleFilters } from "@/types/trainScheduling";
|
|
|
|
export const QUERY_KEYS = {
|
|
USERS: {
|
|
ROOT: ["users"] as const,
|
|
ADD: ["users", "add"] as const,
|
|
},
|
|
|
|
FILES: {
|
|
ROOT: ["file-upload-settings"] as const,
|
|
list: () => ["file-upload-settings", "list"] as const,
|
|
byId: (id: string) => ["file-upload-settings", "detail", id] as const,
|
|
byCode: (code: string) =>
|
|
["file-upload-settings", "by-code", code] as const,
|
|
},
|
|
|
|
DROPDOWN_SETTINGS: {
|
|
ROOT: ["dropdown-settings"] as const,
|
|
list: () => ["dropdown-settings", "list"] as const,
|
|
byId: (id: string) => ["dropdown-settings", "detail", id] as const,
|
|
byCode: (code: string) => ["dropdown-settings", "by-code", code] as const,
|
|
},
|
|
|
|
SHIPPING_LINE_COMPANIES: {
|
|
ROOT: ["shipping-line-companies"] as const,
|
|
list: (page: number, limit: number) =>
|
|
["shipping-line-companies", "list", page, limit] as const,
|
|
byId: (id: string) =>
|
|
["shipping-line-companies", "detail", id] as const,
|
|
},
|
|
|
|
SHIPPING_LINE_CREDITS: {
|
|
ROOT: ["shipping-line-credits"] as const,
|
|
invoices: (
|
|
page: number,
|
|
pageSize: number,
|
|
status?: string,
|
|
shippingLineId?: string,
|
|
) =>
|
|
[
|
|
"shipping-line-credits",
|
|
"invoices",
|
|
shippingLineId ?? "all",
|
|
page,
|
|
pageSize,
|
|
status ?? "all",
|
|
] as const,
|
|
summary: (shippingLineId?: string) =>
|
|
["shipping-line-credits", "summary", shippingLineId ?? "all"] as const,
|
|
list: (
|
|
page: number,
|
|
pageSize: number,
|
|
status?: string,
|
|
shippingLineId?: string,
|
|
) =>
|
|
[
|
|
"shipping-line-credits",
|
|
"list",
|
|
shippingLineId ?? "all",
|
|
page,
|
|
pageSize,
|
|
status ?? "all",
|
|
] as const,
|
|
},
|
|
|
|
CUSTOMERS: {
|
|
ROOT: ["customers"] as const,
|
|
stats: ["customers", "stats"] as const,
|
|
list: (filter?: CompanyListFilter) =>
|
|
["customers", "list", filter ?? {}] as const,
|
|
byId: (id: string) => ["customers", "detail", id] as const,
|
|
bookings: (id: string) => ["customers", "detail", id, "bookings"] as const,
|
|
documents: (id: string) =>
|
|
["customers", "detail", id, "documents"] as const,
|
|
payments: (id: string) => ["customers", "detail", id, "payments"] as const,
|
|
accounts: (id: string) => ["customers", "detail", id, "accounts"] as const,
|
|
resetTarget: (id: string) =>
|
|
["customers", "detail", id, "reset-target"] as const,
|
|
changeRequests: (id: string) =>
|
|
["customers", "detail", id, "change-requests"] as const,
|
|
revisions: (id: string) =>
|
|
["customers", "detail", id, "revisions"] as const,
|
|
},
|
|
|
|
INVOICES: {
|
|
ROOT: ["invoices"] as const,
|
|
list: (filter?: InvoiceListFilter) =>
|
|
["invoices", "list", filter ?? {}] as const,
|
|
byId: (id: string) => ["invoices", "detail", id] as const,
|
|
offlineUsd: (filter?: InvoiceListFilter) =>
|
|
["invoices", "offline-usd", filter ?? {}] as const,
|
|
summary: (filter?: Omit<InvoiceListFilter, "page" | "pageSize">) =>
|
|
["invoices", "summary", filter ?? {}] as const,
|
|
eimsStatus: (id: string) => ["invoices", "eims", id] as const,
|
|
eimsReceipts: (id: string) => ["invoices", "eims", id, "receipts"] as const,
|
|
},
|
|
|
|
BOOKINGS: {
|
|
ROOT: ["bookings"] as const,
|
|
list: (filter?: BookingListFilter) =>
|
|
["bookings", "list", filter ?? {}] as const,
|
|
listSummary: (filter?: BookingListFilter) =>
|
|
["bookings", "list-summary", filter ?? {}] as const,
|
|
byId: (id: string) => ["bookings", "detail", id] as const,
|
|
clearanceQueue: (region?: string) =>
|
|
["bookings", "clearance-queue", region ?? "ET"] as const,
|
|
},
|
|
|
|
CONTRACTS: {
|
|
ROOT: ["contracts"] as const,
|
|
list: (filter?: ContractListFilter) =>
|
|
["contracts", "list", filter ?? {}] as const,
|
|
listSummary: (filter?: ContractListFilter) =>
|
|
["contracts", "list-summary", filter ?? {}] as const,
|
|
byId: (id: string) => ["contracts", "detail", id] as const,
|
|
clearance: (id: string) => ["contracts", "clearance", id] as const,
|
|
clearanceQueue: (region?: string) =>
|
|
["contracts", "clearance-queue", region ?? "ET"] as const,
|
|
clearanceHistory: (region?: string) =>
|
|
["contracts", "clearance-history", region ?? "ET"] as const,
|
|
milestones: (id: string) => ["contracts", "milestones", id] as const,
|
|
capacity: (id: string) => ["contracts", "capacity", id] as const,
|
|
bookingRequests: (id: string) =>
|
|
["contracts", "booking-requests", id] as const,
|
|
bookingMilestones: (bookingId: string) =>
|
|
["contracts", "booking-milestones", bookingId] as const,
|
|
bookingIncidents: (bookingId: string) =>
|
|
["contracts", "booking-incidents", bookingId] as const,
|
|
},
|
|
|
|
BOOKING_ORDERS: {
|
|
ROOT: ["booking-orders"] as const,
|
|
byContract: (contractBookingId: string) =>
|
|
["booking-orders", "by-contract", contractBookingId] as const,
|
|
pool: (contractBookingId: string) =>
|
|
["booking-orders", "pool", contractBookingId] as const,
|
|
},
|
|
|
|
TRAIN_SCHEDULING: {
|
|
ROOT: ["train-scheduling"] as const,
|
|
eligible: (freightType?: string, filters?: TrainScheduleFilters) =>
|
|
[
|
|
"train-scheduling",
|
|
"eligible-bookings",
|
|
freightType ?? "CONTAINER",
|
|
filters ?? {},
|
|
] as const,
|
|
locomotives: (routeId?: string) =>
|
|
["train-scheduling", "locomotives", routeId ?? "all"] as const,
|
|
availableTrains: (routeId?: string) =>
|
|
["train-scheduling", "available-trains", routeId ?? "all"] as const,
|
|
stations: () => ["train-scheduling", "stations"] as const,
|
|
schedules: (filters?: unknown) =>
|
|
["train-scheduling", "schedules", filters ?? {}] as const,
|
|
scheduleById: (id: string) => ["train-scheduling", "schedule", id] as const,
|
|
track: (id: string) => ["train-scheduling", "track", id] as const,
|
|
marshallingStops: (id: string) =>
|
|
["train-scheduling", "marshalling-stops", id] as const,
|
|
batchBoard: (filters?: unknown) =>
|
|
["train-scheduling", "batch-board", "list", filters ?? {}] as const,
|
|
batchBoardDetail: (scheduleId: string) =>
|
|
["train-scheduling", "batch-board", scheduleId] as const,
|
|
unassignedBookings: (id: string) =>
|
|
["train-scheduling", "unassigned", id] as const,
|
|
compositionRemovals: (id: string) =>
|
|
["train-scheduling", "removals", id] as const,
|
|
importLoadingBookings: (id: string) =>
|
|
["train-scheduling", "import-loading-bookings", id] as const,
|
|
},
|
|
|
|
FLEET: {
|
|
ROOT: ["fleet"] as const,
|
|
list: (resource: FleetResourceSlug | string) =>
|
|
["fleet", "list", resource] as const,
|
|
},
|
|
|
|
TRAIN_BUILDER: {
|
|
ROOT: ["train-builder"] as const,
|
|
list: (filters?: unknown) => ["train-builder", "list", filters ?? {}] as const,
|
|
composition: (id: string) => ["train-builder", "composition", id] as const,
|
|
},
|
|
|
|
VEHICLES: {
|
|
ROOT: ["vehicles"] as const,
|
|
list: (filter?: Record<string, unknown>) =>
|
|
["vehicles", "list", filter ?? {}] as const,
|
|
byId: (id: string) => ["vehicles", "detail", id] as const,
|
|
},
|
|
|
|
FIRST_MILE: {
|
|
ROOT: ["first-mile"] as const,
|
|
list: (filter?: Record<string, unknown>) =>
|
|
["first-mile", "list", filter ?? {}] as const,
|
|
byId: (id: string) => ["first-mile", "detail", id] as const,
|
|
},
|
|
|
|
LAST_MILE: {
|
|
ROOT: ["last-mile"] as const,
|
|
list: (filter?: Record<string, unknown>) =>
|
|
["last-mile", "list", filter ?? {}] as const,
|
|
byId: (id: string) => ["last-mile", "detail", id] as const,
|
|
},
|
|
|
|
LAST_MILE_REQUESTS: {
|
|
ROOT: ["last-mile-requests"] as const,
|
|
list: (filter?: Record<string, unknown>) =>
|
|
["last-mile-requests", "list", filter ?? {}] as const,
|
|
freeTruckCount: ["last-mile-requests", "free-truck-count"] as const,
|
|
priceEstimate: (id: string) =>
|
|
["last-mile-requests", "price-estimate", id] as const,
|
|
},
|
|
|
|
RULE_ENGINE: {
|
|
ROOT: ["rule-engine"] as const,
|
|
list: (
|
|
resource: RuleEngineResourceSlug | string,
|
|
params?: RuleEngineListParams,
|
|
) => ["rule-engine", "list", resource, params ?? {}] as const,
|
|
detail: (resource: RuleEngineResourceSlug | string, id: string) =>
|
|
["rule-engine", "detail", resource, id] as const,
|
|
chain: ["rule-engine", "approval-rules", "chain"] as const,
|
|
selectOptions: (
|
|
resource: RuleEngineResourceSlug | string,
|
|
params?: Record<string, unknown>,
|
|
) => ["rule-engine", "select-options", resource, params ?? {}] as const,
|
|
orderList: (resource: RuleEngineResourceSlug | string) =>
|
|
["rule-engine", "order-list", resource] as const,
|
|
priorityRuleChanges: ["rule-engine", "priority-rule-changes"] as const,
|
|
rateChanges: ["rule-engine", "rate-changes"] as const,
|
|
},
|
|
|
|
OVERVIEW: {
|
|
ROOT: ["overview"] as const,
|
|
layouts: () => ["overview", "layouts"] as const,
|
|
dashboard: (range?: string) =>
|
|
["overview", "dashboard", range ?? "30d"] as const,
|
|
bookingsTab: (range?: string) =>
|
|
["overview", "bookings", range ?? "30d"] as const,
|
|
contractsTab: (range?: string) =>
|
|
["overview", "contracts", range ?? "30d"] as const,
|
|
billingTab: (range?: string) =>
|
|
["overview", "billing", range ?? "30d"] as const,
|
|
operationsTab: (range?: string) =>
|
|
["overview", "operations", range ?? "30d"] as const,
|
|
fleetTab: (range?: string) => ["overview", "fleet", range ?? "30d"] as const,
|
|
clearanceTab: () => ["overview", "clearance"] as const,
|
|
customersTab: (range?: string) =>
|
|
["overview", "customers", range ?? "30d"] as const,
|
|
staffTab: (range?: string) =>
|
|
["overview", "staff", range ?? "30d"] as const,
|
|
},
|
|
|
|
FUEL: {
|
|
ROOT: ["fuel"] as const,
|
|
purchases: (vehicleId?: string) =>
|
|
["fuel", "purchases", vehicleId ?? "all"] as const,
|
|
stats: (vehicleId?: string) =>
|
|
["fuel", "stats", vehicleId ?? "all"] as const,
|
|
},
|
|
|
|
MAINTENANCE: {
|
|
ROOT: ["maintenance"] as const,
|
|
dueBoard: () => ["maintenance", "due-board"] as const,
|
|
schedules: (vehicleId?: string) =>
|
|
["maintenance", "schedules", vehicleId ?? "all"] as const,
|
|
upcoming: (vehicleId?: string) =>
|
|
["maintenance", "upcoming", vehicleId ?? "all"] as const,
|
|
history: (vehicleId?: string) =>
|
|
["maintenance", "history", vehicleId ?? "all"] as const,
|
|
stats: (vehicleId?: string) =>
|
|
["maintenance", "stats", vehicleId ?? "all"] as const,
|
|
intervals: (vehicleId?: string) =>
|
|
["maintenance", "intervals", vehicleId ?? "all"] as const,
|
|
},
|
|
|
|
FINANCIAL_REPORTS: {
|
|
ROOT: ["financial-reports"] as const,
|
|
fleet: (vehicleId?: string, months?: number) =>
|
|
["financial-reports", "fleet", vehicleId ?? "all", months ?? 12] as const,
|
|
},
|
|
} as const;
|