From fd6d1969f5767eaecab4d21d7e935fd405a1781a Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 27 Nov 2026 23:15:45 +0100 Subject: [PATCH] feat(tours): open what a walk's stop has to tell under it A city walk's stops showed only their names. A stop standing for a trip place with a description, an address or a website now opens them under itself on a tap of its name, marked by a small chevron, without leaving the walk. Stops without anything more to say stay as they were. Addresses discussion #3205. --- .../Tours/walk/WalkStations.test.tsx | 37 ++++++++ .../components/Tours/walk/WalkStations.tsx | 84 ++++++++++++++++--- 2 files changed, 109 insertions(+), 12 deletions(-) diff --git a/client/src/components/Tours/walk/WalkStations.test.tsx b/client/src/components/Tours/walk/WalkStations.test.tsx index 944e38a12..960bfc303 100644 --- a/client/src/components/Tours/walk/WalkStations.test.tsx +++ b/client/src/components/Tours/walk/WalkStations.test.tsx @@ -284,6 +284,43 @@ describe('WalkStationsCard', () => { expect(within(cafe).queryByText(/Open/)).not.toBeInTheDocument(); }); + it('opens what the linked place has to tell under its stop, and leaves a stop without it as it is (#3205)', async () => { + seedStore(useTripStore, { + places: [ + buildPlace({ + id: 77, + name: 'Lenbachhaus', + description: 'Blue Rider collection', + address: 'Luisenstrasse 33', + website: 'https://lenbachhaus.de', + }), + ], + }); + vi.mocked(tourRepo.detail).mockImplementation(() => + detail([ + { lat: 48, lng: 11, role: 'start', sequence: 0, key: 'stop-01', linked_place_id: 77, stay_minutes: 60 }, + { lat: 48.002, lng: 11, role: 'end', sequence: 1, key: 'stop-02', name: 'Cafe', stay_minutes: 0 }, + ]) + ); + card(); + + const museum = await rowOf('Lenbachhaus'); + const toggle = within(museum).getByRole('button', { name: /Lenbachhaus/ }); + expect(toggle).toHaveAttribute('aria-expanded', 'false'); + expect(within(museum).queryByText('Blue Rider collection')).not.toBeInTheDocument(); + fireEvent.click(toggle); + expect(toggle).toHaveAttribute('aria-expanded', 'true'); + expect(within(museum).getByText('Blue Rider collection')).toBeInTheDocument(); + expect(within(museum).getByText('Luisenstrasse 33')).toBeInTheDocument(); + expect(within(museum).getByRole('link', { name: 'Open Website' })).toHaveAttribute( + 'href', + 'https://lenbachhaus.de' + ); + + const cafe = await rowOf('Cafe'); + expect(within(cafe).queryByRole('button', { name: /Cafe/ })).not.toBeInTheDocument(); + }); + it('shows the times in the 12 hour format where the user chose it', async () => { seedStore(useSettingsStore, { settings: { time_format: '12h' } }); card(onMonday()); diff --git a/client/src/components/Tours/walk/WalkStations.tsx b/client/src/components/Tours/walk/WalkStations.tsx index 316a5b415..abaf0a0ea 100644 --- a/client/src/components/Tours/walk/WalkStations.tsx +++ b/client/src/components/Tours/walk/WalkStations.tsx @@ -1,10 +1,13 @@ -import type { TourListItem, TourVisitStatus } from '@trek/shared'; -import { Check, CheckCheck, Info, Redo2, SkipForward, Undo2 } from 'lucide-react'; +import type { Place, TourListItem, TourVisitStatus } from '@trek/shared'; +import { Check, CheckCheck, ChevronDown, ExternalLink, Info, MapPin, Redo2, SkipForward, Undo2 } from 'lucide-react'; +import { useState } from 'react'; import { useTranslation } from '../../../i18n'; import { useTourVisitStore } from '../../../store/tourVisitStore'; import type { Assignment, AssignmentsMap, Day } from '../../../types'; +import { safeHttpUrl } from '../../../utils/safeUrl'; import { SoftPill } from '../../Planner/planParts'; import { DialogSection, fs } from '../../shared/DialogShell'; +import MarkdownText from '../../shared/MarkdownText'; import { useToast } from '../../shared/Toast'; import { stationMarkNote, stationRingClass } from '../planner/stationMarks'; import { StationPills, StationShield } from '../planner/stationParts'; @@ -83,23 +86,62 @@ function StatusActions({ * trip place it stands for), stay, the day's arrival and opening hours, and * what can be marked. */ +/** What a station's linked place has to tell (#3205): its description, address and website. */ +function placeDetailsOf(place: Place | null | undefined) { + if (!place) return null; + const description = place.description?.trim() || ''; + const address = place.address?.trim() || ''; + const website = safeHttpUrl(place.website); + return description || address || website ? { description, address, website } : null; +} + +/** The linked place's details, opened under its station without leaving the walk. */ +function StationDetails({ details }: { details: NonNullable> }) { + const { t } = useTranslation(); + return ( + + {details.description && {details.description}} + {details.address && ( + + + )} + {details.website && ( + + + )} + + ); +} + function StationRow({ station, index, status, - placeName, + place, schedule, onMark, }: { station: TourPlannerWaypoint; index: number; status: TourVisitStatus | undefined; - placeName: string | undefined; + place: Place | null; schedule: StationSchedule | undefined; onMark: ((status: TourVisitStatus | 'planned') => void) | null; }) { const { t } = useTranslation(); - const name = station.name ?? placeName ?? t('tours.walk.stationNumbered', { number: index + 1 }); + const [open, setOpen] = useState(false); + const details = placeDetailsOf(place); + const name = station.name ?? place?.name ?? t('tours.walk.stationNumbered', { number: index + 1 }); + const nameClass = `truncate font-semibold text-content ${status === 'skipped' ? 'line-through' : ''}`; return (
  • } - - {name} - + {details ? ( + // A station that has more to tell opens it in place (#3205). + + ) : ( + + {name} + + )} + {open && details && } {status && ( @@ -252,7 +312,7 @@ export function WalkStationsCard({ station={station} index={index} status={station.key ? visits?.[station.key] : undefined} - placeName={placeOf(station)?.name} + place={placeOf(station)} schedule={schedule.byStation.get(station.id)} onMark={marking === 'ready' && station.key ? (next) => onMark(station.key ?? '', next) : null} />