Skip to content

Commit

Permalink
front: remove pathTrackRanges from stdcmResults props
Browse files Browse the repository at this point in the history
Signed-off-by: Clara Ni <clara.ni@outlook.fr>
  • Loading branch information
clarani committed Jan 17, 2025
1 parent bcb1ee0 commit c586622
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { useSelector } from 'react-redux';

import { STDCM_TRAIN_ID } from 'applications/stdcm/consts';
import useProjectedTrainsForStdcm from 'applications/stdcm/hooks/useProjectedTrainsForStdcm';
import type { StdcmResultsOutput } from 'applications/stdcm/types';
import { osrdEditoastApi, type TrackRange } from 'common/api/osrdEditoastApi';
import type { StdcmSimulationOutputs } from 'applications/stdcm/types';
import { hasResults } from 'applications/stdcm/utils/simulationOutputUtils';
import { osrdEditoastApi } from 'common/api/osrdEditoastApi';
import { useOsrdConfSelectors } from 'common/osrdContext';
import ResizableSection from 'common/ResizableSection';
import i18n from 'i18n';
Expand All @@ -20,16 +21,13 @@ const HANDLE_TAB_RESIZE_HEIGHT = 20;
const MANCHETTE_HEIGHT_DIFF = 100;

type StdcmDebugResultsProps = {
pathTrackRanges: TrackRange[];
simulationOutputs: StdcmResultsOutput;
simulationOutputs?: StdcmSimulationOutputs;
};

const StdcmDebugResults = ({
pathTrackRanges,
simulationOutputs: { pathProperties, results, speedSpaceChartData },
}: StdcmDebugResultsProps) => {
const StdcmDebugResults = ({ simulationOutputs }: StdcmDebugResultsProps) => {
const { getWorkScheduleGroupId } = useOsrdConfSelectors() as StdcmConfSelectors;
const workScheduleGroupId = useSelector(getWorkScheduleGroupId);
const successfulSimulation = hasResults(simulationOutputs) ? simulationOutputs : undefined;

const [speedSpaceChartContainerHeight, setSpeedSpaceChartContainerHeight] =
useState(SPEED_SPACE_CHART_HEIGHT);
Expand All @@ -39,18 +37,21 @@ const StdcmDebugResults = ({
MANCHETTE_WITH_SPACE_TIME_CHART_DEFAULT_HEIGHT
);

const projectedData = useProjectedTrainsForStdcm(results);
const projectedData = useProjectedTrainsForStdcm(successfulSimulation?.results);

const { data: workSchedules } = osrdEditoastApi.endpoints.postWorkSchedulesProjectPath.useQuery(
{
body: {
path_track_ranges: pathTrackRanges,
path_track_ranges: successfulSimulation?.results.path.track_section_ranges || [],
work_schedule_group_id: workScheduleGroupId!,
},
},
{ skip: !workScheduleGroupId }
{ skip: !workScheduleGroupId || !successfulSimulation }
);

if (!successfulSimulation) return null;
const { pathProperties, results, speedSpaceChartData } = successfulSimulation;

return (
<>
{projectedData &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
getOperationalPointsWithTimes,
} from 'applications/stdcm/utils/formatSimulationReportSheet';
import { hasConflicts, hasResults } from 'applications/stdcm/utils/simulationOutputUtils';
import { type TrackRange } from 'common/api/osrdEditoastApi';
import NewMap from 'modules/trainschedule/components/ManageTrainSchedule/NewMap';
import useDeploymentSettings from 'utils/hooks/useDeploymentSettings';

Expand All @@ -33,7 +32,6 @@ type StcdmResultsProps = {
selectedSimulationIndex: number;
showStatusBanner: boolean;
simulationsList: StdcmSimulation[];
pathTrackRanges?: TrackRange[];
};

const StcdmResults = ({
Expand All @@ -48,7 +46,6 @@ const StcdmResults = ({
selectedSimulationIndex,
showStatusBanner,
simulationsList,
pathTrackRanges,
}: StcdmResultsProps) => {
const { t } = useTranslation('stdcm', { keyPrefix: 'simulation.results' });
const { stdcmName } = useDeploymentSettings();
Expand Down Expand Up @@ -188,9 +185,7 @@ const StcdmResults = ({
/>
</div>
</div>
{isDebugMode && pathTrackRanges && hasSimulationResults && (
<StdcmDebugResults pathTrackRanges={pathTrackRanges} simulationOutputs={outputs} />
)}
{isDebugMode && <StdcmDebugResults simulationOutputs={outputs} />}
</>
);
};
Expand Down
1 change: 0 additions & 1 deletion front/src/applications/stdcm/views/StdcmView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ const StdcmView = () => {
selectedSimulationIndex={selectedSimulationIndex}
showStatusBanner={showStatusBanner}
simulationsList={simulationsList}
pathTrackRanges={stdcmResults?.stdcmResponse.path.track_section_ranges}
/>
)}
</div>
Expand Down

0 comments on commit c586622

Please sign in to comment.