aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/app/routes
diff options
context:
space:
mode:
authorAriel Costas Guerrero <ariel@costas.dev>2025-12-08 01:37:10 +0100
committerAriel Costas Guerrero <ariel@costas.dev>2025-12-08 01:37:10 +0100
commit107295575e3a7c37911ae192baf426b0003975a4 (patch)
treeceb528a428716d5313517a0fa72fcac3ea1360fb /src/frontend/app/routes
parent3b3fd2f6880eaa9170b480d41d43311925483bea (diff)
Refactor code structure for improved readability and maintainability; removed redundant code blocks and optimized functions.
Diffstat (limited to 'src/frontend/app/routes')
-rw-r--r--src/frontend/app/routes/home.tsx10
-rw-r--r--src/frontend/app/routes/stops-$id.tsx5
2 files changed, 8 insertions, 7 deletions
diff --git a/src/frontend/app/routes/home.tsx b/src/frontend/app/routes/home.tsx
index 5d56b48..f97fdf7 100644
--- a/src/frontend/app/routes/home.tsx
+++ b/src/frontend/app/routes/home.tsx
@@ -104,7 +104,7 @@ export default function StopList() {
}
if (!userLocation) {
- return [...data].sort((a, b) => a.stopId - b.stopId);
+ return [...data].sort((a, b) => a.stopId.localeCompare(b.stopId));
}
const toRadians = (value: number) => (value * Math.PI) / 180;
@@ -147,7 +147,7 @@ export default function StopList() {
})
.sort((a, b) => {
if (a.distance === b.distance) {
- return a.stop.stopId - b.stop.stopId;
+ return a.stop.stopId.localeCompare(b.stop.stopId);
}
return a.distance - b.distance;
})
@@ -216,8 +216,8 @@ export default function StopList() {
let items: Stop[];
if (isNumericSearch) {
// Direct match for stop codes
- const stopId = parseInt(searchQuery.trim(), 10);
- const exactMatch = data.filter((stop) => stop.stopId === stopId);
+ const stopId = searchQuery.trim();
+ const exactMatch = data.filter((stop) => stop.stopId === stopId || stop.stopId.endsWith(`:${stopId}`));
if (exactMatch.length > 0) {
items = exactMatch;
} else {
@@ -281,7 +281,7 @@ export default function StopList() {
{/* Favourites Gallery */}
{!loading && (
<StopGallery
- stops={favouriteStops.sort((a, b) => a.stopId - b.stopId)}
+ stops={favouriteStops.sort((a, b) => a.stopId.localeCompare(b.stopId))}
title={t("stoplist.favourites")}
emptyMessage={t("stoplist.no_favourites")}
/>
diff --git a/src/frontend/app/routes/stops-$id.tsx b/src/frontend/app/routes/stops-$id.tsx
index 5260c32..553b8e7 100644
--- a/src/frontend/app/routes/stops-$id.tsx
+++ b/src/frontend/app/routes/stops-$id.tsx
@@ -247,8 +247,8 @@ export default function Estimates() {
<div className="flex items-center gap-8">
<Star
className={`cursor-pointer transition-colors ${favourited
- ? "fill-[var(--star-color)] text-[var(--star-color)]"
- : "text-slate-500"
+ ? "fill-[var(--star-color)] text-[var(--star-color)]"
+ : "text-slate-500"
}`}
onClick={toggleFavourite}
/>
@@ -273,6 +273,7 @@ export default function Estimates() {
<ConsolidatedCirculationList
data={data}
reduced={isReducedView}
+ driver={stopData?.stopId.split(':')[0]}
onCirculationClick={(estimate, idx) => {
setSelectedCirculationId(getCirculationId(estimate));
setIsMapModalOpen(true);