Skip to content

Commit

Permalink
refactor(ts/models/shuttle) implement shuttle prefix using `shuttle…
Browse files Browse the repository at this point in the history
…VariantFromRunId`
  • Loading branch information
firestack committed Oct 18, 2024
1 parent 8436199 commit f4e3b3f
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions assets/src/models/shuttle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)}`
}

0 comments on commit f4e3b3f

Please sign in to comment.