aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/app
diff options
context:
space:
mode:
authorAriel Costas Guerrero <ariel@costas.dev>2025-12-22 22:06:06 +0100
committerAriel Costas Guerrero <ariel@costas.dev>2025-12-22 22:06:06 +0100
commitbed48c3d7e49b1736d50ce42d92bb6c18cf02504 (patch)
tree475571ad6fa8c7aa1f8e81520689bf1eb425164c /src/frontend/app
parent68f49dec91d68579803d6d579b1f1ecb4fc1dd1f (diff)
Refactor arrivals handling and improve type definitions; reorganise components
Diffstat (limited to 'src/frontend/app')
-rw-r--r--src/frontend/app/api/schema.ts8
-rw-r--r--src/frontend/app/components/arrivals/ArrivalCard.css (renamed from src/frontend/app/components/Stops/ArrivalCard.css)0
-rw-r--r--src/frontend/app/components/arrivals/ArrivalCard.tsx (renamed from src/frontend/app/components/Stops/ArrivalCard.tsx)10
-rw-r--r--src/frontend/app/components/arrivals/ArrivalList.tsx (renamed from src/frontend/app/components/Stops/ArrivalList.tsx)0
-rw-r--r--src/frontend/app/components/map/StopSummarySheet.tsx2
5 files changed, 11 insertions, 9 deletions
diff --git a/src/frontend/app/api/schema.ts b/src/frontend/app/api/schema.ts
index 60e2d97..bb1e96c 100644
--- a/src/frontend/app/api/schema.ts
+++ b/src/frontend/app/api/schema.ts
@@ -12,7 +12,7 @@ export const HeadsignInfoSchema = z.object({
marquee: z.string().optional().nullable(),
});
-export const ArrivalPrecissionSchema = z.enum([
+export const ArrivalPrecisionSchema = z.enum([
"confident",
"unsure",
"scheduled",
@@ -20,8 +20,8 @@ export const ArrivalPrecissionSchema = z.enum([
]);
export const ArrivalDetailsSchema = z.object({
- minutes: z.number(),
- precission: ArrivalPrecissionSchema,
+ minutes: z.number().int(),
+ precision: ArrivalPrecisionSchema,
});
export const DelayBadgeSchema = z.object({
@@ -49,7 +49,7 @@ export const StopArrivalsResponseSchema = z.object({
export type RouteInfo = z.infer<typeof RouteInfoSchema>;
export type HeadsignInfo = z.infer<typeof HeadsignInfoSchema>;
-export type ArrivalPrecission = z.infer<typeof ArrivalPrecissionSchema>;
+export type ArrivalPrecision = z.infer<typeof ArrivalPrecisionSchema>;
export type ArrivalDetails = z.infer<typeof ArrivalDetailsSchema>;
export type DelayBadge = z.infer<typeof DelayBadgeSchema>;
export type ShiftBadge = z.infer<typeof ShiftBadgeSchema>;
diff --git a/src/frontend/app/components/Stops/ArrivalCard.css b/src/frontend/app/components/arrivals/ArrivalCard.css
index 5835352..5835352 100644
--- a/src/frontend/app/components/Stops/ArrivalCard.css
+++ b/src/frontend/app/components/arrivals/ArrivalCard.css
diff --git a/src/frontend/app/components/Stops/ArrivalCard.tsx b/src/frontend/app/components/arrivals/ArrivalCard.tsx
index 96d0af0..de4fcc7 100644
--- a/src/frontend/app/components/Stops/ArrivalCard.tsx
+++ b/src/frontend/app/components/arrivals/ArrivalCard.tsx
@@ -16,11 +16,11 @@ export const ArrivalCard: React.FC<ArrivalCardProps> = ({
const { t } = useTranslation();
const { route, headsign, estimate } = arrival;
- const etaValue = Math.max(0, Math.round(estimate.minutes)).toString();
+ const etaValue = estimate.minutes.toString();
const etaUnit = t("estimates.minutes", "min");
const timeClass = useMemo(() => {
- switch (estimate.precission) {
+ switch (estimate.precision) {
case "confident":
return "time-running";
case "unsure":
@@ -30,7 +30,7 @@ export const ArrivalCard: React.FC<ArrivalCardProps> = ({
default:
return "time-scheduled";
}
- }, [estimate.precission]);
+ }, [estimate.precision]);
return (
<div
@@ -50,7 +50,9 @@ export const ArrivalCard: React.FC<ArrivalCardProps> = ({
/>
</div>
<div className="flex-1 min-w-0 flex flex-col gap-1">
- <strong className="text-base text-(--text-color) overflow-hidden text-ellipsis line-clamp-2 leading-tight">
+ <strong
+ className={`text-base overflow-hidden text-ellipsis line-clamp-2 leading-tight ${estimate.precision == "past" ? "line-through" : ""}`}
+ >
{headsign.destination}
</strong>
</div>
diff --git a/src/frontend/app/components/Stops/ArrivalList.tsx b/src/frontend/app/components/arrivals/ArrivalList.tsx
index a1210d5..a1210d5 100644
--- a/src/frontend/app/components/Stops/ArrivalList.tsx
+++ b/src/frontend/app/components/arrivals/ArrivalList.tsx
diff --git a/src/frontend/app/components/map/StopSummarySheet.tsx b/src/frontend/app/components/map/StopSummarySheet.tsx
index 16a9cbe..e318bee 100644
--- a/src/frontend/app/components/map/StopSummarySheet.tsx
+++ b/src/frontend/app/components/map/StopSummarySheet.tsx
@@ -3,7 +3,7 @@ import React from "react";
import { useTranslation } from "react-i18next";
import { Sheet } from "react-modal-sheet";
import { Link } from "react-router";
-import { ArrivalList } from "~/components/Stops/ArrivalList";
+import { ArrivalList } from "~/components/arrivals/ArrivalList";
import { useStopArrivals } from "../../hooks/useArrivals";
import { ErrorDisplay } from "../ErrorDisplay";
import LineIcon from "../LineIcon";