From d0154a2b9be15f07d8282df57078e2086a381e0b Mon Sep 17 00:00:00 2001 From: Kayla Firestack Date: Thu, 10 Oct 2024 15:43:37 -0400 Subject: [PATCH 1/2] feat(ts/models/shuttle): create enum `ShuttleVariant` --- assets/src/models/shuttle.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/assets/src/models/shuttle.ts b/assets/src/models/shuttle.ts index 026b99e9e..36b44294c 100644 --- a/assets/src/models/shuttle.ts +++ b/assets/src/models/shuttle.ts @@ -1,5 +1,17 @@ import { Vehicle } from "../realtime" +export enum ShuttleVariant { + // Rapid Transit Lines + Blue = "Blue", + Green = "Green", + Orange = "Orange", + Red = "Red", + + // Other Shuttle Types + CommuterRail = "CR", + Special = "Special", +} + export const formattedRunNumber = ({ runId }: Vehicle): string => { if (runId === null) { return "Not Available" From 1d06567dbf1de64f88f51cf703e22d30d5645fa1 Mon Sep 17 00:00:00 2001 From: Kayla Firestack Date: Thu, 10 Oct 2024 15:43:37 -0400 Subject: [PATCH 2/2] feat(ts/models/shuttle): create `RunId` to `ShuttleVariant ` "mapper" The `RunId` => `ShuttleVariant ` relationship is "many to one", which makes this better suited for a function which returns the enum value from the `RunId`. --- assets/src/models/shuttle.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/assets/src/models/shuttle.ts b/assets/src/models/shuttle.ts index 36b44294c..74e67bef4 100644 --- a/assets/src/models/shuttle.ts +++ b/assets/src/models/shuttle.ts @@ -1,4 +1,4 @@ -import { Vehicle } from "../realtime" +import { RunId, Vehicle } from "../realtime" export enum ShuttleVariant { // Rapid Transit Lines @@ -12,6 +12,27 @@ export enum ShuttleVariant { Special = "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"