mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-07 05:55:02 +00:00
Merge pull request #1337 from Tria-plc/freight_feature/usermanagement
Freight feature/usermanagement
This commit is contained in:
@@ -284,6 +284,32 @@ const TRAIN_BUILDER_INVALIDATIONS: ReadonlyArray<readonly unknown[]> = [
|
||||
QUERY_KEYS.FLEET.ROOT,
|
||||
];
|
||||
|
||||
/**
|
||||
* Coupling/uncoupling wagons moves wagons between the available pool and one
|
||||
* train — it does not touch locomotives, so those roots stay valid. Trimming
|
||||
* the set keeps a drag-reorder from refetching the whole fleet.
|
||||
*/
|
||||
const TRAIN_BUILDER_WAGON_INVALIDATIONS: ReadonlyArray<readonly unknown[]> = [
|
||||
QUERY_KEYS.TRAIN_BUILDER.ROOT,
|
||||
QUERY_KEYS.TRAIN_SCHEDULING.ROOT,
|
||||
["wagons"],
|
||||
];
|
||||
|
||||
/**
|
||||
* Every train-builder mutation responds with the train's full, fresh
|
||||
* composition — write it straight into the detail cache so the workspace
|
||||
* repaints from the response instead of refetching what it was just handed.
|
||||
*/
|
||||
const seedComposition = (
|
||||
input: { id: string } | string,
|
||||
data: TrainComposition,
|
||||
): ReadonlyArray<readonly [readonly unknown[], unknown]> => [
|
||||
[
|
||||
QUERY_KEYS.TRAIN_BUILDER.composition(typeof input === "string" ? input : input.id),
|
||||
data,
|
||||
],
|
||||
];
|
||||
|
||||
export const api = {
|
||||
trainScheduling: {
|
||||
// ── Queries ────────────────────────────────────────────────────────────
|
||||
@@ -2070,6 +2096,7 @@ export const api = {
|
||||
trainBuilderService.setLocomotives(id, locomotiveIds).then((r) => r.data),
|
||||
undefined,
|
||||
() => TRAIN_BUILDER_INVALIDATIONS,
|
||||
seedComposition,
|
||||
),
|
||||
|
||||
setYard: endpoint<{ id: string; currentYardId: string }, TrainComposition>(
|
||||
@@ -2079,6 +2106,7 @@ export const api = {
|
||||
trainBuilderService.setYard(id, currentYardId).then((r) => r.data),
|
||||
undefined,
|
||||
() => TRAIN_BUILDER_INVALIDATIONS,
|
||||
seedComposition,
|
||||
),
|
||||
|
||||
updateDetails: endpoint<
|
||||
@@ -2091,6 +2119,7 @@ export const api = {
|
||||
trainBuilderService.updateDetails(id, payload).then((r) => r.data),
|
||||
undefined,
|
||||
() => TRAIN_BUILDER_INVALIDATIONS,
|
||||
seedComposition,
|
||||
),
|
||||
|
||||
assignWagons: endpoint<{ id: string; wagonIds: string[] }, TrainComposition>(
|
||||
@@ -2099,7 +2128,8 @@ export const api = {
|
||||
({ id, wagonIds }) =>
|
||||
trainBuilderService.assignWagons(id, wagonIds).then((r) => r.data),
|
||||
undefined,
|
||||
() => TRAIN_BUILDER_INVALIDATIONS,
|
||||
() => TRAIN_BUILDER_WAGON_INVALIDATIONS,
|
||||
seedComposition,
|
||||
),
|
||||
|
||||
removeWagon: endpoint<{ id: string; wagonId: string }, TrainComposition>(
|
||||
@@ -2108,7 +2138,8 @@ export const api = {
|
||||
({ id, wagonId }) =>
|
||||
trainBuilderService.removeWagon(id, wagonId).then((r) => r.data),
|
||||
undefined,
|
||||
() => TRAIN_BUILDER_INVALIDATIONS,
|
||||
() => TRAIN_BUILDER_WAGON_INVALIDATIONS,
|
||||
seedComposition,
|
||||
),
|
||||
|
||||
sendWagonToMaintenance: endpoint<
|
||||
@@ -2120,7 +2151,8 @@ export const api = {
|
||||
({ id, wagonId, note }) =>
|
||||
trainBuilderService.sendWagonToMaintenance(id, wagonId, note).then((r) => r.data),
|
||||
undefined,
|
||||
() => TRAIN_BUILDER_INVALIDATIONS,
|
||||
() => TRAIN_BUILDER_WAGON_INVALIDATIONS,
|
||||
seedComposition,
|
||||
),
|
||||
|
||||
reorderWagons: endpoint<{ id: string; wagonIds: string[] }, TrainComposition>(
|
||||
@@ -2129,7 +2161,8 @@ export const api = {
|
||||
({ id, wagonIds }) =>
|
||||
trainBuilderService.reorderWagons(id, wagonIds).then((r) => r.data),
|
||||
undefined,
|
||||
() => TRAIN_BUILDER_INVALIDATIONS,
|
||||
() => TRAIN_BUILDER_WAGON_INVALIDATIONS,
|
||||
seedComposition,
|
||||
),
|
||||
|
||||
deactivate: endpoint<string, TrainComposition>(
|
||||
@@ -2138,6 +2171,7 @@ export const api = {
|
||||
(id) => trainBuilderService.deactivate(id).then((r) => r.data),
|
||||
undefined,
|
||||
() => TRAIN_BUILDER_INVALIDATIONS,
|
||||
seedComposition,
|
||||
),
|
||||
|
||||
activate: endpoint<string, TrainComposition>(
|
||||
@@ -2146,6 +2180,7 @@ export const api = {
|
||||
(id) => trainBuilderService.activate(id).then((r) => r.data),
|
||||
undefined,
|
||||
() => TRAIN_BUILDER_INVALIDATIONS,
|
||||
seedComposition,
|
||||
),
|
||||
|
||||
disband: endpoint<string, void>(
|
||||
|
||||
Reference in New Issue
Block a user