feat: add wagon usage computation and maintenance logging features

- Implemented  utility to calculate wagon usage metrics for train schedules.
- Created  for sending wagons to maintenance with optional notes.
- Added unit tests for train builder maintenance functionalities, including formatting train run labels and building maintenance notes.
- Developed  component for merging train schedules with detailed previews and reasons for merging.
- Introduced  component for selecting wagons with search functionality and selection limits.
- Created  for displaying and filtering audit logs, including detailed views of individual log entries.
- Added  for handling API interactions related to audit logs, including fetching logs and entity types.
This commit is contained in:
marshalyordanos
2026-08-12 09:36:50 +03:00
parent 35e5404b41
commit 5da36eb128
77 changed files with 6275 additions and 296 deletions

View File

@@ -67,6 +67,7 @@ import type {
PinWagonsPayload,
RecordCheckpointPayload,
StaffBookingWindow,
ScheduleMergePreview,
TrainScheduleDetail,
TrainScheduleFilters,
TrainScheduleListFilters,
@@ -596,6 +597,36 @@ export const api = {
() => TRAIN_SCHEDULING_INVALIDATIONS,
),
previewScheduleMerge: endpoint<
{ id: string; targetTrainId: string },
ScheduleMergePreview
>(
"train-scheduling",
"merge-preview",
({ id, targetTrainId }) =>
trainSchedulingService.previewScheduleMerge(id, targetTrainId),
({ id, targetTrainId }) => [
"train-scheduling",
"merge-preview",
id,
targetTrainId,
],
),
mergeScheduleTrain: endpoint<
{ id: string; targetTrainId: string; reason?: string },
TrainScheduleDetail
>(
"train-scheduling",
"merge-train",
({ id, ...payload }) =>
trainSchedulingService.mergeScheduleTrain(id, payload),
undefined,
// Wagons and bookings move between trains and schedules, so the wagon and
// train caches are stale too — not just the scheduling ones.
() => [...TRAIN_SCHEDULING_INVALIDATIONS, ["wagons"], ["trains"]],
),
markBookingPaid: endpoint<string, void>(
"train-scheduling",
"mark-booking-paid",
@@ -2040,11 +2071,14 @@ export const api = {
() => TRAIN_BUILDER_INVALIDATIONS,
),
sendWagonToMaintenance: endpoint<{ id: string; wagonId: string }, TrainComposition>(
sendWagonToMaintenance: endpoint<
{ id: string; wagonId: string; note?: string },
TrainComposition
>(
"train-builder",
"sendWagonToMaintenance",
({ id, wagonId }) =>
trainBuilderService.sendWagonToMaintenance(id, wagonId).then((r) => r.data),
({ id, wagonId, note }) =>
trainBuilderService.sendWagonToMaintenance(id, wagonId, note).then((r) => r.data),
undefined,
() => TRAIN_BUILDER_INVALIDATIONS,
),