Skip to content

Commit 240cc12

Browse files
committed
fixup! front: add input data only mode for space time chart
1 parent dc191d6 commit 240cc12

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

front/src/modules/simulationResult/components/SpaceTimeChartWrapper/SettingsPanel.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { X } from '@osrd-project/ui-icons';
55
import { useTranslation } from 'react-i18next';
66
import { useSelector } from 'react-redux';
77

8-
import { updateProjectionType, updateUseSimulation } from 'reducers/simulationResults';
8+
import { toggleUseSimulation, updateProjectionType } from 'reducers/simulationResults';
99
import { getProjectionType, getUseSimulation } from 'reducers/simulationResults/selectors';
1010
import type { ProjectionType } from 'reducers/simulationResults/types';
1111
import { useAppDispatch } from 'store';
@@ -37,15 +37,8 @@ const SettingsPanel = ({
3737
onChange({ ...settings, [key]: event.target.checked });
3838
};
3939

40-
const handleUseSimulationChange = (event: ChangeEvent<HTMLInputElement>) => {
41-
// When checkbox is checked, "Input data only" is enabled, so useSimulation should be false
42-
const shouldUseSimulation = !event.target.checked;
43-
dispatch(updateUseSimulation(shouldUseSimulation));
44-
45-
// When switching to input mode, force interPR projection
46-
if (!shouldUseSimulation && projectionType !== 'operationalPointProjection') {
47-
dispatch(updateProjectionType('operationalPointProjection'));
48-
}
40+
const handleUseSimulationChange = () => {
41+
dispatch(toggleUseSimulation());
4942
};
5043

5144
return (

front/src/reducers/simulationResults/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ export const simulationResultsSlice = createSlice({
3939
) {
4040
state.projectionType = action.payload;
4141
},
42-
updateUseSimulation(state: Draft<SimulationResultsState>, action: PayloadAction<boolean>) {
43-
state.useSimulation = action.payload;
42+
toggleUseSimulation(state: Draft<SimulationResultsState>) {
43+
state.useSimulation = !state.useSimulation;
4444
// When switching to input mode, force interPR projection
45-
if (!action.payload) {
45+
if (!state.useSimulation) {
4646
state.projectionType = 'operationalPointProjection';
4747
}
4848
},
@@ -88,10 +88,10 @@ export const simulationResultsSlice = createSlice({
8888

8989
export const {
9090
toggleDisplayOnlyPathSteps,
91+
toggleUseSimulation,
9192
updateSelectedTrainId,
9293
updateTrainIdUsedForProjection,
9394
updateProjectionType,
94-
updateUseSimulation,
9595
unsetTrainIdsMatching,
9696
unsetTrainIdsMatchingMissingOccurencesOf,
9797
} = simulationResultsSlice.actions;

0 commit comments

Comments
 (0)