Skip to content

Commit

Permalink
refactor(ts/models/shuttle) implement shuttle prefix using `shuttleVa…
Browse files Browse the repository at this point in the history
…riantFromRunId` (#2862)
  • Loading branch information
firestack authored Oct 22, 2024
1 parent 181a732 commit 101479d
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions assets/src/models/shuttle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,32 @@ export const shuttleVariantFromRunId = (
}
}

export const formattedRunNumber = ({ runId }: Vehicle): string => {
if (runId === null) {
return "Not Available"
}

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":
const prefix = (variant: ShuttleVariant | null): string => {
switch (variant) {
case ShuttleVariant.Blue:
return "Blue "
case "0502":
case ShuttleVariant.Green:
return "Green "
case "0503":
case ShuttleVariant.Orange:
return "Orange "
case "0504":
case ShuttleVariant.Red:
return "Red "
case "0505":
case ShuttleVariant.CommuterRail:
return "Commuter Rail "
case "0555":
case ShuttleVariant.Special:
return "Special "
default:
return ""
}
}

export const formattedRunNumber = ({ runId }: Vehicle): string => {
if (runId === null) {
return "Not Available"
}

const [area, run] = runId.split("-")

// Remove leading zero from the run portion
return `${prefix(shuttleVariantFromRunId(runId))}${area} ${run.slice(1)}`
}

0 comments on commit 101479d

Please sign in to comment.