From 7348781b89178589036620b33f3554b2e7271c5f Mon Sep 17 00:00:00 2001 From: Ariel Costas Guerrero Date: Fri, 30 Jan 2026 19:29:55 +0100 Subject: feat: Enhance header and app shell with back navigation and dynamic title support --- src/frontend/app/routes/planner.tsx | 13 ++-- src/frontend/app/routes/routes-$id.tsx | 110 +++++++++++++++++++++------------ 2 files changed, 75 insertions(+), 48 deletions(-) (limited to 'src/frontend/app/routes') diff --git a/src/frontend/app/routes/planner.tsx b/src/frontend/app/routes/planner.tsx index 32c37c0..1f64590 100644 --- a/src/frontend/app/routes/planner.tsx +++ b/src/frontend/app/routes/planner.tsx @@ -11,7 +11,7 @@ import LineIcon from "~/components/LineIcon"; import { PlannerOverlay } from "~/components/PlannerOverlay"; import { AppMap } from "~/components/shared/AppMap"; import { APP_CONSTANTS } from "~/config/constants"; -import { usePageTitle } from "~/contexts/PageTitleContext"; +import { useBackButton, usePageTitle } from "~/contexts/PageTitleContext"; import { type Itinerary } from "~/data/PlannerApi"; import { usePlanner } from "~/hooks/usePlanner"; import "../tailwind-full.css"; @@ -185,6 +185,7 @@ const ItineraryDetail = ({ onClose: () => void; }) => { const { t } = useTranslation(); + useBackButton({ onBack: onClose }); const mapRef = useRef(null); const { destination: userDestination } = usePlanner(); const [nextArrivals, setNextArrivals] = useState< @@ -319,7 +320,8 @@ const ItineraryDetail = ({ ); if (resp.ok) { - arrivalsByStop[stopKey] = await resp.json() satisfies ConsolidatedCirculation[]; + arrivalsByStop[stopKey] = + (await resp.json()) satisfies ConsolidatedCirculation[]; } } catch (err) { console.warn( @@ -463,13 +465,6 @@ const ItineraryDetail = ({ /> - - {/* Details Panel */} diff --git a/src/frontend/app/routes/routes-$id.tsx b/src/frontend/app/routes/routes-$id.tsx index 3b61ba6..62de642 100644 --- a/src/frontend/app/routes/routes-$id.tsx +++ b/src/frontend/app/routes/routes-$id.tsx @@ -1,5 +1,5 @@ import { useQuery } from "@tanstack/react-query"; -import { useRef, useState } from "react"; +import { useMemo, useRef, useState } from "react"; import { useTranslation } from "react-i18next"; import { AttributionControl, @@ -10,7 +10,11 @@ import { import { useParams } from "react-router"; import { fetchRouteDetails } from "~/api/transit"; import { AppMap } from "~/components/shared/AppMap"; -import { usePageTitle } from "~/contexts/PageTitleContext"; +import { + useBackButton, + usePageTitle, + usePageTitleNode, +} from "~/contexts/PageTitleContext"; import "../tailwind-full.css"; export default function RouteDetailsPage() { @@ -35,6 +39,38 @@ export default function RouteDetailsPage() { : t("routes.details", "Detalles de ruta") ); + const titleNode = useMemo(() => { + if (!route) { + return ( + + {t("routes.details", "Detalles de ruta")} + + ); + } + + return ( +
+
+ + {route.shortName || route.longName} + + + {route.longName} + +
+
+ ); + }, [route, t]); + + usePageTitleNode(titleNode); + + useBackButton({ to: "/routes" }); + if (isLoading) { return (
@@ -122,38 +158,6 @@ export default function RouteDetailsPage() { return (
-
- -
-
@@ -179,11 +183,7 @@ export default function RouteDetailsPage() { showTraffic={false} attributionControl={false} > - + {selectedPattern?.geometry && (
+ +

{t("routes.stops", "Paradas")} -- cgit v1.3