From f3bdcf7ffbf530f35d2c56e7ea46ac9e85beda35 Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 27 Nov 2026 22:51:00 +0100 Subject: [PATCH] feat(mobile): open directions from a place's address and a booking's location On the road the address is what the eye lands on. A tap on it in the place sheet now does what the navigation button does (the preferred map app, or the choice of apps), and the location row of a booking card opens directions to it the same way, marked by a small arrow. The rest of the booking card still opens the booking. Addresses discussion #3213. --- .../screens/trip/sheets/MPlaceSheet.tsx | 24 +++++++- .../mobile/screens/trip/tabs/MBookingsTab.tsx | 59 +++++++++++++++---- 2 files changed, 71 insertions(+), 12 deletions(-) diff --git a/client/src/mobile/screens/trip/sheets/MPlaceSheet.tsx b/client/src/mobile/screens/trip/sheets/MPlaceSheet.tsx index 0b4e5eafc..91417db58 100644 --- a/client/src/mobile/screens/trip/sheets/MPlaceSheet.tsx +++ b/client/src/mobile/screens/trip/sheets/MPlaceSheet.tsx @@ -1,4 +1,4 @@ -import { useMemo, useRef, useState } from 'react' +import { useMemo, useRef, useState, type KeyboardEvent } from 'react' import DawarichIcon from '../../../../components/shared/DawarichIcon' import { Bookmark, ChevronRight, ExternalLink, Map as MapIcon, MapPinOff, Navigation, Paperclip, @@ -220,8 +220,28 @@ export default function MPlaceSheet({ planner, shell }: MTripSheetsProps) { )} + {/* A tap on the address opens directions, as the navigation button does: + on the road the address is what the eye lands on. */} {place.address && ( -
{place.address}
+
0 ? ' cursor-pointer underline decoration-dotted underline-offset-2' : ''}`} + {...(navTargets.length > 0 + ? { + role: 'button', + tabIndex: 0, + 'aria-label': `${navTargets.length === 1 ? navigationTargetLabel(navTargets[0], t) : t('inspector.navigation')}: ${place.address}`, + onClick: openDirections, + onKeyDown: (e: KeyboardEvent) => { + if (e.key === 'Enter' || e.key === ' ') { + e.preventDefault() + openDirections() + } + }, + } + : {})} + > + {place.address} +
)} {/* A typed address that never got coordinates: no marker, and the sheet says why (#2837). */} {addressWithoutCoordinates(place) && ( diff --git a/client/src/mobile/screens/trip/tabs/MBookingsTab.tsx b/client/src/mobile/screens/trip/tabs/MBookingsTab.tsx index 43b901678..baea1ad24 100644 --- a/client/src/mobile/screens/trip/tabs/MBookingsTab.tsx +++ b/client/src/mobile/screens/trip/tabs/MBookingsTab.tsx @@ -1,4 +1,5 @@ -import { MapPin } from 'lucide-react' +import { MapPin, Navigation } from 'lucide-react' +import { useState } from 'react' import MDancingTrek from '../../../components/MDancingTrek' import { RES_ICONS } from '../../../../components/Planner/DayPlanSidebar.constants' import { formatTime, formatPriceText } from '../../../../utils/formatters' @@ -13,6 +14,8 @@ import { useReservationListFilter } from '../../../../components/Planner/booking import { useReservationCard } from '../../../../components/Planner/bookings/useReservationCard' import { orderedEndpoints, seatCells } from '../../../../utils/flightLegs' import { filesFor } from '../../../../utils/reservationFiles' +import { getNavigationTargets, openNavigationTarget } from '../../../../components/Planner/placeNavigation' +import { NavigationMenu } from '../../../../components/shared/NavigationMenu' /** * Tab 2 — Buchungen. Real `planner.reservations` filtered to the non-transport @@ -176,17 +179,16 @@ function BookingCard({ res, planner, canEdit, compact, onView }: { )} - - {res.location && ( -
- - {res.location} -
- )} - - + + + {res.notes?.trim() && ( + + )} + )} @@ -196,3 +198,40 @@ function BookingCard({ res, planner, canEdit, compact, onView }: { ) } + +/** + * Where the booking is (the hotel, the rental desk): a tap opens directions to + * it, as the address of a place does, in the traveller's map app or with the + * same choice of apps. + */ +function CardLocation({ location }: { location: string | null | undefined }) { + const { t } = useTranslation() + const [anchor, setAnchor] = useState(null) + const [menuOpen, setMenuOpen] = useState(false) + const text = location?.trim() + if (!text) return null + const targets = getNavigationTargets({ name: text, address: text, lat: null, lng: null, google_place_id: null, google_ftid: null }) + const openDirections = () => { + if (targets.length === 1) openNavigationTarget(targets[0]) + else if (targets.length > 1) setMenuOpen(true) + } + return ( + <> + + {menuOpen && ( + setMenuOpen(false)} title={t('inspector.openWith')} /> + )} + + ) +}