File tree Expand file tree Collapse file tree 2 files changed +7
-14
lines changed
modules/simulationResult/components/SpaceTimeChartWrapper
reducers/simulationResults Expand file tree Collapse file tree 2 files changed +7
-14
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import { X } from '@osrd-project/ui-icons';
55import { useTranslation } from 'react-i18next' ;
66import { useSelector } from 'react-redux' ;
77
8- import { updateProjectionType , updateUseSimulation } from 'reducers/simulationResults' ;
8+ import { toggleUseSimulation , updateProjectionType } from 'reducers/simulationResults' ;
99import { getProjectionType , getUseSimulation } from 'reducers/simulationResults/selectors' ;
1010import type { ProjectionType } from 'reducers/simulationResults/types' ;
1111import { 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 (
Original file line number Diff line number Diff 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
8989export const {
9090 toggleDisplayOnlyPathSteps,
91+ toggleUseSimulation,
9192 updateSelectedTrainId,
9293 updateTrainIdUsedForProjection,
9394 updateProjectionType,
94- updateUseSimulation,
9595 unsetTrainIdsMatching,
9696 unsetTrainIdsMatchingMissingOccurencesOf,
9797} = simulationResultsSlice . actions ;
You can’t perform that action at this time.
0 commit comments