From 0704f8610dc0961502134d30ae416fd5fb36b62b Mon Sep 17 00:00:00 2001 From: Theo Macron Date: Mon, 25 Nov 2024 17:19:31 +0100 Subject: [PATCH] front: fix duplicated pr in suggested vias and time stops table Signed-off-by: Theo Macron --- .../pathfinding/components/Itinerary/ModalSuggestedVias.tsx | 6 ++++-- front/src/modules/timesStops/TimesStops.tsx | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/front/src/modules/pathfinding/components/Itinerary/ModalSuggestedVias.tsx b/front/src/modules/pathfinding/components/Itinerary/ModalSuggestedVias.tsx index 64ac5390043..ef8473b0b37 100644 --- a/front/src/modules/pathfinding/components/Itinerary/ModalSuggestedVias.tsx +++ b/front/src/modules/pathfinding/components/Itinerary/ModalSuggestedVias.tsx @@ -2,7 +2,7 @@ import { useCallback } from 'react'; import { Dash, Plus, Trash } from '@osrd-project/ui-icons'; import cx from 'classnames'; -import { compact } from 'lodash'; +import _, { compact } from 'lodash'; import { useTranslation } from 'react-i18next'; import { useSelector } from 'react-redux'; @@ -93,6 +93,8 @@ const ModalSuggestedVias = ({ suggestedVias }: ModalSuggestedViasProps) => { ); }; + const filteredSuggestedVias = _.uniqBy(suggestedVias, (via) => `${via.name}-${via.ch}`); + let idxTrueVia = 0; return (
@@ -104,7 +106,7 @@ const ModalSuggestedVias = ({ suggestedVias }: ModalSuggestedViasProps) => {
- {suggestedVias.map((via, idx) => { + {filteredSuggestedVias.map((via, idx) => { if (!isOriginOrDestination(via)) { // If name is undefined, we know the op/via has been added by clicking on map if (isVia(vias, via)) idxTrueVia += 1; diff --git a/front/src/modules/timesStops/TimesStops.tsx b/front/src/modules/timesStops/TimesStops.tsx index 774860bf8ec..0d34145f246 100644 --- a/front/src/modules/timesStops/TimesStops.tsx +++ b/front/src/modules/timesStops/TimesStops.tsx @@ -1,4 +1,5 @@ import cx from 'classnames'; +import _ from 'lodash'; import { DynamicDataSheetGrid, type DataSheetGridProps } from 'react-datasheet-grid'; import type { Operation } from 'react-datasheet-grid/dist/types'; import { useTranslation } from 'react-i18next'; @@ -38,6 +39,7 @@ const TimesStops = ({
); } + const filteredRows = _.uniqBy(rows, (row) => `${row.name}-${row.ch}`); if (!rows) { return (