Skip to content

Commit

Permalink
front: display correct ch code after linked train selection
Browse files Browse the repository at this point in the history
Signed-off-by: SarahBellaha <[email protected]>
  • Loading branch information
SarahBellaha committed Jan 7, 2025
1 parent 2c4aca1 commit a465be7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const StdcmOperationalPoint = ({ location, pathStepId, disabled }: StdcmOperatio
const { t } = useTranslation('stdcm');
const dispatch = useAppDispatch();

const { searchTerm, chCodeFilter, sortedSearchResults, setSearchTerm, setChCodeFilter } =
const { searchTerm, sortedSearchResults, setSearchTerm, setChCodeFilter } =
useSearchOperationalPoint({
initialSearchTerm: location?.name,
initialChCodeFilter: location?.secondary_code,
Expand Down Expand Up @@ -61,7 +61,7 @@ const StdcmOperationalPoint = ({ location, pathStepId, disabled }: StdcmOperatio
const sortedChOptions = useMemo(
() =>
sortedSearchResults
.filter((pr) => pr.name === searchTerm)
.filter((pr) => (location ? pr.name === location.name : pr.name === searchTerm))
.reduce(
(acc, pr) => {
const newObject = {
Expand Down Expand Up @@ -155,7 +155,11 @@ const StdcmOperationalPoint = ({ location, pathStepId, disabled }: StdcmOperatio
<Select
label={t('trainPath.ch')}
id={`${pathStepId}-ch`}
value={chCodeFilter ? { label: formatChCode(chCodeFilter), id: chCodeFilter } : undefined}
value={
location
? { label: formatChCode(location.secondary_code), id: location.secondary_code }
: undefined
}
onChange={(e) => onSelectChCodeFilter(e)}
{...createFixedSelectOptions(sortedChOptions)}
disabled={disabled}
Expand Down
5 changes: 1 addition & 4 deletions front/src/reducers/osrdconf/stdcmConf/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,8 @@ export const stdcmConfSlice = createSlice({
const { name, ch, uic, geographic, arrivalDate, date, time } = pathStep;

const newPathStep = {
name,
ch,
location: { name, coordinates: geographic.coordinates, uic, secondary_code: ch },
id: pathStepId,
uic,
coordinates: geographic.coordinates,
arrival: arrivalDate,
...(linkedTrainExtremity === 'origin' && { arrivalType: ArrivalTimeTypes.PRECISE_TIME }),
};
Expand Down

0 comments on commit a465be7

Please sign in to comment.