Skip to content

Commit

Permalink
front: set default tolerances in the store
Browse files Browse the repository at this point in the history
Signed-off-by: Clara Ni <[email protected]>
  • Loading branch information
clarani committed Dec 9, 2024
1 parent 9c34c10 commit 0f5f813
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { extractDateAndTimefromISO, generateISODateFromDateTime } from 'utils/da
import StdcmCard from './StdcmCard';
import StdcmOperationalPoint from './StdcmOperationalPoint';
import StdcmOpSchedule from './StdcmOpSchedule';
import { DEFAULT_TOLERANCE } from '../../consts';
import type { ArrivalTimeTypes, ScheduleConstraint, StdcmConfigCardProps } from '../../types';

const StdcmDestination = ({ disabled = false }: StdcmConfigCardProps) => {
Expand All @@ -32,14 +31,8 @@ const StdcmDestination = ({ disabled = false }: StdcmConfigCardProps) => {
? extractDateAndTimefromISO(destination.arrival)
: undefined,
destinationToleranceValues: {
arrivalToleranceBefore:
destination.tolerances?.before !== undefined
? destination.tolerances.before
: DEFAULT_TOLERANCE,
arrivalToleranceAfter:
destination.tolerances?.after !== undefined
? destination.tolerances.after
: DEFAULT_TOLERANCE,
arrivalToleranceBefore: destination.tolerances!.before,
arrivalToleranceAfter: destination.tolerances!.after,
},
}),
[destination]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { extractDateAndTimefromISO, generateISODateFromDateTime } from 'utils/da
import StdcmCard from './StdcmCard';
import StdcmOperationalPoint from './StdcmOperationalPoint';
import StdcmOpSchedule from './StdcmOpSchedule';
import { DEFAULT_TOLERANCE } from '../../consts';
import type { ArrivalTimeTypes, ScheduleConstraint, StdcmConfigCardProps } from '../../types';

const StdcmOrigin = ({ disabled = false }: StdcmConfigCardProps) => {
Expand All @@ -29,10 +28,8 @@ const StdcmOrigin = ({ disabled = false }: StdcmConfigCardProps) => {
() => ({
originArrival: origin.arrival ? extractDateAndTimefromISO(origin.arrival) : undefined,
originToleranceValues: {
arrivalToleranceBefore:
origin.tolerances?.before !== undefined ? origin.tolerances.before : DEFAULT_TOLERANCE,
arrivalToleranceAfter:
origin.tolerances?.after !== undefined ? origin.tolerances.after : DEFAULT_TOLERANCE,
arrivalToleranceBefore: origin.tolerances!.before,
arrivalToleranceAfter: origin.tolerances!.after,
},
}),
[origin]
Expand Down
2 changes: 0 additions & 2 deletions front/src/applications/stdcm/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ export const COMPOSITION_CODES = [
'MV160',
'MVGV',
];

export const DEFAULT_TOLERANCE = 1800; // 30min
18 changes: 16 additions & 2 deletions front/src/reducers/osrdconf/stdcmConf/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,25 @@ import type { OsrdStdcmConfState, StdcmPathStep } from 'reducers/osrdconf/types'
import { addElementAtIndex } from 'utils/array';
import type { ArrayElement } from 'utils/types';

const DEFAULT_TOLERANCE = 1800; // 30min

export const stdcmConfInitialState: OsrdStdcmConfState = {
// TODO: remove all the default uic values
stdcmPathSteps: [
{ id: nextId(), uic: -1, isVia: false, arrivalType: ArrivalTimeTypes.PRECISE_TIME },
{ id: nextId(), uic: -1, isVia: false, arrivalType: ArrivalTimeTypes.ASAP },
{
id: nextId(),
uic: -1,
isVia: false,
arrivalType: ArrivalTimeTypes.PRECISE_TIME,
tolerances: { before: DEFAULT_TOLERANCE, after: DEFAULT_TOLERANCE },
},
{
id: nextId(),
uic: -1,
isVia: false,
arrivalType: ArrivalTimeTypes.ASAP,
tolerances: { before: DEFAULT_TOLERANCE, after: DEFAULT_TOLERANCE },
},
],
standardStdcmAllowance: undefined,
totalMass: undefined,
Expand Down

0 comments on commit 0f5f813

Please sign in to comment.