Skip to content

Commit ae2b391

Browse files
kmer2016SharglutDev
authored andcommitted
front: refacto. rename selector and variable to clarify stdcm roles check
Signed-off-by: nncluzu <[email protected]>
1 parent 635e088 commit ae2b391

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import useSearchOperationalPoint from 'common/Map/Search/useSearchOperationalPoi
1010
import { useOsrdConfActions } from 'common/osrdContext';
1111
import type { StdcmConfSliceActions } from 'reducers/osrdconf/stdcmConf';
1212
import type { StdcmPathStep } from 'reducers/osrdconf/types';
13-
import { getIsOnlyStdcmProfile } from 'reducers/user/userSelectors';
13+
import { userHasOnlyStdcmRoles } from 'reducers/user/userSelectors';
1414
import { useAppDispatch } from 'store';
1515
import { normalized } from 'utils/strings';
1616
import { createFixedSelectOptions } from 'utils/uiCoreHelpers';
@@ -37,7 +37,7 @@ const StdcmOperationalPoint = ({ location, pathStepId, disabled }: StdcmOperatio
3737
initialChCodeFilter: location?.secondary_code,
3838
});
3939

40-
const isOnlyStdcmProfile = useSelector(getIsOnlyStdcmProfile);
40+
const hasOnlyStdcmRoles = useSelector(userHasOnlyStdcmRoles);
4141

4242
const { updateStdcmPathStep } = useOsrdConfActions() as StdcmConfSliceActions;
4343

@@ -49,7 +49,7 @@ const StdcmOperationalPoint = ({ location, pathStepId, disabled }: StdcmOperatio
4949
const isNameMatch = normalized(op.name).startsWith(normalized(searchTerm));
5050
const isTrigramMatch = op.trigram === searchTerm.toUpperCase();
5151

52-
if (isOnlyStdcmProfile) {
52+
if (hasOnlyStdcmRoles) {
5353
return (
5454
CI_CH_OPERATIONAL_POINTS_ON_DPY_MAS[op.ci]?.includes(op.ch) &&
5555
(isNameMatch || isTrigramMatch)

front/src/common/authorization/components/InitialRedirect.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { useSelector } from 'react-redux';
22
import { Navigate } from 'react-router-dom';
33

44
import Home from 'main/home';
5-
import { getIsOnlyStdcmProfile } from 'reducers/user/userSelectors';
5+
import { userHasOnlyStdcmRoles } from 'reducers/user/userSelectors';
66

77
const InitialRedirect = () => {
8-
const isOnlyStdcmProfile = useSelector(getIsOnlyStdcmProfile);
8+
const hasOnlyStdcmRoles = useSelector(userHasOnlyStdcmRoles);
99

10-
return isOnlyStdcmProfile ? <Navigate to="stdcm" /> : <Home />;
10+
return hasOnlyStdcmRoles ? <Navigate to="stdcm" /> : <Home />;
1111
};
1212

1313
export default InitialRedirect;

front/src/reducers/user/userSelectors.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const makeUserHasAllRequiredRolesSelector =
2121
const userRoles = getUserRoles(state);
2222
return requiredRoles.every((role) => userRoles.includes(role));
2323
};
24-
export const getIsOnlyStdcmProfile = (state: RootState) => {
24+
export const userHasOnlyStdcmRoles = (state: RootState) => {
2525
const userRoles = getUserRoles(state);
2626
return (
2727
userRoles.length === REQUIRED_USER_ROLES_FOR.USER_PROFILE.STDCM.length &&

0 commit comments

Comments
 (0)