Skip to content

Commit

Permalink
front: change the strategy. Filter DPY-MAS opertaional points inside …
Browse files Browse the repository at this point in the history
…the request

Signed-off-by: nncluzu <[email protected]>
  • Loading branch information
kmer2016 committed Dec 30, 2024
1 parent 816af8e commit 10512cf
Show file tree
Hide file tree
Showing 4 changed files with 367 additions and 193 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ import { useEffect, useMemo } from 'react';

import { Select, ComboBox } from '@osrd-project/ui-core';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';

import CI_CH_OPERATIONAL_POINTS_ON_DPY_MAS from 'assets/operationStudies/ciChOperationalPointsOnDPYMAS';
import { type SearchResultItemOperationalPoint } from 'common/api/osrdEditoastApi';
import useSearchOperationalPoint from 'common/Map/Search/useSearchOperationalPoint';
import { useOsrdConfActions } from 'common/osrdContext';
import type { StdcmConfSliceActions } from 'reducers/osrdconf/stdcmConf';
import type { StdcmPathStep } from 'reducers/osrdconf/types';
import { userHasOnlyStdcmRoles } from 'reducers/user/userSelectors';
import { useAppDispatch } from 'store';
import { normalized } from 'utils/strings';
import { createFixedSelectOptions } from 'utils/uiCoreHelpers';
Expand All @@ -35,29 +32,20 @@ const StdcmOperationalPoint = ({ location, pathStepId, disabled }: StdcmOperatio
useSearchOperationalPoint({
initialSearchTerm: location?.name,
initialChCodeFilter: location?.secondary_code,
isStdcm: true,
});

const hasOnlyStdcmRoles = useSelector(userHasOnlyStdcmRoles);

const { updateStdcmPathStep } = useOsrdConfActions() as StdcmConfSliceActions;

const operationalPointsSuggestions = useMemo(
() =>
// Temporary filter added to show a more restrictive list of suggestions inside the stdcm app.
sortedSearchResults
.filter((op) => {
const isNameMatch = normalized(op.name).startsWith(normalized(searchTerm));
const isTrigramMatch = op.trigram === searchTerm.toUpperCase();

if (hasOnlyStdcmRoles) {
return (
CI_CH_OPERATIONAL_POINTS_ON_DPY_MAS[op.ci]?.includes(op.ch) &&
(isNameMatch || isTrigramMatch)
);
}

return isNameMatch || isTrigramMatch;
})
.filter(
(op) =>
normalized(op.name).startsWith(normalized(searchTerm)) ||
op.trigram === searchTerm.toUpperCase()
)
.reduce((acc, p) => {
const newObject = {
label: [p.trigram, p.name].join(' '),
Expand Down
337 changes: 337 additions & 0 deletions front/src/assets/operationStudies/DPYToMASOperationalPoints.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,337 @@
const DPY_TO_MAS_OPERATIONAL_POINTS: [number, string][] = [
[112136, '00'],
[140210, '00'],
[140228, '00'],
[140236, '00'],
[140244, '00'],
[140251, '00'],
[140269, '00'],
[140277, '00'],
[140285, '00'],
[144816, '00'],
[207779, '00'],
[352054, '00'],
[357178, '00'],
[441535, 'EP'],
[556621, '00'],
[598482, '00'],
[712026, '00'],
[712604, '00'],
[712620, '00'],
[712679, '00'],
[713032, 'P1'],
[713032, 'P2'],
[713032, 'P3'],
[713032, 'P4'],
[713040, 'AS'],
[713040, 'ES'],
[713503, '00'],
[713511, 'BV'],
[713529, '00'],
[713529, '12'],
[713529, 'V9'],
[713537, '00'],
[713545, '00'],
[713545, 'EN'],
[713560, '00'],
[713578, '3E'],
[713578, 'BN'],
[713578, 'BS'],
[713578, 'BV'],
[713586, '00'],
[713628, '00'],
[713636, '00'],
[713644, '00'],
[713651, 'BV'],
[713669, '00'],
[713677, '00'],
[713693, '00'],
[713701, 'BV'],
[713735, 'BV'],
[713735, 'EP'],
[713867, 'ZI'],
[713875, '13'],
[713875, '3B'],
[713875, 'AT'],
[713875, 'BK'],
[713875, 'P2'],
[713875, 'P3'],
[713875, 'RA'],
[713875, 'RI'],
[713875, 'RO'],
[713875, 'RP'],
[718296, 'BF'],
[718296, 'BV'],
[721001, '13'],
[721001, 'AN'],
[721001, 'AS'],
[721001, 'BV'],
[721001, 'FP'],
[721001, 'TU'],
[721225, '00'],
[721241, '00'],
[721266, '00'],
[721282, 'BV'],
[721282, 'P1'],
[721282, 'P2'],
[721282, 'VG'],
[721290, 'BV'],
[721290, 'KM'],
[721290, 'PK'],
[721324, '00'],
[721332, 'BV'],
[721332, 'PK'],
[721340, 'BV'],
[721340, 'PK'],
[721357, '00'],
[721357, 'V3'],
[722009, '21'],
[722009, 'AG'],
[722025, 'BV'],
[722025, 'K1'],
[722025, 'PS'],
[722207, '00'],
[722231, '00'],
[722249, '00'],
[722264, 'BV'],
[722298, '00'],
[722306, 'P1'],
[722306, 'P2'],
[722314, 'BV'],
[722322, '00'],
[722348, '00'],
[722439, '21'],
[722439, '25'],
[722439, 'BR'],
[722439, 'BV'],
[722439, 'KM'],
[722520, 'BN'],
[722520, 'BS'],
[722520, 'FR'],
[722520, 'IT'],
[722520, 'NS'],
[722520, 'SN'],
[722538, '00'],
[722546, '00'],
[722553, '00'],
[722561, 'BV'],
[722561, 'HA'],
[722561, 'P1'],
[722579, 'BV'],
[722579, 'PK'],
[722579, 'UR'],
[722587, 'BV'],
[722587, 'PU'],
[722645, '00'],
[722652, '00'],
[722660, 'BV'],
[722678, '00'],
[722686, '00'],
[723197, 'AN'],
[723197, 'AS'],
[723197, 'BF'],
[723197, 'BV'],
[723197, 'ES'],
[723197, 'G1'],
[723197, 'KN'],
[723197, 'KS'],
[723197, 'PO'],
[723197, 'SM'],
[723254, '00'],
[723502, '00'],
[723528, '00'],
[723536, '00'],
[723544, 'BV'],
[723551, '00'],
[723569, 'BV'],
[723577, '00'],
[723585, '00'],
[725002, 'AS'],
[725002, 'BF'],
[725002, 'BV'],
[725002, 'FI'],
[725002, 'PA'],
[725606, '00'],
[725614, '00'],
[725614, 'AG'],
[725614, 'PV'],
[725622, '00'],
[725622, 'AG'],
[725655, 'AG'],
[725655, 'BV'],
[725655, 'PV'],
[725663, '00'],
[725671, '00'],
[725689, 'BF'],
[725689, 'BV'],
[725689, 'CH'],
[725689, 'FA'],
[725689, 'KM'],
[725689, 'PK'],
[725689, 'PV'],
[725689, 'RN'],
[725689, 'RS'],
[725713, '00'],
[725721, '00'],
[725721, 'V3'],
[725721, 'V4'],
[725739, 'BV'],
[725739, 'PK'],
[728006, '27'],
[728006, '74'],
[728006, '7P'],
[728006, 'AG'],
[728006, 'CV'],
[728006, 'J1'],
[728006, 'KM'],
[728006, 'MT'],
[728006, 'P7'],
[728006, 'PO'],
[728006, 'SF'],
[728006, 'VI'],
[728501, 'BV'],
[742114, '00'],
[743005, 'BV'],
[743005, 'P1'],
[743005, 'P2'],
[743104, 'BV'],
[743112, '00'],
[743120, '00'],
[743146, 'BV'],
[743146, 'SM'],
[743203, '00'],
[743211, '00'],
[743708, 'BV'],
[743716, 'AG'],
[743716, 'AR'],
[743716, 'BV'],
[743716, 'EP'],
[743716, 'P1'],
[743716, 'P2'],
[743716, 'P5'],
[753004, 'A2'],
[753004, 'AN'],
[753004, 'AT'],
[753004, 'BN'],
[753004, 'BV'],
[753004, 'DP'],
[753004, 'FD'],
[753004, 'FR'],
[753004, 'PC'],
[753004, 'RC'],
[753004, 'RL'],
[753004, 'SC'],
[753657, 'BV'],
[753681, '00'],
[753681, '3G'],
[753681, 'KM'],
[753707, '00'],
[753715, '00'],
[753731, '00'],
[753764, '00'],
[761007, 'BG'],
[761007, 'BP'],
[761007, 'BV'],
[761007, 'ES'],
[761007, 'IT'],
[761007, 'JO'],
[761106, '62'],
[761106, 'BN'],
[761106, 'BS'],
[761106, 'BV'],
[761106, 'NS'],
[761122, 'BV'],
[761130, '00'],
[761163, '00'],
[761189, 'BV'],
[761205, 'AS'],
[761205, 'BV'],
[761205, 'P1'],
[761205, 'P2'],
[761247, 'BS'],
[761247, 'BV'],
[761247, 'NS'],
[761247, 'RC'],
[761262, '00'],
[761403, 'BV'],
[761403, 'CV'],
[761403, 'NS'],
[761403, 'P1'],
[761403, 'RN'],
[761437, '00'],
[761460, 'BV'],
[761460, 'SG'],
[761486, '00'],
[761494, '00'],
[761502, 'EP'],
[761528, '00'],
[761544, 'BP'],
[761544, 'BT'],
[761544, 'NS'],
[761544, 'P1'],
[764001, 'BV'],
[764290, '00'],
[764308, 'BF'],
[764308, 'BV'],
[764308, 'RL'],
[764357, '00'],
[764407, '00'],
[764449, 'BV'],
[764472, 'AS'],
[764472, 'BV'],
[764472, 'PN'],
[764506, 'EP'],
[764522, 'BV'],
[764522, 'EP'],
[764555, '00'],
[764571, 'BV'],
[764571, 'EP'],
[764613, '00'],
[765008, 'BC'],
[765008, 'BR'],
[765008, 'BV'],
[765024, 'A1'],
[765024, 'A2'],
[765024, 'P1'],
[765024, 'RP'],
[765040, '2T'],
[765040, 'BC'],
[765040, 'CF'],
[765040, 'DU'],
[765040, 'PC'],
[765040, 'UD'],
[765040, 'VC'],
[765107, 'AS'],
[765107, 'BV'],
[765107, 'KP'],
[765107, 'PK'],
[765107, 'PR'],
[765180, 'BV'],
[765198, '00'],
[765206, '00'],
[765206, '2B'],
[765255, 'BV'],
[765305, '00'],
[765339, '00'],
[765354, 'KP'],
[765354, 'PK'],
[765354, 'RN'],
[765354, 'RS'],
[765354, 'V4'],
[765354, 'V5'],
[765412, '00'],
[765420, '00'],
[765438, '00'],
[765446, '00'],
[765453, '00'],
[765479, '00'],
[765503, 'BV'],
[765503, 'CB'],
[765842, 'EP'],
[765875, 'BR'],
[765875, 'BV'],
[765875, 'RN'],
[21030, 'BV'],
];

export default DPY_TO_MAS_OPERATIONAL_POINTS;
Loading

0 comments on commit 10512cf

Please sign in to comment.