Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainValls committed Apr 23, 2024
1 parent 3e4a331 commit cfc131a
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
"calculatingTrainScheduleCompleteAll_other": "All running time calculations completed: {{successfulTrainsCount}}/{{trainsCount}} trains created. {{errorsNb}}/{{trainsCount}} trains couldn't be created.",
"calculatingTrainScheduleCompleteAllSuccess_one": "All running time calculations completed: {{successfulTrainsCount}} train created.",
"calculatingTrainScheduleCompleteAllSuccess": "All running time calculations completed: {{successfulTrainsCount}} trains created.",
"calculatingTrainScheduleCompleteAllFailure_zero": "Des calculs de marche ont échoué. {{errorsNb}}/{{trainsCount}} train couldn't be created.",
"calculatingTrainScheduleCompleteAllFailure_one": "All running time calculations completed: {{errorsNb}}/{{trainsCount}} train couldn't be created.",
"calculatingTrainScheduleCompleteAllFailure_other": "All running time calculations completed: {{errorsNb}}/{{trainsCount}} trains couldn't be created.",
"calculatingTrainScheduleCompleteFailure_zero": "All running time calculations have failed.",
"calculatingTrainScheduleCompleteFailure_one": "All running time calculations completed: {{errorsNb}}/{{trainsCount}} train couldn't be created.",
"calculatingTrainScheduleCompleteFailure_other": "All running time calculations completed: {{errorsNb}}/{{trainsCount}} trains couldn't be created.",
"calculatingTrainScheduleCompleteAllFailure": "All running time calculations have failed.",
"complete": "{{uicNumber}}/{{uicTotalCount}} position {{uicName}}",
"missingRollingStock": "You must choose a default rolling stock",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
"calculatingTrainScheduleCompleteAll_other": "Tous les calculs de marches sont terminés: {{successfulTrainsCount}}/{{trainsCount}} trains créés. {{errorsNb}}/{{trainsCount}} trains n'ont pas été créés.",
"calculatingTrainScheduleCompleteAllSuccess_one": "Tous les calculs de marches sont terminés: {{successfulTrainsCount}} train créé.",
"calculatingTrainScheduleCompleteAllSuccess": "Tous les calculs de marches sont terminés: {{successfulTrainsCount}} trains créés.",
"calculatingTrainScheduleCompleteAllFailure_zero": "Des calculs de marche ont échoué. {{errorsNb}}/{{trainsCount}} train na pas été créé.",
"calculatingTrainScheduleCompleteAllFailure_one": "Des calculs de marche ont échoué. {{errorsNb}}/{{trainsCount}} train na pas été créé.",
"calculatingTrainScheduleCompleteAllFailure_other": "Des calculs de marche ont échoué. {{errorsNb}}/{{trainsCount}} trains n'ont pas été créés.",
"calculatingTrainScheduleCompleteFailure_zero": "Tous les calculs de marche ont échoué.",
"calculatingTrainScheduleCompleteFailure_one": "Des calculs de marche ont échoué. {{errorsNb}}/{{trainsCount}} train n'a pas été créé.",
"calculatingTrainScheduleCompleteFailure_other": "Des calculs de marche ont échoué. {{errorsNb}}/{{trainsCount}} trains n'ont pas été créés.",
"calculatingTrainScheduleCompleteAllFailure": "Tous les calculs de marche ont échoué.",
"complete": "{{uicNumber}}/{{uicTotalCount}} positionnez {{uicName}}",
"missingRollingStock": "Vous devez choisir un matériel roulant par défaut",
Expand Down
23 changes: 21 additions & 2 deletions front/src/applications/operationalStudies/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,37 @@ export interface Step extends Destination {
arrivalTime: string;
departureTime: string;
duration?: number;
tracks: {
position: number;
track: string;
}[];
}
export interface StepV2 extends Destination {
arrivalTime: string;
departureTime: string;
duration?: number;
}

export type TrainSchedule = {
trainNumber: string;
rollingStock: string;
rollingStock: string | null;
departureTime: string;
arrivalTime: string;
departure: string;
steps: Step[];
transilienName?: string;
};

export type TrainScheduleV2 = {
trainNumber: string;
rollingStock: string | null;
departureTime: string;
arrivalTime: string;
departure: string;
steps: StepV2[];
transilienName?: string;
};

export interface TrainScheduleWithPathRef extends TrainSchedule {
pathRef: string;
}
Expand All @@ -37,7 +56,7 @@ export interface TrainScheduleWithPath extends TrainScheduleWithPathRef {

export type ImportedTrainSchedule = {
trainNumber: string;
rollingStock: string;
rollingStock: string | null;
departureTime: string;
arrivalTime: string;
departure: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';

import { useTranslation } from 'react-i18next';

import type { TrainSchedule } from 'applications/operationalStudies/types';
import type { TrainScheduleV2 } from 'applications/operationalStudies/types';
import { enhancedEditoastApi } from 'common/api/enhancedEditoastApi';
import { Loader } from 'common/Loaders';
import { ImportTrainScheduleConfigV2 } from 'modules/trainschedule/components/ImportTrainSchedule';
Expand All @@ -13,7 +13,7 @@ import { useAppDispatch } from 'store';
const ImportTrainScheduleV2 = ({ timetableId }: { timetableId: number }) => {
const dispatch = useAppDispatch();
const { t } = useTranslation(['rollingstock']);
const [trainsList, setTrainsList] = useState<TrainSchedule[]>([]);
const [trainsList, setTrainsList] = useState<TrainScheduleV2[]>([]);
const [isLoading, setIsLoading] = useState(false);

const { data: { results: rollingStocks } = { results: [] }, isError } =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ const ScenarioV2 = () => {
)}
{displayTrainScheduleManagement === MANAGE_TRAIN_SCHEDULE_TYPES.import && (
<div className="scenario-managetrainschedule">
<ImportTrainScheduleV2 infraId={infraId} timetableId={timetableId} />
<ImportTrainScheduleV2 timetableId={timetableId} />
</div>
)}
<div className="scenario-results">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next';

import type {
ImportedTrainSchedule,
TrainSchedule,
TrainScheduleV2,
TrainScheduleImportConfig,
} from 'applications/operationalStudies/types';
import { getGraouTrainSchedules } from 'common/api/graouApi';
Expand All @@ -20,7 +20,7 @@ import { useAppDispatch } from 'store';
import { formatIsoDate } from 'utils/date';

interface ImportTrainScheduleConfigProps {
setTrainsList: (trainsList: TrainSchedule[]) => void;
setTrainsList: (trainsList: TrainScheduleV2[]) => void;
setIsLoading: (isLoading: boolean) => void;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ const ImportTrainScheduleModal = ({
count: successfulTrainsCount,
successfulTrainsCount,
trainsCount,
errorsNb: trainsCount - successfulTrainsCount,
})
);
refetchTimetable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import cx from 'classnames';
import nextId from 'react-id-generator';
import { LazyLoadComponent } from 'react-lazy-load-image-component';

import type { TrainSchedule } from 'applications/operationalStudies/types';
import type { TrainSchedule, TrainScheduleV2 } from 'applications/operationalStudies/types';
import type {
LightRollingStockWithLiveries,
RollingStockWithLiveries,
Expand All @@ -13,7 +13,7 @@ import RollingStock2Img from 'modules/rollingStock/components/RollingStock2Img';
import { seconds2hhmmss } from 'modules/trainschedule/components/ImportTrainSchedule/ImportTrainScheduleHelpers';

type Props = {
trainData: TrainSchedule;
trainData: TrainSchedule | TrainScheduleV2;
idx: number;
rollingStock?: LightRollingStockWithLiveries | RollingStockWithLiveries;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import { Rocket } from '@osrd-project/ui-icons';
import type { TFunction } from 'i18next';
import { keyBy } from 'lodash';
import { useTranslation } from 'react-i18next';
import nextId from 'react-id-generator';

import type { TrainSchedule } from 'applications/operationalStudies/types';
import type { TrainScheduleV2 } from 'applications/operationalStudies/types';
import { osrdEditoastApi, type LightRollingStockWithLiveries } from 'common/api/osrdEditoastApi';
import { Loader } from 'common/Loaders';
// eslint-disable-next-line import/no-cycle
Expand All @@ -26,7 +25,7 @@ function LoadingIfSearching({ isLoading, t }: { isLoading: boolean; t: TFunction
}

type ImportTrainScheduleTrainsListProps = {
trainsList: TrainSchedule[];
trainsList: TrainScheduleV2[];
rollingStocks: LightRollingStockWithLiveries[];
isLoading: boolean;
timetableId: number;
Expand Down Expand Up @@ -70,7 +69,7 @@ const ImportTrainScheduleTrainsListV2 = ({
dispatch(
setFailure({
name: t('failure'),
message: t('status.calculatingTrainScheduleCompleteAllFailure', {
message: t('status.calculatingTrainScheduleCompleteFailure', {
trainsCount,
errorsNb,
count: trainsCount - errorsNb,
Expand Down Expand Up @@ -112,7 +111,7 @@ const ImportTrainScheduleTrainsListV2 = ({
<ImportTrainScheduleTrainDetail
trainData={train}
idx={idx}
key={nextId()}
key={train.trainNumber}
rollingStock={
rollingStockDict[
rollingstockOpenData2OSRD[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const generateAutocompleteWaypoints = (step: Step) => {
if (isEmpty(step.tracks)) {
return [];
}
return step.tracks.map((trackPosition) => ({
return step.tracks?.map((trackPosition) => ({
track_section: trackPosition.track,
offset: trackPosition.position,
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import nextId from 'react-id-generator';

import type {
Step,
TrainSchedule,
TrainScheduleV2,
TrainScheduleWithPath,
} from 'applications/operationalStudies/types';
import type {
Expand Down Expand Up @@ -64,7 +64,7 @@ export default function generateTrainSchedulesPayloads(
}

export function generateV2TrainSchedulesPayloads(
trains: TrainSchedule[],
trains: TrainScheduleV2[],
timetableID: number
): TrainScheduleForm[] {
return trains.map((train) => {
Expand Down Expand Up @@ -96,7 +96,7 @@ export function generateV2TrainSchedulesPayloads(
timetable_id: timetableID,
path,
train_name: train.trainNumber,
rolling_stock_name: train.rollingStock,
rolling_stock_name: train.rollingStock || '',
constraint_distribution: 'MARECO',
schedule,
start_time: formatToISO8601(train.departureTime),
Expand Down

0 comments on commit cfc131a

Please sign in to comment.