Skip to content

Commit

Permalink
front: remove some conditions in SimulationResults
Browse files Browse the repository at this point in the history
- Removed the first condition trainSimulation.status === 'success' to allow the user to see the SpaceTimeChart even if the current selected train is invalid.
- Removed not needed condition on pathproperties to display the spacetimechart

Signed-off-by: Clara Ni <clara.ni@outlook.fr>
  • Loading branch information
clarani committed Dec 5, 2024
1 parent 418d712 commit d6b49dd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ const SimulationResults = ({
}
}, [extViewport]);

if (!trainSimulation) return null;

if (trainSimulation.status !== 'success') return null;

return (
<div className="simulation-results">
{/* SIMULATION : STICKY BAR */}
Expand Down Expand Up @@ -150,7 +146,7 @@ const SimulationResults = ({
className="simulation-warped-map d-flex flex-row align-items-stretch mb-2"
style={{ height: manchetteWithSpaceTimeChartHeight }}
>
{projectionData && projectionData.projectedTrains.length > 0 && pathProperties && (
{projectionData && projectionData.projectedTrains.length > 0 && (
<>
<button
type="button"
Expand Down
4 changes: 2 additions & 2 deletions front/src/modules/timesStops/TimesStopsOutput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import TimesStops from './TimesStops';
import { TableType, type TimesStopsRow } from './types';

type TimesStopsOutputProps = {
simulatedTrain: SimulationResponseSuccess;
simulatedTrain?: SimulationResponseSuccess;
trainSummary?: TrainScheduleWithDetails;
operationalPoints?: PathPropertiesFormatted['operationalPoints'];
selectedTrainSchedule?: TrainScheduleResult;
Expand All @@ -30,7 +30,7 @@ const TimesStopsOutput = ({
dataIsLoading,
}: TimesStopsOutputProps) => {
const enrichedOperationalPoints = useOutputTableData(
simulatedTrain,
simulatedTrain?.final_output,
trainSummary,
operationalPoints,
selectedTrainSchedule,
Expand Down
4 changes: 2 additions & 2 deletions front/src/modules/timesStops/hooks/useOutputTableData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { formatSchedule } from '../helpers/scheduleData';
import { type ScheduleEntry, type TimesStopsRow } from '../types';

const useOutputTableData = (
{ final_output: simulatedTrain }: SimulationResponseSuccess,
simulatedTrain?: SimulationResponseSuccess['final_output'],
trainSummary?: TrainScheduleWithDetails,
operationalPoints?: PathPropertiesFormatted['operationalPoints'],
selectedTrainSchedule?: TrainScheduleResult,
Expand Down Expand Up @@ -109,7 +109,7 @@ const useOutputTableData = (

useEffect(() => {
const formatRows = async () => {
if (!operationalPoints || !startDatetime) {
if (!operationalPoints || !startDatetime || !simulatedTrain) {
setRows([]);
return;
}
Expand Down

0 comments on commit d6b49dd

Please sign in to comment.