Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

feat(mobile): open directions from a place's address and a booking's location

Mauricef3bdcf7ffbf5
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) {
</span>
)}
</div>
+ {/* 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 && (
- <div className="mt-[2px] font-geist text-[0.6875rem] leading-[1.4] text-m-muted"><bdi>{place.address}</bdi></div>
+ <div
+ className={`mt-[2px] font-geist text-[0.6875rem] leading-[1.4] text-m-muted${navTargets.length > 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()
+ }
+ },
+ }
+ : {})}
+ >
+ <bdi>{place.address}</bdi>
+ </div>
)}
{/* 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,16 +179,15 @@ function BookingCard({ res, planner, canEdit, compact, onView }: {
)}
<TravelerAvatars travelers={res.travelers || []} label={t('reservations.travelers.label')} />
+ </button>
- {res.location && (
- <div className="mt-2 flex items-center gap-[6px] rounded-[10px] border border-[color:var(--m-rowbr)] bg-m-card px-[10px] py-[7px]">
- <MapPin size={12} strokeWidth={2} className="flex-none text-m-muted" />
- <span dir="auto" className="truncate text-[0.71875rem] font-semibold text-m-ink">{res.location}</span>
- </div>
- )}
+ <CardLocation location={res.location} />
- <CardNotes notes={res.notes} />
- </button>
+ {res.notes?.trim() && (
+ <button type="button" onClick={onView} className="block w-full text-start">
+ <CardNotes notes={res.notes} />
+ </button>
+ )}
<CardFiles files={files} card={card} t={t} />
</div>
@@ -196,3 +198,40 @@ function BookingCard({ res, planner, canEdit, compact, onView }: {
</div>
)
}
+
+/**
+ * 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<HTMLButtonElement | null>(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 (
+ <>
+ <button
+ ref={setAnchor}
+ type="button"
+ onClick={openDirections}
+ disabled={targets.length === 0}
+ aria-label={`${t('inspector.navigation')}: ${text}`}
+ className="mt-2 flex w-full items-center gap-[6px] rounded-[10px] border border-[color:var(--m-rowbr)] bg-m-card px-[10px] py-[7px] text-start"
+ >
+ <MapPin size={12} strokeWidth={2} className="flex-none text-m-muted" />
+ <span dir="auto" className="min-w-0 flex-1 truncate text-[0.71875rem] font-semibold text-m-ink">{text}</span>
+ {targets.length > 0 && <Navigation size={12} strokeWidth={2} aria-hidden="true" className="flex-none text-m-muted" />}
+ </button>
+ {menuOpen && (
+ <NavigationMenu targets={targets} anchor={anchor} onClose={() => setMenuOpen(false)} title={t('inspector.openWith')} />
+ )}
+ </>
+ )
+}