Skip to content

Commit

Permalink
front: adapt RTK calls to infra::routes endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
leovalais committed Jan 16, 2024
1 parent c3c6261 commit a823c8c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ export const RoutesList = ({ type, id }: RoutesListProps) => {
>({ type: 'idle' });
const { switchTool } = useContext(EditorContext) as ExtendedEditorContextType<unknown>;
const [getRoutesFromWaypoint] =
osrdEditoastApi.endpoints.getInfraByIdRoutesAndWaypointTypeWaypointId.useLazyQuery();
osrdEditoastApi.endpoints.getInfraByInfraIdRoutesAndWaypointTypeWaypointId.useLazyQuery();

useEffect(() => {
if (routesState.type === 'idle' && infraID) {
if (type !== 'BufferStop' && type !== 'Detector') {
setRoutesState({ type: 'error', message: `${type} elements are not valid waypoints.` });
} else {
setRoutesState({ type: 'loading' });
getRoutesFromWaypoint({ id: infraID, waypointType: type, waypointId: id })
getRoutesFromWaypoint({ infraId: infraID, waypointType: type, waypointId: id })
.unwrap()
.then(({ starting = [], ending = [] }) => {
if (starting.length || ending.length) {
Expand Down
6 changes: 3 additions & 3 deletions front/src/applications/editor/tools/routeEdition/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ async function getRouteGeometryByRoute(
dispatch: Dispatch
): Promise<Feature<LineString, { id: string }>> {
const trackRangesResult = await dispatch(
osrdEditoastApi.endpoints.getInfraByIdRoutesTrackRanges.initiate({
id: infra as number,
routes: [route.properties.id],
osrdEditoastApi.endpoints.getInfraByInfraIdRoutesTrackRanges.initiate({
infraId: infra as number,
routes: route.properties.id,
})
).unwrap();
if (trackRangesResult.length === 0 || trackRangesResult[0].type !== 'Computed') {
Expand Down

0 comments on commit a823c8c

Please sign in to comment.