Skip to content

Commit

Permalink
fix clara
Browse files Browse the repository at this point in the history
  • Loading branch information
SarahBellaha committed Dec 2, 2024
1 parent 5b48a87 commit 073b940
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 33 deletions.
2 changes: 0 additions & 2 deletions front/public/locales/fr/stdcm.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
"invalidDate": "Renseignez une date entre le {{startDate}} et le {{endDate}}"
}
},
"indicateAnteriorPath": "Indiquer le sillon antérieur",
"indicatePosteriorPath": "Indiquer le sillon postérieur",
"leaveAt": "Partir à {{ time }}",
"linkedTrainDefaultCard": {
"anterior": "Indiquer le sillon antérieur",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const StdcmLinkedTrainResults = ({
linkedOp: { extremityType, id },
}: StdcmLinkedTrainResultsProps) => {
const dispatch = useDispatch();
const { updateLinkedPathStep } = useOsrdConfActions() as StdcmConfSliceActions;
const { updateLinkedTrainExtremity } = useOsrdConfActions() as StdcmConfSliceActions;
return (
<div className="stdcm-linked-train-results">
{linkedTrainResults.map(({ trainName, origin, destination }, index) => (
Expand All @@ -29,8 +29,8 @@ const StdcmLinkedTrainResults = ({
onClick={() => {
if (linkedTrainResults.length === 1)
dispatch(
updateLinkedPathStep({
linkedPathStep: extremityType,
updateLinkedTrainExtremity({
linkedTrainExtremity: extremityType,
trainName,
pathStep: linkedTrainResults[0][extremityType],
pathStepId: id,
Expand All @@ -47,8 +47,8 @@ const StdcmLinkedTrainResults = ({
onClick={({ target }) => {
const resultIndex = Number((target as HTMLInputElement).value);
dispatch(
updateLinkedPathStep({
linkedPathStep: extremityType,
updateLinkedTrainExtremity({
linkedTrainExtremity: extremityType,
trainName,
pathStep: linkedTrainResults[resultIndex][extremityType],
pathStepId: id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const SimulationReportSheet = ({
let renderedIndex = 0;

const { rollingStock, speedLimitByTag, departure_time: departureTime, creationDate } = stdcmData;
const { anteriorPath, posteriorPath } = stdcmLinkedTrains;
const { anteriorTrain, posteriorTrain } = stdcmLinkedTrains;

const convoyMass = consist?.totalMass ?? rollingStock.mass / 1000;
const convoyLength = consist?.totalLength ?? rollingStock.length;
Expand Down Expand Up @@ -161,11 +161,11 @@ const SimulationReportSheet = ({
<Text style={styles.convoyAndRoute.from}>{t('from')}</Text>
</View>
<Text style={styles.convoyAndRoute.fromNumber}>
{anteriorPath?.trainName || fakeInformation.path_number1}
{anteriorTrain?.trainName || fakeInformation.path_number1}
</Text>
<Text style={styles.convoyAndRoute.fromScheduled}>
{anteriorPath &&
t('scheduledArrival', { date: anteriorPath.date, time: anteriorPath.time })}
{anteriorTrain &&
t('scheduledArrival', { date: anteriorTrain.date, time: anteriorTrain.time })}
</Text>
</View>
<View style={styles.convoyAndRoute.stopTableContainer}>
Expand Down Expand Up @@ -236,11 +236,11 @@ const SimulationReportSheet = ({
{/* TODO: Add path number and date from reference path when it becomes avalaible */}
<View style={styles.convoyAndRoute.forBanner}>
<Text style={styles.convoyAndRoute.forScheduled}>
{posteriorPath &&
t('scheduledDeparture', { date: posteriorPath.date, time: posteriorPath.time })}
{posteriorTrain &&
t('scheduledDeparture', { date: posteriorTrain.date, time: posteriorTrain.time })}
</Text>
<Text style={styles.convoyAndRoute.forNumber}>
{posteriorPath?.trainName || fakeInformation.path_number2}
{posteriorTrain?.trainName || fakeInformation.path_number2}
</Text>
<View style={styles.convoyAndRoute.forBox}>
<Text style={styles.convoyAndRoute.for}>{t('for')}</Text>
Expand Down
9 changes: 6 additions & 3 deletions front/src/applications/stdcm/hooks/useLinkedTrainSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { osrdEditoastApi } from 'common/api/osrdEditoastApi';
import { useOsrdConfSelectors } from 'common/osrdContext';
import { isEqualDate } from 'utils/date';

import type { StdcmLinkedTrainResult, StdcmLinkedPathStep } from '../types';
import type { StdcmLinkedTrainResult, StdcmLinkedTrainExtremity } from '../types';
import computeOpSchedules from '../utils/computeOpSchedules';

const useLinkedTrainSearch = () => {
Expand Down Expand Up @@ -96,11 +96,14 @@ const useLinkedTrainSearch = () => {
if (opDetails === undefined) return undefined;
return {
trainName: result.train_name,
origin: { ...opDetails.origin, ...computedOpSchedules.origin } as StdcmLinkedPathStep,
origin: {
...opDetails.origin,
...computedOpSchedules.origin,
} as StdcmLinkedTrainExtremity,
destination: {
...opDetails.destination,
...computedOpSchedules.destination,
} as StdcmLinkedPathStep,
} as StdcmLinkedTrainExtremity,
};
})
);
Expand Down
10 changes: 5 additions & 5 deletions front/src/applications/stdcm/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ export type StdcmResults = {
};

export type LinkedTrains = {
anteriorPath?: {
anteriorTrain?: {
date: string;
time: string;
trainName: string;
};
posteriorPath?: {
posteriorTrain?: {
date: string;
time: string;
trainName: string;
Expand Down Expand Up @@ -181,7 +181,7 @@ export enum StdcmStopTypes {
SERVICE_STOP = 'serviceStop',
}

export type StdcmLinkedPathStep = {
export type StdcmLinkedTrainExtremity = {
ch: string;
date: string;
geographic: GeoJsonPoint;
Expand All @@ -194,8 +194,8 @@ export type StdcmLinkedPathStep = {
};

export type StdcmLinkedTrainResult = {
destination: StdcmLinkedPathStep;
origin: StdcmLinkedPathStep;
destination: StdcmLinkedTrainExtremity;
origin: StdcmLinkedTrainExtremity;
trainName: string;
};

Expand Down
22 changes: 11 additions & 11 deletions front/src/reducers/osrdconf/stdcmConf/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ArrivalTimeTypes,
StdcmStopTypes,
type ExtremityPathStepType,
type StdcmLinkedPathStep,
type StdcmLinkedTrainExtremity,
} from 'applications/stdcm/types';
import { defaultCommonConf, buildCommonConfReducers } from 'reducers/osrdconf/osrdConfCommon';
import type { OsrdStdcmConfState, StdcmPathStep } from 'reducers/osrdconf/types';
Expand All @@ -25,8 +25,8 @@ export const stdcmConfInitialState: OsrdStdcmConfState = {
maxSpeed: undefined,
towedRollingStockID: undefined,
linkedTrains: {
anteriorPath: undefined,
posteriorPath: undefined,
anteriorTrain: undefined,
posteriorTrain: undefined,
},
...defaultCommonConf,
};
Expand Down Expand Up @@ -153,16 +153,16 @@ export const stdcmConfSlice = createSlice({
(pathStep) => pathStep.id !== action.payload
);
},
updateLinkedPathStep(
updateLinkedTrainExtremity(
state: Draft<OsrdStdcmConfState>,
action: PayloadAction<{
linkedPathStep: ExtremityPathStepType;
linkedTrainExtremity: ExtremityPathStepType;
trainName: string;
pathStep: StdcmLinkedPathStep;
pathStep: StdcmLinkedTrainExtremity;
pathStepId: string;
}>
) {
const { linkedPathStep, trainName, pathStep, pathStepId } = action.payload;
const { linkedTrainExtremity, trainName, pathStep, pathStepId } = action.payload;
const { name, ch, uic, geographic, isoArrivalTime, date, time, trigram } = pathStep;
const newPathStep = {
name,
Expand All @@ -172,15 +172,15 @@ export const stdcmConfSlice = createSlice({
coordinates: geographic.coordinates,
arrival: isoArrivalTime,
trigram,
...(linkedPathStep === 'origin' && { arrivalType: ArrivalTimeTypes.PRECISE_TIME }),
...(linkedTrainExtremity === 'origin' && { arrivalType: ArrivalTimeTypes.PRECISE_TIME }),
};

const newLinkedTrain = { date, time, trainName };

if (linkedPathStep === 'destination') {
state.linkedTrains.anteriorPath = newLinkedTrain;
if (linkedTrainExtremity === 'destination') {
state.linkedTrains.anteriorTrain = newLinkedTrain;
} else {
state.linkedTrains.posteriorPath = newLinkedTrain;
state.linkedTrains.posteriorTrain = newLinkedTrain;
}
const newPathSteps = state.stdcmPathSteps.map((step) =>
step.id === action.payload.pathStepId
Expand Down

0 comments on commit 073b940

Please sign in to comment.