aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/app')
-rw-r--r--src/frontend/app/routes/routes-$id.tsx7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/frontend/app/routes/routes-$id.tsx b/src/frontend/app/routes/routes-$id.tsx
index 79997b5..d563cdc 100644
--- a/src/frontend/app/routes/routes-$id.tsx
+++ b/src/frontend/app/routes/routes-$id.tsx
@@ -56,10 +56,13 @@ export default function RouteDetailsPage() {
() => formatDateKey(selectedWeekDate),
[selectedWeekDate]
);
+ const ONE_HOUR_SECONDS = 3600;
const isTodaySelectedDate = selectedDateKey === formatDateKey(new Date());
const now = new Date();
const nowSeconds =
now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds();
+ const formatDelayMinutes = (delayMinutes: number) =>
+ ` (${delayMinutes > 0 ? "+" : ""}${delayMinutes})`;
const { data: route, isLoading } = useQuery({
queryKey: ["route", id, selectedDateKey],
@@ -597,7 +600,7 @@ export default function RouteDetailsPage() {
.get(stop.id)
?.filter((item) =>
isTodaySelectedDate
- ? item.departure >= nowSeconds - 3600
+ ? item.departure >= nowSeconds - ONE_HOUR_SECONDS
: true
) ?? []
).map((item, i) => (
@@ -640,7 +643,7 @@ export default function RouteDetailsPage() {
>
{arrival.estimate.minutes}′
{arrival.delay?.minutes
- ? ` (${arrival.delay.minutes > 0 ? "+" : ""}${arrival.delay.minutes})`
+ ? formatDelayMinutes(arrival.delay.minutes)
: ""}
</span>
)