feat: updateing the loading and unloading

This commit is contained in:
Nathnael
2026-08-24 14:01:19 +00:00
parent 17c2dca3cc
commit 562c8b48ba
9 changed files with 357 additions and 37 deletions

View File

@@ -24,6 +24,8 @@ type Field = {
hint: string;
unit: string;
integer?: boolean;
/** May be left blank, which clears it. Only the handling standards are. */
optional?: boolean;
};
type Section = { title: string; description: string; fields: Field[] };
@@ -84,6 +86,27 @@ const SECTIONS: Section[] = [
},
],
},
{
title: "Loading and unloading",
description:
"What a stop's handling should take, for the rate on Loading & Unloading. The reporting spec names no figure here, so both start blank and the rate stays empty until one is set. Leave blank to clear.",
fields: [
{
name: "handlingStandardHoursContainer",
label: "Container trains",
hint: "Unloading start to loading finish",
unit: "hrs",
optional: true,
},
{
name: "handlingStandardHoursBulk",
label: "Bulk trains",
hint: "Loading or unloading at the station",
unit: "hrs",
optional: true,
},
],
},
{
title: "Delay",
description:
@@ -189,6 +212,8 @@ export default function OperationsStandardsPage() {
const invalid = (field: Field): boolean => {
const raw = draft[field.name];
if (raw === undefined) return false;
// Blank on an optional field is a deliberate clear, not a bad number.
if (field.optional && raw.trim() === "") return false;
const parsed = Number(raw);
if (!Number.isFinite(parsed) || parsed <= 0) return true;
return field.integer ? !Number.isInteger(parsed) : false;
@@ -200,7 +225,10 @@ export default function OperationsStandardsPage() {
const handleSave = async () => {
if (anyInvalid || !dirty) return;
const patch = Object.fromEntries(
Object.entries(draft).map(([key, value]) => [key, Number(value)]),
Object.entries(draft).map(([key, value]) => [
key,
value.trim() === "" ? null : Number(value),
]),
);
await update.mutateAsync(patch);
setDraft({});

View File

@@ -19,6 +19,9 @@ export interface OperationsStandards {
cycleStandardHoursBulkBcc: number;
defaultLegStandardHours: number;
delayToleranceMinutes: number;
/** Null until a planner sets one — the spec names no handling standard. */
handlingStandardHoursContainer: number | null;
handlingStandardHoursBulk: number | null;
chargedTonsFull20ft: number;
chargedTonsFull40ft: number;
chargedTonsEmpty20ft: number;