diff --git a/front/src/applications/stdcm/views/StdcmResultsV2.tsx b/front/src/applications/stdcm/views/StdcmResultsV2.tsx index 78c8da4344a..752a88699e7 100644 --- a/front/src/applications/stdcm/views/StdcmResultsV2.tsx +++ b/front/src/applications/stdcm/views/StdcmResultsV2.tsx @@ -24,7 +24,7 @@ type StcdmResultsProps = { creationDate?: Date; }; -const simulationReportSheetNumber = generateCodeNumber(); +const codeNumber = generateCodeNumber(); // TODO TS2 : Adapt StdcmResult to trainSchedule v2 (SpaceTimeChart and SpeedSpaceChart) @@ -107,12 +107,12 @@ const StcdmResultsV2 = ({ pathProperties={pathProperties} rollingStockData={rollingStockData} speedLimitByTag={speedLimitByTag} - simulationReportSheetNumber={simulationReportSheetNumber} + simulationReportSheetNumber={codeNumber} mapCanvas={mapCanvas} creationDate={creationDate} /> } - fileName={`STDCM-${simulationReportSheetNumber}.pdf`} + fileName={`STDCM-${codeNumber}.pdf`} > {t('stdcmSimulationReport')} diff --git a/front/src/applications/stdcmV2/components/StdcmConfig.tsx b/front/src/applications/stdcmV2/components/StdcmConfig.tsx index 38f388ef224..e7e256378e7 100644 --- a/front/src/applications/stdcmV2/components/StdcmConfig.tsx +++ b/front/src/applications/stdcmV2/components/StdcmConfig.tsx @@ -98,7 +98,7 @@ const StdcmConfig = ({ disabled={isPending} setCurrentSimulationInputs={setCurrentSimulationInputs} /> - + ) => { diff --git a/front/src/applications/stdcmV2/components/StdcmVias.tsx b/front/src/applications/stdcmV2/components/StdcmVias.tsx index 9b619479b23..1e98ba14fe7 100644 --- a/front/src/applications/stdcmV2/components/StdcmVias.tsx +++ b/front/src/applications/stdcmV2/components/StdcmVias.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useMemo } from 'react'; +import React, { useMemo } from 'react'; import { Location } from '@osrd-project/ui-icons'; import { useTranslation } from 'react-i18next'; @@ -15,17 +15,8 @@ import { formatDurationAsISO8601 } from 'utils/timeManipulation'; import StdcmCard from './StdcmCard'; import StdcmInputVia from './StdcmInputVia'; import StdcmOperationalPoint from './StdcmOperationalPoint'; -import type { StdcmSimulationResult } from '../views/StdcmViewV2'; -const StdcmVias = ({ - disabled = false, - setCurrentSimulationInputs, -}: { - disabled?: boolean; - setCurrentSimulationInputs: React.Dispatch< - React.SetStateAction - >; -}) => { +const StdcmVias = ({ disabled = false }: { disabled?: boolean }) => { const { t } = useTranslation('stdcm'); const dispatch = useAppDispatch(); const { getPathSteps } = useOsrdConfSelectors(); @@ -50,22 +41,15 @@ const StdcmVias = ({ ); }; - const deletePathStep = (index: number) => { - dispatch(updatePathSteps(pathSteps.filter((_, i) => i !== index))); - }; - - useEffect(() => { - setCurrentSimulationInputs((prevState) => ({ - ...prevState, - pathSteps, - })); - }, [pathSteps]); - return (
{intermediatePoints.length > 0 && intermediatePoints.map((pathStep, index) => { const pathStepId = index + 1; + function deleteViaV2(index: number): any { + throw new Error('Function not implemented.'); + } + return ( intermediate-point -
- } // TODO: Remove icon and clear button -> replace them by the "numbered point" icon + } hasTip disabled={disabled} > diff --git a/front/src/modules/pathfinding/components/Pathfinding/PathfindingV2.tsx b/front/src/modules/pathfinding/components/Pathfinding/PathfindingV2.tsx index e7acfd54215..52bd3457e6b 100644 --- a/front/src/modules/pathfinding/components/Pathfinding/PathfindingV2.tsx +++ b/front/src/modules/pathfinding/components/Pathfinding/PathfindingV2.tsx @@ -33,10 +33,7 @@ const Pathfinding = ({ pathProperties, setPathProperties }: PathfindingProps) => const { pathfindingState, infraInfos: { infra, reloadCount }, - } = usePathfindingV2({ - pathProperties, - setPathProperties, - }); + } = usePathfindingV2(setPathProperties, pathProperties); const missingElements = conditionalStringConcat([ [!origin, t('origin')], diff --git a/front/src/modules/pathfinding/hook/useInfra.ts b/front/src/modules/pathfinding/hook/useInfra.ts deleted file mode 100644 index f503eac60be..00000000000 --- a/front/src/modules/pathfinding/hook/useInfra.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { useState, useEffect } from 'react'; - -import { isEqual } from 'lodash'; -import { useSelector } from 'react-redux'; - -import { osrdEditoastApi } from 'common/api/osrdEditoastApi'; -import { useOsrdConfSelectors } from 'common/osrdContext'; - -export default function useInfra() { - const { getInfraID } = useOsrdConfSelectors(); - const infraId = useSelector(getInfraID, isEqual); - - const [reloadInfra] = osrdEditoastApi.endpoints.postInfraByInfraIdLoad.useMutation(); - - const [isInfraLoaded, setIsInfraLoaded] = useState(false); - const [reloadCount, setReloadCount] = useState(1); - const [isInfraError, setIsInfraError] = useState(false); - - const { data: infra } = osrdEditoastApi.endpoints.getInfraByInfraId.useQuery( - { infraId: infraId as number }, - { - refetchOnMountOrArgChange: true, - pollingInterval: !isInfraLoaded ? 1000 : undefined, - } - ); - - useEffect(() => { - if (reloadCount <= 5 && infra && infra.state === 'TRANSIENT_ERROR') { - setTimeout(() => { - reloadInfra({ infraId: infraId as number }).unwrap(); - setReloadCount((count) => count + 1); - }, 1000); - } - }, [infra, reloadCount]); - - useEffect(() => { - if (infra) { - switch (infra.state) { - case 'NOT_LOADED': { - reloadInfra({ infraId: infraId as number }).unwrap(); - setIsInfraLoaded(false); - break; - } - case 'ERROR': - case 'TRANSIENT_ERROR': { - setIsInfraLoaded(true); - break; - } - case 'CACHED': { - setIsInfraLoaded(true); - if (isInfraError) setIsInfraError(false); - break; - } - default: - break; - } - } - }, [infra]); - - useEffect(() => { - if (isInfraError) { - reloadInfra({ infraId: infraId as number }).unwrap(); - setIsInfraLoaded(false); - } - }, [isInfraError]); - - return { - reloadCount, - setIsInfraError, - infra, - }; -}