mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 18:48:11 +00:00
Merge pull request #847 from Tria-plc/freight_feature/usermanagement
chnages
This commit is contained in:
@@ -205,6 +205,14 @@ const WagonYardWorkspaceModal = ({ opened, onClose }: WagonYardWorkspaceModalPro
|
||||
const availableCount = availableWagons.length;
|
||||
const assignedCount = assignedWagons.length;
|
||||
const otherCount = otherWagons.length;
|
||||
// Split "Other" so a coupled wagon is visible as such. The Available/Assigned
|
||||
// buckets deliberately count only UNCOUPLED wagons (see above), so a yard
|
||||
// holding 54 assigned wagons of which 53 are on a train shows "Assigned 1" —
|
||||
// accurate for shunting, but unreadable unless the other 53 are named.
|
||||
const onTrainCount = useMemo(
|
||||
() => matching.filter((w) => w.trainId != null).length,
|
||||
[matching],
|
||||
);
|
||||
|
||||
const destinationYardOptions = useMemo(
|
||||
() =>
|
||||
@@ -397,9 +405,14 @@ const WagonYardWorkspaceModal = ({ opened, onClose }: WagonYardWorkspaceModalPro
|
||||
</div>
|
||||
</Group>
|
||||
<Group gap="lg" wrap="wrap">
|
||||
<LegendDot color="teal" label="Available" value={availableCount} />
|
||||
<LegendDot color="blue" label="Assigned" value={assignedCount} />
|
||||
{otherCount > 0 ? <LegendDot color="gray" label="Other" value={otherCount} /> : null}
|
||||
<LegendDot color="teal" label="Available in yard" value={availableCount} />
|
||||
<LegendDot color="blue" label="Assigned in yard" value={assignedCount} />
|
||||
{onTrainCount > 0 ? (
|
||||
<LegendDot color="gray" label="On train" value={onTrainCount} />
|
||||
) : null}
|
||||
{otherCount - onTrainCount > 0 ? (
|
||||
<LegendDot color="gray" label="Other" value={otherCount - onTrainCount} />
|
||||
) : null}
|
||||
</Group>
|
||||
</Group>
|
||||
|
||||
|
||||
@@ -128,6 +128,8 @@ const LOCOMOTIVE_STATUS_OPTIONS = [
|
||||
{ label: "Out of service", value: "OUT_OF_SERVICE" },
|
||||
];
|
||||
|
||||
// Every status a wagon can hold — for FILTERING the list. ASSIGNED belongs here:
|
||||
// staff still need to search for assigned wagons.
|
||||
const WAGON_STATUS_OPTIONS = [
|
||||
{ label: "Available", value: Freight.WagonStatus.Available },
|
||||
{ label: "Assigned", value: Freight.WagonStatus.Assigned },
|
||||
@@ -135,6 +137,15 @@ const WAGON_STATUS_OPTIONS = [
|
||||
{ label: "Detained", value: Freight.WagonStatus.Detained },
|
||||
];
|
||||
|
||||
// Statuses staff may set BY HAND on the create/edit form. ASSIGNED is omitted
|
||||
// on purpose: a wagon becomes ASSIGNED as a side effect of being built into a
|
||||
// train, never by editing it directly. Setting it by hand produced wagons that
|
||||
// claim to be assigned while coupled to nothing, which the yard workspace then
|
||||
// counts as in-yard stock.
|
||||
const WAGON_EDITABLE_STATUS_OPTIONS = WAGON_STATUS_OPTIONS.filter(
|
||||
(o) => o.value !== Freight.WagonStatus.Assigned,
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -333,7 +344,7 @@ export const FLEET_RESOURCES: FleetResourceConfig[] = [
|
||||
{ name: "wagonNumber", label: "Wagon number", type: "text", required: true },
|
||||
{ name: "wagonTypeId", label: "Wagon type", type: "select", required: true, dynamicOptions: "wagonTypes" },
|
||||
{ name: "currentYardId", label: "Current Yard", type: "select", dynamicOptions: "yards" },
|
||||
{ name: "status", label: "Status", type: "select", required: true, options: WAGON_STATUS_OPTIONS },
|
||||
{ name: "status", label: "Status", type: "select", required: true, options: WAGON_EDITABLE_STATUS_OPTIONS },
|
||||
{ name: "notes", label: "Notes", type: "textarea" },
|
||||
],
|
||||
emptyValues: {
|
||||
|
||||
@@ -20,7 +20,7 @@ import { useDebouncedValue } from "@mantine/hooks";
|
||||
import { isAxiosError } from "axios";
|
||||
import {
|
||||
ArrowRight,
|
||||
Ban,
|
||||
// Ban, — used only by the commented-out "Cancel schedule" row action
|
||||
CalendarClock,
|
||||
Clock,
|
||||
Eye,
|
||||
@@ -196,7 +196,7 @@ export default function TrainScheduleV2ListPage() {
|
||||
}),
|
||||
);
|
||||
const create = useMutation(api.trainScheduling.createSchedule.mutationOptions());
|
||||
const cancel = useMutation(api.trainScheduling.cancelSchedule.mutationOptions());
|
||||
// const cancel = useMutation(api.trainScheduling.cancelSchedule.mutationOptions());
|
||||
|
||||
// Intercity (same-country / DOMESTIC) routes cannot be scheduled yet — the
|
||||
// API rejects them, so keep them out of the picker entirely.
|
||||
@@ -464,6 +464,9 @@ export default function TrainScheduleV2ListPage() {
|
||||
Booking window settings
|
||||
</Menu.Item>
|
||||
) : null}
|
||||
{/* Cancel schedule — hidden for now (frontend only; the
|
||||
cancelSchedule mutation is untouched). Restore by
|
||||
uncommenting.
|
||||
{["DRAFT", "SCHEDULED"].includes(schedule.status) ? (
|
||||
<Menu.Item
|
||||
color="red"
|
||||
@@ -487,6 +490,7 @@ export default function TrainScheduleV2ListPage() {
|
||||
Cancel schedule
|
||||
</Menu.Item>
|
||||
) : null}
|
||||
*/}
|
||||
</Menu.Dropdown>
|
||||
</Menu>
|
||||
</Group>
|
||||
@@ -494,7 +498,7 @@ export default function TrainScheduleV2ListPage() {
|
||||
},
|
||||
},
|
||||
];
|
||||
}, [navigate, cancel.isPending, cancel, toast]);
|
||||
}, [navigate, toast]);
|
||||
|
||||
const handleCreate = async () => {
|
||||
if (!routeId || !scheduleDate || !trainId) {
|
||||
|
||||
@@ -344,6 +344,11 @@ export function Step2ServiceType({
|
||||
if (isIntercity && form.getValues("paymentCurrency") !== "ETB") {
|
||||
form.setValue("paymentCurrency", "ETB", { shouldValidate: true });
|
||||
}
|
||||
// The customs clearing agent field is hidden for intercity — drop any value
|
||||
// carried over from a draft or an operation-type switch.
|
||||
if (isIntercity && form.getValues("customsClearingAgent")) {
|
||||
form.setValue("customsClearingAgent", "", { shouldDirty: true });
|
||||
}
|
||||
}, [isIntercity, form]);
|
||||
|
||||
return (
|
||||
@@ -538,7 +543,9 @@ export function Step2ServiceType({
|
||||
)}
|
||||
|
||||
|
||||
{includesCustoms ? (
|
||||
{/* Intercity (domestic) moves never cross a border, so no customs
|
||||
clearing agent is collected. */}
|
||||
{isIntercity ? null : includesCustoms ? (
|
||||
<Box
|
||||
px={16}
|
||||
py={14}
|
||||
|
||||
Reference in New Issue
Block a user