Merge pull request #720 from Tria-plc/freight_feature/usermanagement

fix issue
This commit is contained in:
marshal
2026-07-16 03:34:14 +03:00
committed by GitHub
51 changed files with 1895 additions and 206 deletions

View File

@@ -298,7 +298,17 @@ const FleetResourcePage = () => {
const handleFormSubmit = async (values: Record<string, unknown>) => {
try {
if (editing && "id" in editing) {
await update.mutateAsync({ slug, id: String(editing.id), data: values });
// PATCH only the fields the user actually changed. Re-sending the whole
// form used to re-submit status/currentYardId on every save — which,
// for a locomotive/wagon coupled to a built train, silently diverged
// the consist (editing a name could move the loco to another yard).
const editingRecord = editing as unknown as Record<string, unknown>;
const changed = Object.fromEntries(
Object.entries(values).filter(
([key, value]) => value !== editingRecord[key],
),
);
await update.mutateAsync({ slug, id: String(editing.id), data: changed });
toast({ title: `${config.entityLabel} updated` });
} else {
await create.mutateAsync({ slug, data: values });