+ );
+}
diff --git a/src/components/nearby/NearbyStopCard.tsx b/src/components/nearby/NearbyStopCard.tsx
new file mode 100644
index 0000000..1a213bd
--- /dev/null
+++ b/src/components/nearby/NearbyStopCard.tsx
@@ -0,0 +1,59 @@
+import { useEffect, useState } from "react";
+import { useTranslation } from "react-i18next";
+
+import { EtaBusWithID } from "../../models/etaObjects.js";
+import { EtaCard } from "../etaCard/EtaCard.js";
+import { getStopPredictions } from "../fetch/fetchUtils.js";
+import { etaParser } from "../parser/etaParser.js";
+
+export default function NearbyStopCard({
+ stop,
+}: {
+ stop: {
+ id: string;
+ lines: string[];
+ title: string;
+ realDistance: number;
+ directions: string;
+ };
+}) {
+ const { t } = useTranslation();
+
+ const [unifiedEta, setUnifiedEta] = useState([]);
+
+ useEffect(() => {
+ const controller = new AbortController();
+
+ getStopPredictions(parseInt(stop.id), { signal: controller.signal }).then(
+ (data) => {
+ if (data) {
+ const etaDb = etaParser(data);
+
+ let templist: EtaBusWithID[] = [];
+ for (const list of etaDb) {
+ templist = templist.concat(list.etas);
+ }
+ setUnifiedEta(templist.sort((a, b) => a.epochTime - b.epochTime));
+ }
+ }
+ );
+
+ // when useEffect is called, the following clean-up fn will run first
+ return () => {
+ controller.abort();
+ };
+ }, []);
+
+ return (
+
+ );
+}
diff --git a/src/i18n/en/locales.json b/src/i18n/en/locales.json
index d2daa74..cd934eb 100644
--- a/src/i18n/en/locales.json
+++ b/src/i18n/en/locales.json
@@ -6,7 +6,8 @@
"about": "About",
"lang": "Language",
"settings": "Settings",
- "bookmarks": "Bookmarks"
+ "bookmarks": "Bookmarks",
+ "nearby": "Nearby"
}
},
"home": {
@@ -31,6 +32,19 @@
"lineAndStopInfo": "Line {{lineNum}} Stop {{stopNum}} =",
"noLineInDb": "Error: This line is not in the route database. Subway lines are unsupported for now."
},
+ "nearby": {
+ "totalStopsSummary": "There are {{stopsTotal}} stops in the local database.",
+ "checkingDb": "Downloading database ...",
+ "checkDb": "Download database",
+ "checkingLocation": "Checking your location...",
+ "checkLocation": "Set my location",
+ "recheckLocation": "Refresh my location",
+ "alwaysProvideLocation": "Provide my locations on load",
+ "locationPolicy": "
Even though we do not send your location to the internet, you still have a choice to only use your location when you want. For convenience, you can provide your location automatically when you load TOBus.ca.