Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

front: set default tolerances in the store #9977

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading