Skip to content

Commit 2c3c48e

Browse files
committed
front: simplify OP matching in useOutputTableData()
We were using a map keyed by the name and ch of OPs. This is more complicated than it needs to be and isn't robust (there is no guarantee that names+ch are unique). Instead, just use the OP ID.
1 parent 5038159 commit 2c3c48e

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

front/src/modules/timesStops/hooks/useOutputTableData.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ function useOutputTableData(
6868
pathStepsWithOpPointIndices,
6969
(pathStep) => `${pathStep.uic}-${pathStep.secondary_code}`
7070
);
71-
const operationPointsByNameCh = keyBy(
72-
operationalPoints,
73-
(opPoint) => `${opPoint.name}-${opPoint.ch}`
74-
);
7571

7672
const outputTableData = useMemo(() => {
7773
const pathStepRows = pathStepsWithPositionOnPath.map((pathStep) => {
@@ -81,7 +77,7 @@ function useOutputTableData(
8177
});
8278

8379
const suggestedOpRows = suggestedOperationalPoints.map((sugOpPoint, sugOpIndex) => {
84-
const opPoint = operationPointsByNameCh[`${sugOpPoint.name}-${sugOpPoint.ch}`];
80+
const opPoint = operationalPoints.find((op) => op.id === sugOpPoint.opId);
8581
if (!opPoint) {
8682
return sugOpPoint;
8783
}

0 commit comments

Comments
 (0)