Skip to content

Commit 2ef9be2

Browse files
committed
Add SSP creation for child quays and mirror quay deletion #35370
1 parent 12ef099 commit 2ef9be2

4 files changed

Lines changed: 67 additions & 5 deletions

File tree

ui/src/components/stop-registry/stops/queries/useDeleteQuay.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function useDeleteQuay() {
2626
(stopPlaceId: string, quayId: string) =>
2727
deleteQuay({
2828
variables: { stopPlaceId, quayId },
29-
refetchQueries: ['GetMapStops', 'getStopPlaceDetails'],
29+
refetchQueries: ['GetMapStops', 'getStopPlaceDetails', 'GetStopDetails'],
3030
awaitRefetchQueries: true,
3131
}),
3232
[deleteQuay],
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { useCallback, useState } from 'react';
2+
import {
3+
useGetStopPointsByQuayIdLazyQuery,
4+
useRemoveStopMutation,
5+
} from '../../../../../generated/graphql';
6+
import { useDeleteQuay } from '../../queries/useDeleteQuay';
7+
8+
type RemoveMirrorRelationParams = {
9+
readonly childQuayId: string;
10+
readonly childStopPlaceId: string;
11+
};
12+
13+
export function useRemoveMirrorRelation() {
14+
const [loading, setLoading] = useState(false);
15+
16+
const [getStopPointsByQuayId] = useGetStopPointsByQuayIdLazyQuery();
17+
const [removeStopMutation] = useRemoveStopMutation();
18+
const deleteQuay = useDeleteQuay();
19+
20+
const removeMirrorRelation = useCallback(
21+
async ({ childQuayId, childStopPlaceId }: RemoveMirrorRelationParams) => {
22+
setLoading(true);
23+
try {
24+
// 1. Remove the child's SSP (scheduled stop point)
25+
const sspResult = await getStopPointsByQuayId({
26+
variables: { quayIds: [childQuayId] },
27+
});
28+
const childStopPoints =
29+
sspResult.data?.service_pattern_scheduled_stop_point ?? [];
30+
await Promise.all(
31+
childStopPoints.map((ssp) =>
32+
removeStopMutation({
33+
variables: { stop_id: ssp.scheduled_stop_point_id },
34+
}),
35+
),
36+
);
37+
38+
// 2. Delete the child quay from Tiamat
39+
await deleteQuay(childStopPlaceId, childQuayId);
40+
41+
return true;
42+
} finally {
43+
setLoading(false);
44+
}
45+
},
46+
[getStopPointsByQuayId, removeStopMutation, deleteQuay],
47+
);
48+
49+
return { removeMirrorRelation, loading };
50+
}

ui/src/locales/en-US/common.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,13 @@
557557
"metro": "Metro station",
558558
"rail": "Train station",
559559
"water": "Ferry stop"
560-
}
560+
},
561+
"removeButton": "Remove from hybrid",
562+
"removeConfirmTitle": "Remove transport mode",
563+
"removeConfirmDescription": "Are you sure you want to remove this transport mode from hybrid use?",
564+
"removeConfirm": "Remove",
565+
"removeCancel": "Cancel",
566+
"removeSuccess": "Stop removed from hybrid use"
561567
},
562568
"version": {
563569
"copyBoilerPlate": "All properties from the existing stop will be copied over. You can edit the properties of the new copy after its creation.",
@@ -1700,4 +1706,4 @@
17001706
"routeStopsOverlayRowActions": "More actions for stop {{stopLabel}}"
17011707
}
17021708
}
1703-
}
1709+
}

ui/src/locales/fi-FI/common.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,13 @@
557557
"metro": "Metroasema",
558558
"rail": "Juna-asema",
559559
"water": "Lauttapysäkki"
560-
}
560+
},
561+
"removeButton": "Poista yhteiskäytöstä",
562+
"removeConfirmTitle": "Poista liikennemuoto",
563+
"removeConfirmDescription": "Haluatko varmasti poistaa tämän liikennemuodon yhteiskäytöstä?",
564+
"removeConfirm": "Poista",
565+
"removeCancel": "Peruuta",
566+
"removeSuccess": "Pysäkki poistettu yhteiskäytöstä"
561567
},
562568
"version": {
563569
"copyBoilerPlate": "Pysäkin kaikki ominaisuudet kopioidaan mukana. Voit muokata uuden version ominaisuuksia kopioinnin jälkeen.",
@@ -1700,4 +1706,4 @@
17001706
"routeStopsOverlayRowActions": "Lisää toimintoja pysäkille {{stopLabel}}"
17011707
}
17021708
}
1703-
}
1709+
}

0 commit comments

Comments
 (0)