Skip to content

Commit

Permalink
lmr: putting ma100 as default value only for lmr
Browse files Browse the repository at this point in the history
Signed-off-by: Mathieu <[email protected]>
  • Loading branch information
Caracol3 committed Dec 13, 2024
1 parent 9e6a940 commit 5ea2d08
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions front/src/applications/stdcm/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ export const COMPOSITION_CODES = [
'MV160',
'MVGV',
];

export const DEFAULT_COMPOSITION_CODE = 'MA100';
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export default function SpeedLimitByTagSelector({
id="speed-limit-by-tag-selector"
value={speedLimitByTag || ''}
label={t('speedLimitByTagAbbrev')}
placeholder={t('noSpeedLimitByTag')}
onChange={(e) => {
if (e) {
dispatchUpdateSpeedLimitByTag(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { compact, concat, uniq } from 'lodash';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';

import { COMPOSITION_CODES } from 'applications/stdcm/consts';
import { COMPOSITION_CODES, DEFAULT_COMPOSITION_CODE } from 'applications/stdcm/consts';
import { osrdEditoastApi } from 'common/api/osrdEditoastApi';
import { useOsrdConfSelectors, useOsrdConfActions, useInfraID } from 'common/osrdContext';
import { setFailure } from 'reducers/main';
Expand Down Expand Up @@ -45,6 +45,12 @@ export const useStoreDataForSpeedLimitByTagSelector = ({ isStdcm } = { isStdcm:
}
}, [error]);

useEffect(() => {
if (isStdcm && !speedLimitByTag) {
dispatchUpdateSpeedLimitByTag(DEFAULT_COMPOSITION_CODE);
}
}, [isStdcm, speedLimitByTag, dispatchUpdateSpeedLimitByTag]);

const speedLimitsByTags = isStdcm
? COMPOSITION_CODES
: compact(uniq(concat(speedLimitTags, speedLimitsTagsByInfraId)));
Expand Down

0 comments on commit 5ea2d08

Please sign in to comment.