From 88f72f1b2df9817df210027c50d28e252a9ae5cc Mon Sep 17 00:00:00 2001 From: Kayla Firestack Date: Thu, 10 Oct 2024 15:43:37 -0400 Subject: [PATCH] refactor(ts/models/shuttle) implement shuttle `prefix` using `shuttleVariantFromRunId` --- assets/src/models/shuttle.ts | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/assets/src/models/shuttle.ts b/assets/src/models/shuttle.ts index 74e67bef4..7eced30c9 100644 --- a/assets/src/models/shuttle.ts +++ b/assets/src/models/shuttle.ts @@ -33,6 +33,17 @@ export const shuttleVariantFromRunId = ( } } +const prefix = (variant: ShuttleVariant | null): string => { + switch (variant) { + case null: + return "" + case ShuttleVariant.CommuterRail: + return "Commuter Rail " + default: + return variant + " " + } +} + export const formattedRunNumber = ({ runId }: Vehicle): string => { if (runId === null) { return "Not Available" @@ -41,24 +52,5 @@ export const formattedRunNumber = ({ runId }: Vehicle): string => { const [area, run] = runId.split("-") // Remove leading zero from the run portion - return `${prefix(run)}${area} ${run.slice(1)}` -} - -const prefix = (run: string): string => { - switch (run) { - case "0501": - return "Blue " - case "0502": - return "Green " - case "0503": - return "Orange " - case "0504": - return "Red " - case "0505": - return "Commuter Rail " - case "0555": - return "Special " - default: - return "" - } + return `${prefix(shuttleVariantFromRunId(runId))}${area} ${run.slice(1)}` }