Skip to content

Commit

Permalink
front: fix duplicated pr in suggested vias and time stops table
Browse files Browse the repository at this point in the history
Signed-off-by: Theo Macron <[email protected]>
  • Loading branch information
Akctarus committed Dec 2, 2024
1 parent c98d385 commit 0704f86
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -93,6 +93,8 @@ const ModalSuggestedVias = ({ suggestedVias }: ModalSuggestedViasProps) => {
);
};

const filteredSuggestedVias = _.uniqBy(suggestedVias, (via) => `${via.name}-${via.ch}`);

let idxTrueVia = 0;
return (
<div className="manage-vias-modal">
Expand All @@ -104,7 +106,7 @@ const ModalSuggestedVias = ({ suggestedVias }: ModalSuggestedViasProps) => {
</ModalHeaderSNCF>
<ModalBodySNCF>
<div className="suggested-vias">
{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;
Expand Down
2 changes: 2 additions & 0 deletions front/src/modules/timesStops/TimesStops.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -38,6 +39,7 @@ const TimesStops = <T extends TimesStopsRow>({
</div>
);
}
const filteredRows = _.uniqBy(rows, (row) => `${row.name}-${row.ch}`);

if (!rows) {
return (
Expand Down

0 comments on commit 0704f86

Please sign in to comment.