Skip to content

Commit

Permalink
fixup! front: select op with map when add train
Browse files Browse the repository at this point in the history
  • Loading branch information
theocrsb committed Dec 24, 2024
1 parent 192380d commit 0c38cde
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ const AddPathStepPopup = ({
}
>();

const [getTrackEntity] =
const [getInfraObjectEntity] =
osrdEditoastApi.endpoints.postInfraByInfraIdObjectsAndObjectType.useLazyQuery();

useEffect(() => {
const calculateOffset = async () => {
const objectId = featureInfoClick.feature.properties?.id;

const result = await getTrackEntity({
const result = await getInfraObjectEntity({
infraId: infraId!,
objectType: isOperationalPoint ? 'OperationalPoint' : 'TrackSection',
body: [objectId],
Expand All @@ -84,17 +84,17 @@ const AddPathStepPopup = ({
if (isOperationalPoint) {
const trackId = featureInfoClick.feature.properties?.track_id;

const clickedTrack = await getTrackEntity({
const clickedTrack = await getInfraObjectEntity({
infraId: infraId!,
objectType: 'TrackSection',
body: [trackId],
}).unwrap();

const { parts } = result[0].railjson as OperationalPoint;
const trackIds = parts.map((part) => part.track);
const operationalPoint = result[0].railjson as OperationalPoint;
const trackIds = operationalPoint.parts.map((part) => part.track);
const tracks = await getTrackSectionsByIds(trackIds);

const trackPartCoordinates = parts.map((part) => {
const trackPartCoordinates = operationalPoint.parts.map((part) => {
const track = tracks[part.track];

return {
Expand All @@ -112,8 +112,8 @@ const AddPathStepPopup = ({

setClickedOp({
id: nextId(),
secondary_code: (result[0].railjson as any).extensions.sncf.ch,
uic: (result[0].railjson as any).extensions.identifier.uic,
secondary_code: operationalPoint.extensions!.sncf!.ch,
uic: operationalPoint.extensions!.identifier!.uic,
tracks: trackPartCoordinates,
});
} else {
Expand Down

0 comments on commit 0c38cde

Please sign in to comment.