Skip to content

Commit

Permalink
front: fix pr comments
Browse files Browse the repository at this point in the history
Signed-off-by: Egor Berezovskiy <egor@berezify.fr>
  • Loading branch information
Wadjetz committed Dec 17, 2024
1 parent 3aa8cfb commit 3f5afb8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
12 changes: 12 additions & 0 deletions front/src/applications/stdcm/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,15 @@ export const COMPOSITION_CODES = [
'MV160',
'MVGV',
];

export const COMPOSITION_CODES_MAX_SPEEDS: Record<string, number | undefined> = {
MA80: 80,
MA90: 90,
MA100: 100,
ME100: 100,
ME120: 120,
ME140: 140,
ME160: 160,
HLP: 100,
MVGV: 200,
};
17 changes: 3 additions & 14 deletions front/src/applications/stdcm/utils/maxSpeedFromSpeedLimitByTag.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
import { COMPOSITION_CODES_MAX_SPEEDS } from '../consts';

/**
* Get max speed in km/h from speedLimitByTag
* @param speedLimitByTag - A string representing the speed limit tag
* @returns The max speed in km/h, or undefined if not applicable
*/
const maxSpeedFromSpeedLimitByTag = (speedLimitByTag?: string | null): number | undefined => {
if (!speedLimitByTag) return undefined;

const speedMap: Record<string, number | undefined> = {
MA80: 80,
MA90: 90,
MA100: 100,
ME100: 100,
ME120: 120,
ME140: 140,
ME160: 160,
HLP: undefined,
MVGV: undefined,
};

return speedMap[speedLimitByTag] ?? undefined;
return COMPOSITION_CODES_MAX_SPEEDS[speedLimitByTag] ?? undefined;
};

export default maxSpeedFromSpeedLimitByTag;

0 comments on commit 3f5afb8

Please sign in to comment.