Skip to content

Commit

Permalink
feat(ts/models/shuttle): create RunId to ShuttleVariant "mapper"
Browse files Browse the repository at this point in the history
The `RunId` => `ShuttleVariant` relationship is "many to one", which makes this better suited for a function which returns the enum value from the `RunId`.
  • Loading branch information
firestack committed Oct 21, 2024
1 parent 0585c42 commit 8e47fe6
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion assets/src/models/shuttle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Vehicle } from "../realtime"
import { RunId, Vehicle } from "../realtime"

export enum ShuttleVariant {
// Rapid Transit Lines
Expand All @@ -12,6 +12,27 @@ export enum ShuttleVariant {
Special,
}

export const shuttleVariantFromRunId = (
runId: RunId
): ShuttleVariant | null => {
switch (runId) {
case "999-0501":
return ShuttleVariant.Blue
case "999-0502":
return ShuttleVariant.Green
case "999-0503":
return ShuttleVariant.Orange
case "999-0504":
return ShuttleVariant.Red
case "999-0505":
return ShuttleVariant.CommuterRail
case "999-0555":
return ShuttleVariant.Special
default:
return null
}
}

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

0 comments on commit 8e47fe6

Please sign in to comment.