Skip to content

Commit 4f61d00

Browse files
committed
front: restrict OP to Perigny-Miramas line for users with railway_undertaker profile
Signed-off-by: nncluzu <[email protected]>
1 parent 3613a9b commit 4f61d00

File tree

2 files changed

+192
-5
lines changed

2 files changed

+192
-5
lines changed

front/src/applications/stdcm/components/StdcmForm/StdcmOperationalPoint.tsx

+18-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ import { useEffect, useMemo } from 'react';
22

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

7+
import CI_CH_OPERATIONAL_POINTS_ON_DPY_MAS from 'assets/operationStudies/ciChOperationalPointsOnDPYMAS';
68
import { type SearchResultItemOperationalPoint } from 'common/api/osrdEditoastApi';
79
import useSearchOperationalPoint from 'common/Map/Search/useSearchOperationalPoint';
810
import { useOsrdConfActions } from 'common/osrdContext';
911
import type { StdcmConfSliceActions } from 'reducers/osrdconf/stdcmConf';
1012
import type { StdcmPathStep } from 'reducers/osrdconf/types';
13+
import { getIsOnlyStdcmProfile } from 'reducers/user/userSelectors';
1114
import { useAppDispatch } from 'store';
1215
import { normalized } from 'utils/strings';
1316
import { createFixedSelectOptions } from 'utils/uiCoreHelpers';
@@ -34,17 +37,27 @@ const StdcmOperationalPoint = ({ location, pathStepId, disabled }: StdcmOperatio
3437
initialChCodeFilter: location?.secondary_code,
3538
});
3639

40+
const isOnlyStdcmProfile = useSelector(getIsOnlyStdcmProfile);
41+
3742
const { updateStdcmPathStep } = useOsrdConfActions() as StdcmConfSliceActions;
3843

3944
const operationalPointsSuggestions = useMemo(
4045
() =>
4146
// Temporary filter added to show a more restrictive list of suggestions inside the stdcm app.
4247
sortedSearchResults
43-
.filter(
44-
(op) =>
45-
normalized(op.name).startsWith(normalized(searchTerm)) ||
46-
op.trigram === searchTerm.toUpperCase()
47-
)
48+
.filter((op) => {
49+
const isNameMatch = normalized(op.name).startsWith(normalized(searchTerm));
50+
const isTrigramMatch = op.trigram === searchTerm.toUpperCase();
51+
52+
if (isOnlyStdcmProfile) {
53+
return (
54+
CI_CH_OPERATIONAL_POINTS_ON_DPY_MAS[op.ci]?.includes(op.ch) &&
55+
(isNameMatch || isTrigramMatch)
56+
);
57+
}
58+
59+
return isNameMatch || isTrigramMatch;
60+
})
4861
.reduce((acc, p) => {
4962
const newObject = {
5063
label: [p.trigram, p.name].join(' '),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
type CiChOperationalPoints = {
2+
[key: string]: string[];
3+
};
4+
5+
const CI_CH_OPERATIONAL_POINTS_ON_DPY_MAS: CiChOperationalPoints = {
6+
'112136': ['00'],
7+
'140210': ['00'],
8+
'140228': ['00'],
9+
'140236': ['00'],
10+
'140244': ['00'],
11+
'140251': ['00'],
12+
'140269': ['00'],
13+
'140277': ['00'],
14+
'140285': ['00'],
15+
'144816': ['00'],
16+
'207779': ['00'],
17+
'352054': ['00'],
18+
'357178': ['00'],
19+
'441535': ['EP'],
20+
'556621': ['00'],
21+
'598482': ['00'],
22+
'712026': ['00'],
23+
'712604': ['00'],
24+
'712620': ['00'],
25+
'712679': ['00'],
26+
'713032': ['P1', 'P2', 'P3', 'P4'],
27+
'713040': ['AS', 'ES'],
28+
'713503': ['00'],
29+
'713511': ['BV'],
30+
'713529': ['00', '12', 'V9'],
31+
'713537': ['00'],
32+
'713545': ['00', 'EN'],
33+
'713560': ['00'],
34+
'713578': ['3E', 'BN', 'BS', 'BV'],
35+
'713586': ['00'],
36+
'713628': ['00'],
37+
'713636': ['00'],
38+
'713644': ['00'],
39+
'713651': ['BV'],
40+
'713669': ['00'],
41+
'713677': ['00'],
42+
'713693': ['00'],
43+
'713701': ['BV'],
44+
'713735': ['BV', 'EP'],
45+
'713867': ['ZI'],
46+
'713875': ['13', '3B', 'AT', 'BK', 'P2', 'P3', 'RA', 'RI', 'RO', 'RP'],
47+
'718296': ['BF', 'BV'],
48+
'721001': ['13', 'AN', 'AS', 'BV', 'FP', 'TU'],
49+
'721225': ['00'],
50+
'721241': ['00'],
51+
'721266': ['00'],
52+
'721282': ['BV', 'P1', 'P2', 'VG'],
53+
'721290': ['BV', 'KM', 'PK'],
54+
'721324': ['00'],
55+
'721332': ['BV', 'PK'],
56+
'721340': ['BV', 'PK'],
57+
'721357': ['00', 'V3'],
58+
'722009': ['21', 'AG'],
59+
'722025': ['BV', 'K1', 'PS'],
60+
'722207': ['00'],
61+
'722231': ['00'],
62+
'722249': ['00'],
63+
'722264': ['BV'],
64+
'722298': ['00'],
65+
'722306': ['P1', 'P2'],
66+
'722314': ['BV'],
67+
'722322': ['00'],
68+
'722348': ['00'],
69+
'722439': ['21', '25', 'BR', 'BV', 'KM'],
70+
'722520': ['BN', 'BS', 'FR', 'IT', 'NS', 'SN'],
71+
'722538': ['00'],
72+
'722546': ['00'],
73+
'722553': ['00'],
74+
'722561': ['BV', 'HA', 'P1'],
75+
'722579': ['BV', 'PK', 'UR'],
76+
'722587': ['BV', 'PU'],
77+
'722645': ['00'],
78+
'722652': ['00'],
79+
'722660': ['BV'],
80+
'722678': ['00'],
81+
'722686': ['00'],
82+
'723197': ['AN', 'AS', 'BF', 'BV', 'ES', 'G1', 'KN', 'KS', 'PO', 'SM'],
83+
'723254': ['00'],
84+
'723502': ['00'],
85+
'723528': ['00'],
86+
'723536': ['00'],
87+
'723544': ['BV'],
88+
'723551': ['00'],
89+
'723569': ['BV'],
90+
'723577': ['00'],
91+
'723585': ['00'],
92+
'725002': ['AS', 'BF', 'BV', 'FI', 'PA'],
93+
'725606': ['00'],
94+
'725614': ['00', 'AG', 'PV'],
95+
'725622': ['00', 'AG'],
96+
'725655': ['AG', 'BV', 'PV'],
97+
'725663': ['00'],
98+
'725671': ['00'],
99+
'725689': ['BF', 'BV', 'CH', 'FA', 'KM', 'PK', 'PV', 'RN', 'RS'],
100+
'725713': ['00'],
101+
'725721': ['00', 'V3', 'V4'],
102+
'725739': ['BV', 'PK'],
103+
'728006': ['27', '74', '7P', 'AG', 'CV', 'J1', 'KM', 'MT', 'P7', 'PO', 'SF', 'VI'],
104+
'728501': ['BV'],
105+
'742114': ['00'],
106+
'743005': ['BV', 'P1', 'P2'],
107+
'743104': ['BV'],
108+
'743112': ['00'],
109+
'743120': ['00'],
110+
'743146': ['BV', 'SM'],
111+
'743203': ['00'],
112+
'743211': ['00'],
113+
'743708': ['BV'],
114+
'743716': ['AG', 'AR', 'BV', 'EP', 'P1', 'P2', 'P5'],
115+
'753004': ['A2', 'AN', 'AT', 'BN', 'BV', 'DP', 'FD', 'FR', 'PC', 'RC', 'RL', 'SC'],
116+
'753657': ['BV'],
117+
'753681': ['00', '3G', 'KM'],
118+
'753707': ['00'],
119+
'753715': ['00'],
120+
'753731': ['00'],
121+
'753764': ['00'],
122+
'761007': ['BG', 'BP', 'BV', 'ES', 'IT', 'JO'],
123+
'761106': ['62', 'BN', 'BS', 'BV', 'NS'],
124+
'761122': ['BV'],
125+
'761130': ['00'],
126+
'761163': ['00'],
127+
'761189': ['BV'],
128+
'761205': ['AS', 'BV', 'P1', 'P2'],
129+
'761247': ['BS', 'BV', 'NS', 'RC'],
130+
'761262': ['00'],
131+
'761403': ['BV', 'CV', 'NS', 'P1', 'RN'],
132+
'761437': ['00'],
133+
'761460': ['BV', 'SG'],
134+
'761486': ['00'],
135+
'761494': ['00'],
136+
'761502': ['EP'],
137+
'761528': ['00'],
138+
'761544': ['BP', 'BT', 'NS', 'P1'],
139+
'764001': ['BV'],
140+
'764290': ['00'],
141+
'764308': ['BF', 'BV', 'RL'],
142+
'764357': ['00'],
143+
'764407': ['00'],
144+
'764449': ['BV'],
145+
'764472': ['AS', 'BV', 'PN'],
146+
'764506': ['EP'],
147+
'764522': ['BV', 'EP'],
148+
'764555': ['00'],
149+
'764571': ['BV', 'EP'],
150+
'764613': ['00'],
151+
'765008': ['BC', 'BR', 'BV'],
152+
'765024': ['A1', 'A2', 'P1', 'RP'],
153+
'765040': ['2T', 'BC', 'CF', 'DU', 'PC', 'UD', 'VC'],
154+
'765107': ['AS', 'BV', 'KP', 'PK', 'PR'],
155+
'765180': ['BV'],
156+
'765198': ['00'],
157+
'765206': ['00', '2B'],
158+
'765255': ['BV'],
159+
'765305': ['00'],
160+
'765339': ['00'],
161+
'765354': ['KP', 'PK', 'RN', 'RS', 'V4', 'V5'],
162+
'765412': ['00'],
163+
'765420': ['00'],
164+
'765438': ['00'],
165+
'765446': ['00'],
166+
'765453': ['00'],
167+
'765479': ['00'],
168+
'765503': ['BV', 'CB'],
169+
'765842': ['EP'],
170+
'765875': ['BR', 'BV', 'RN'],
171+
'021030': ['BV'],
172+
};
173+
174+
export default CI_CH_OPERATIONAL_POINTS_ON_DPY_MAS;

0 commit comments

Comments
 (0)