mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 16:28:12 +00:00
fix
This commit is contained in:
@@ -16,7 +16,7 @@ import { useEffect, useState } from "react";
|
||||
import { api } from "@/services/api";
|
||||
import type { TrainComposition } from "@/services/trainBuilder.service";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
import { EXPORT_TRAIN_OPTIONS, importRunFor } from "@/constants/trainRuns";
|
||||
import { IMPORT_TRAIN_OPTIONS, exportRunFor } from "@/constants/trainRuns";
|
||||
|
||||
const parseError = (error: unknown, fallback: string) => {
|
||||
if (isAxiosError(error)) {
|
||||
@@ -56,11 +56,11 @@ export default function BuildTrainModal({ opened, onClose, onBuilt }: BuildTrain
|
||||
setLocomotiveIds([]);
|
||||
}, [yardId]);
|
||||
|
||||
// The import run is fixed by the export run, so it tracks it rather than
|
||||
// being entered by hand (and clears back to empty when the export is cleared).
|
||||
// The export run is fixed by the import run, so it tracks it rather than
|
||||
// being entered by hand (and clears back to empty when the import is cleared).
|
||||
useEffect(() => {
|
||||
setImportTrainNumber(importRunFor(exportTrainNumber));
|
||||
}, [exportTrainNumber]);
|
||||
setExportTrainNumber(exportRunFor(importTrainNumber));
|
||||
}, [importTrainNumber]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!opened) {
|
||||
@@ -85,7 +85,7 @@ export default function BuildTrainModal({ opened, onClose, onBuilt }: BuildTrain
|
||||
// only "nothing picked" is reachable here.
|
||||
if (!exportTrainNumber || !importTrainNumber) {
|
||||
toast({
|
||||
title: "Pick an export train number (e.g. 8001) — the import run follows it",
|
||||
title: "Pick an import train number (e.g. 8002) — the export run follows it",
|
||||
variant: "destructive",
|
||||
});
|
||||
return;
|
||||
@@ -138,24 +138,24 @@ export default function BuildTrainModal({ opened, onClose, onBuilt }: BuildTrain
|
||||
maxLength={100}
|
||||
/>
|
||||
<Group grow>
|
||||
<Select
|
||||
{/* Fixed by the import run — derived, never typed. */}
|
||||
<TextInput
|
||||
label="Export train number"
|
||||
description="Odd — Ethiopia → Djibouti runs"
|
||||
placeholder="e.g. 8001"
|
||||
data={EXPORT_TRAIN_OPTIONS}
|
||||
value={exportTrainNumber || null}
|
||||
onChange={(value) => setExportTrainNumber(value ?? "")}
|
||||
searchable
|
||||
clearable
|
||||
value={exportTrainNumber}
|
||||
readOnly
|
||||
variant="filled"
|
||||
/>
|
||||
{/* Fixed by the export run — derived, never typed. */}
|
||||
<TextInput
|
||||
<Select
|
||||
label="Import train number"
|
||||
description="Even — Djibouti → Ethiopia runs"
|
||||
placeholder="e.g. 8002"
|
||||
value={importTrainNumber}
|
||||
readOnly
|
||||
variant="filled"
|
||||
data={IMPORT_TRAIN_OPTIONS}
|
||||
value={importTrainNumber || null}
|
||||
onChange={(value) => setImportTrainNumber(value ?? "")}
|
||||
searchable
|
||||
clearable
|
||||
/>
|
||||
</Group>
|
||||
<Select
|
||||
|
||||
Reference in New Issue
Block a user