Skip to content

Commit 419861e

Browse files
YohhMath-R
authored andcommitted
fixup! front: pathfinding: display CI/CH codes
1 parent 2e458fe commit 419861e

File tree

7 files changed

+20
-19
lines changed

7 files changed

+20
-19
lines changed

front/src/common/StationCard.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ export default function StationCard({ station, onClick, fixedHeight = false }: P
3535
<div className="station-card-head">
3636
<span className="station-card-code">{trigram}</span>
3737
<span className="station-card-name">{name}&nbsp;</span>
38-
{yardname && !yardNamesToExclude.includes(yardname) && <span>{yardname}</span>}
39-
<span className="station-card-uic ml-3">{uic ? formatUicToCi(uic) : ''}</span>
38+
{yardname && !yardNamesToExclude.includes(yardname) && <small>{yardname}</small>}
39+
{uic && <span className="station-card-uic ml-3">{formatUicToCi(uic)}</span>}
4040
</div>
4141
<div className="station-card-localization">
4242
<span className="station-card-city">{town}</span>

front/src/common/api/osrdEditoastApi.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1642,7 +1642,7 @@ export type GeoJsonPoint = {
16421642
type: 'Point';
16431643
};
16441644
export type PathWaypoint = {
1645-
ch?: string | null;
1645+
ch: string | null;
16461646
duration: number;
16471647
geo: GeoJsonPoint;
16481648
id: string | null;
@@ -1651,7 +1651,7 @@ export type PathWaypoint = {
16511651
path_offset: number;
16521652
sch: GeoJsonPoint;
16531653
suggestion: boolean;
1654-
uic?: number | null;
1654+
uic: number | null;
16551655
};
16561656
export type PathResponse = {
16571657
created: string;
@@ -2202,7 +2202,7 @@ export type ResultSpeed = {
22022202
time: number;
22032203
};
22042204
export type ResultStops = {
2205-
ch?: string | null;
2205+
ch: string | null;
22062206
duration: number;
22072207
position: number;
22082208
time: number;

front/src/modules/trainschedule/components/DriverTrainSchedule/DriverTrainScheduleStop.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default function DriverTrainScheduleStop({ stop, idx, train }: Props) {
5454
</td>
5555
<td>
5656
{stop.name || 'Unknown'}&nbsp;
57-
{stop.ch === '00' || !stop.ch ? 'BV' : `${stop.ch}`}
57+
<small>{stop.ch}</small>
5858
</td>
5959
<td className="stoptime-container">
6060
<div className="box">

front/src/modules/trainschedule/components/ManageTrainSchedule/Itinerary/DisplayVias.tsx

+4-6
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,10 @@ export default function DisplayVias({ zoomToFeaturePoint }: DisplayViasProps) {
100100
`KM ${place.position && Math.round(place.position) / 1000}`
101101
}`}
102102
</small>
103-
<small className="">
104-
{place.ch === '00' || !place.ch ? 'BV' : `${place.ch}`}
105-
</small>
106-
<small className="text-muted ml-3">
107-
{place.uic ? formatUicToCi(place.uic) : ''}
108-
</small>
103+
<small className="">{place.ch}</small>
104+
{place.uic && (
105+
<small className="text-muted ml-3">{formatUicToCi(place.uic)}</small>
106+
)}
109107
</div>
110108
{index !== indexSelected && (
111109
<div className="default-durations-button mr-1">

front/src/modules/trainschedule/components/ManageTrainSchedule/Itinerary/ModalSuggeredVias.tsx

+7-6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Spinner } from 'common/Loader';
1212
import type { ArrayElement } from 'utils/types';
1313
import type { PathResponse, PathWaypoint } from 'common/api/osrdEditoastApi';
1414
import { formatUicToCi } from 'utils/strings';
15+
import cx from 'classnames';
1516

1617
type Props = {
1718
removeAllVias: () => void;
@@ -67,18 +68,18 @@ export default function ModalSugerredVias({ removeAllVias, pathfindingInProgress
6768
const formatVia = (via: ArrayElement<PathResponse['steps']>, idx: number, idxTrueVia: number) => (
6869
<div
6970
key={`suggested-via-modal-${via.id}-${idx}`}
70-
className={`d-flex align-items-center p-1 ${via.suggestion && 'suggested-via-clickable'}`}
71+
className={cx('d-flex align-items-center p-1', via.suggestion && 'suggested-via-clickable')}
7172
title={via.name!}
7273
>
7374
{!via.suggestion && <small className="pr-2">{idxTrueVia}</small>}
7475
<i className={`${via.suggestion ? 'text-muted' : 'text-info'} icons-itinerary-bullet mr-2`} />
7576
<span className="suggested-via-name">{via.name || ''}</span>&nbsp;
76-
<span>{via.ch === '00' || !via.ch ? 'BV' : `${via.ch}`}</span>
77-
<small className="text-muted ml-3">{via.uic ? formatUicToCi(via.uic) : ''}</small>
77+
<span>{via.ch}</span>
78+
{via.uic && <small className="text-muted ml-3">{formatUicToCi(via.uic)}</small>}
7879
<div className="ml-auto">
79-
<small className="mr-2">
80-
{via.path_offset && `KM ${Math.round(via.path_offset) / 1000}`}
81-
</small>
80+
{via.path_offset && (
81+
<small className="mr-2">{`KM ${Math.round(via.path_offset) / 1000}`}</small>
82+
)}
8283
{via.suggestion && via.id && !selectedViasTracks.includes(via.id) ? (
8384
<button
8485
className="btn btn-sm btn-only-icon"

front/src/reducers/osrdconf2/common/tests/commonConfBuilder.ts

+2
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ export default function commonConfBuilder() {
107107
type: 'Point',
108108
},
109109
suggestion: true,
110+
ch: null,
111+
uic: null,
110112
},
111113
],
112114
}),

front/src/utils/strings.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,5 @@ export function convertInputStringToNumber(str: string) {
6363
* @param uic full UIC and CI code (8 digits)
6464
*/
6565
export function formatUicToCi(uic: number) {
66-
return uic.toString().startsWith('87') ? uic.toString().slice(2) : uic;
66+
return uic.toString().replace(/^87/, '');
6767
}

0 commit comments

Comments
 (0)