Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
anisometropie committed Sep 12, 2024
1 parent ba274bb commit dd6cf07
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const computeBasePathSteps = (trainSchedule: TrainScheduleResult) =>
...stepWithoutSecondaryCode,
ch: 'secondary_code' in step ? step.secondary_code : undefined,
name,
arrival,
arrival, // ISODurationString
stopFor: stopFor ? ISO8601Duration2sec(stopFor).toString() : stopFor,
locked,
onStopSignal,
Expand Down
12 changes: 6 additions & 6 deletions front/src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ export type TimeString = string;
*/
export type IsoDateTimeString = string;

export type RangedValue = {
begin: number;
end: number;
value: string;
};

/**
* A ISO 8601 duration string
* @example "PT3600S"
*/
export type IsoDurationString = string;

export type RangedValue = {
begin: number;
end: number;
value: string;
};
2 changes: 1 addition & 1 deletion front/src/modules/timesStops/ReadOnlyTime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { NO_BREAK_SPACE } from 'utils/strings';

import type { TimeExtraDays } from './types';

type ReadOnlyTimeProps = CellProps<TimeExtraDays | undefined | undefined, string>;
type ReadOnlyTimeProps = CellProps<TimeExtraDays | undefined, string>;

const ReadOnlyTime = ({ rowData }: ReadOnlyTimeProps) => {
const { t } = useTranslation('timesStops');
Expand Down
13 changes: 7 additions & 6 deletions front/src/modules/timesStops/TimesStops.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,13 @@ const TimesStops = ({
} else {
const newVias = updatedRows
.filter((row, index) => !isEqual(row, rows[index]))
.map((row) => {
return {
...row,
...(row.arrival && { arrival: durationSinceStartTime(startTime, row.arrival) }),
} as SuggestedOP;
});
.map(
(row) =>
({
...row,
...(row.arrival && { arrival: durationSinceStartTime(startTime, row.arrival) }),
}) as SuggestedOP
);
dispatch(upsertSeveralViasFromSuggestedOP(newVias));
}
}}
Expand Down
1 change: 1 addition & 0 deletions front/src/modules/timesStops/TimesStopsInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type TimesStopsInputProps = {
startTime: string;
pathSteps: PathStep[];
};

const TimesStopsinput = ({ allWaypoints, startTime, pathSteps }: TimesStopsInputProps) => {
const dispatch = useAppDispatch();
const { updatePathSteps } = useOsrdConfActions();
Expand Down
2 changes: 1 addition & 1 deletion front/src/modules/timesStops/TimesStopsOutput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const TimesStopsOutput = ({
tableType={TableType.Output}
cellClassName={({ rowData: rowData_ }) => {
const rowData = rowData_ as PathWaypointRow;
const arrivalScheduleNotRespected = rowData?.arrival?.time
const arrivalScheduleNotRespected = rowData.arrival?.time
? rowData.calculatedArrival !== rowData.arrival.time
: false;
const negativeDiffMargins = Number(rowData.diffMargins?.split(NO_BREAK_SPACE)[0]) < 0;
Expand Down
7 changes: 4 additions & 3 deletions front/src/modules/timesStops/types.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import type { TrainScheduleBase, TrainScheduleResult } from 'common/api/osrdEditoastApi';
import type { TimeString } from 'common/types';
import type { SuggestedOP } from 'modules/trainschedule/components/ManageTrainSchedule/types';
import type { ArrayElement } from 'utils/types';

export type TimeExtraDays = {
time: string | null | undefined;
time: TimeString | null | undefined;
daySinceDeparture?: number;
dayDisplayed?: boolean;
};

export type PathWaypointRow = Omit<SuggestedOP, 'arrival' | 'departure'> & {
isMarginValid: boolean;
arrival?: TimeExtraDays | undefined; // value asked by user
departure?: TimeExtraDays | undefined; // value asked by user
arrival?: TimeExtraDays; // value asked by user
departure?: TimeExtraDays; // value asked by user
};

export enum TableType {
Expand Down
6 changes: 3 additions & 3 deletions front/src/reducers/osrdconf/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@ export const updateDestinationPathStep = (
) => updatePathStepAtIndex(pathSteps, pathSteps.length - 1, destination, replaceCompletely);

/**
* modifies the array statePathSteps in place
* Modifies the array statePathSteps in place in the reducer
*/
export function upsertPathStep(statePathSteps: (PathStep | null)[], op: SuggestedOP) {
// We know that, at this point, origin and destination are defined because pathfinding has been done
const cleanPathSteps = compact(statePathSteps);

let newVia = {
let newVia: PathStep = {
...pick(op, [
'coordinates',
'positionOnPath',
Expand All @@ -174,7 +174,7 @@ export function upsertPathStep(statePathSteps: (PathStep | null)[], op: Suggeste
track: op.track,
offset: op.offsetOnTrack,
}),
} as PathStep;
};

const stepIndex = cleanPathSteps.findIndex((step) => pathStepMatchesOp(step, op));
if (stepIndex >= 0) {
Expand Down

0 comments on commit dd6cf07

Please sign in to comment.