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 9, 2024
1 parent 8f6131e commit b76e9d1
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMemo } from 'react';
import { useEffect, useMemo } from 'react';

import { Select } from '@osrd-project/ui-core';
import cx from 'classnames';
Expand All @@ -25,6 +25,13 @@ export default function SpeedLimitByTagSelector({
className = '',
}: SpeedLimitByTagSelectorProps) {
const { t } = useTranslation(['operationalStudies/manageTrainSchedule']);
const defaultTag = 'MA100';

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

const speedLimitsTagsList = useMemo(
() => (!isEmpty(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 || defaultTag}
label={t('speedLimitByTagAbbrev')}
placeholder={t('noSpeedLimitByTag')}
onChange={(e) => {
if (e) {
dispatchUpdateSpeedLimitByTag(e);
Expand Down

0 comments on commit b76e9d1

Please sign in to comment.