Skip to content

Commit

Permalink
lmr: putting ma100 as default value in the speedlimittag selector
Browse files Browse the repository at this point in the history
Signed-off-by: Mathieu <[email protected]>
  • Loading branch information
Caracol3 committed Dec 10, 2024
1 parent 950c4ac commit 1c3dbc1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 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
@@ -1,11 +1,12 @@
import { useMemo } from 'react';
import { useEffect, useMemo } from 'react';

import { Select } from '@osrd-project/ui-core';
import cx from 'classnames';
import { isEmpty } from 'lodash';
import { useTranslation } from 'react-i18next';

import { createStringSelectOptions } from 'utils/uiCoreHelpers';
import { DEFAULT_COMPOSITION_CODE } from 'applications/stdcm/consts';

type SpeedLimitByTagSelectorProps = {
condensed?: boolean;
Expand All @@ -26,6 +27,12 @@ export default function SpeedLimitByTagSelector({
}: SpeedLimitByTagSelectorProps) {
const { t } = useTranslation(['operationalStudies/manageTrainSchedule']);

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

const speedLimitsTagsList = useMemo(
() => (!isEmpty(speedLimitsByTags) ? speedLimitsByTags : []),
[speedLimitsByTags]
Expand All @@ -46,9 +53,8 @@ export default function SpeedLimitByTagSelector({
<Select
disabled={disabled}
id="speed-limit-by-tag-selector"
value={speedLimitByTag || ''}
value={speedLimitByTag || DEFAULT_COMPOSITION_CODE}
label={t('speedLimitByTagAbbrev')}
placeholder={t('noSpeedLimitByTag')}
onChange={(e) => {
if (e) {
dispatchUpdateSpeedLimitByTag(e);
Expand Down

0 comments on commit 1c3dbc1

Please sign in to comment.