diff --git a/src/components/map/use-map-legs.ts b/src/components/map/use-map-legs.ts index 64d1d90d7..f754f4522 100644 --- a/src/components/map/use-map-legs.ts +++ b/src/components/map/use-map-legs.ts @@ -56,7 +56,9 @@ export const useMapLegs = ( t(ComponentText.Map.map.startPoint), background.accent[0], ); - const endTextPoint = createStartEndTextPoint(endMapLeg.points[0]); + const endTextPoint = createStartEndTextPoint( + endMapLeg.points[endMapLeg.points.length - 1], + ); const endTextLayer = createStartEndTextLayer( endTextSourceId, t(ComponentText.Map.map.endPoint), diff --git a/src/page-modules/assistant/details/trip-section/index.tsx b/src/page-modules/assistant/details/trip-section/index.tsx index deed93006..55b15ac57 100644 --- a/src/page-modules/assistant/details/trip-section/index.tsx +++ b/src/page-modules/assistant/details/trip-section/index.tsx @@ -82,7 +82,8 @@ export default function TripSection({ leg.serviceJourney?.id && leg.serviceDate && leg.fromPlace.quay?.id - ? `/departures/details/${leg.serviceJourney.id}?date=${leg.serviceDate}&fromQuayId=${leg.fromPlace.quay.id}` + ? `/departures/details/${leg.serviceJourney.id}?date=${leg.serviceDate}&fromQuayId=${leg.fromPlace.quay.id}` + + (leg.toPlace.quay?.id ? `&toQuayId=${leg.toPlace.quay.id}` : '') : undefined; return ( diff --git a/src/page-modules/departures/details/estimated-call-rows.tsx b/src/page-modules/departures/details/estimated-call-rows.tsx index 089c8d435..e3e27df8b 100644 --- a/src/page-modules/departures/details/estimated-call-rows.tsx +++ b/src/page-modules/departures/details/estimated-call-rows.tsx @@ -25,6 +25,7 @@ export type EstimatedCallRowsProps = { mode: TransportModeType; subMode?: TransportSubmode; alreadyShownSituationNumbers: string[]; + toQuayId?: string; }; export function EstimatedCallRows({ @@ -32,6 +33,7 @@ export function EstimatedCallRows({ mode, subMode, alreadyShownSituationNumbers, + toQuayId, }: EstimatedCallRowsProps) { const { t } = useTranslation(); const [collapsed, setCollapsed] = useState(true); @@ -89,6 +91,7 @@ export function EstimatedCallRows({ situations={getSituationsToShowForCall( call, alreadyShownSituationNumbers, + toQuayId, )} /> diff --git a/src/page-modules/departures/details/index.tsx b/src/page-modules/departures/details/index.tsx index ef74e49da..277792370 100644 --- a/src/page-modules/departures/details/index.tsx +++ b/src/page-modules/departures/details/index.tsx @@ -25,11 +25,13 @@ import { useGoBack } from '@atb/utils/use-go-back'; export type DeparturesDetailsProps = { fromQuayId?: string; + toQuayId?: string; serviceJourney: ServiceJourneyType; }; export function DeparturesDetails({ fromQuayId, + toQuayId, serviceJourney, }: DeparturesDetailsProps) { const { t } = useTranslation(); @@ -64,7 +66,7 @@ export function DeparturesDetails({ const estimatedCallsWithMetadata = addMetadataToEstimatedCalls( serviceJourney.estimatedCalls, fromQuayId, - undefined, + toQuayId, ); const notices = getNoticesForServiceJourney(serviceJourney, fromQuayId); @@ -143,6 +145,7 @@ export function DeparturesDetails({ mode={serviceJourney.transportMode ?? 'unknown'} subMode={serviceJourney.transportSubmode} alreadyShownSituationNumbers={alreadyShownSituationNumbers} + toQuayId={toQuayId} /> diff --git a/src/page-modules/departures/server/journey-planner/index.ts b/src/page-modules/departures/server/journey-planner/index.ts index 38abd1d1c..1ef03182a 100644 --- a/src/page-modules/departures/server/journey-planner/index.ts +++ b/src/page-modules/departures/server/journey-planner/index.ts @@ -64,6 +64,7 @@ export type ServiceJourneyInput = { id: string; date: Date; fromQuayId: string; + toQuayId?: string; }; export type JourneyPlannerApi = { @@ -251,6 +252,12 @@ export function createJourneyApi( (call) => call.quay.id === input.fromQuayId, )?.quay?.stopPlace; + const toStopPlace = input.toQuayId + ? serviceJourney?.estimatedCalls?.find( + (call) => call.quay.id === input.toQuayId, + )?.quay?.stopPlace + : undefined; + return { ...serviceJourney, mapLegs: mapToMapLegs( @@ -258,6 +265,7 @@ export function createJourneyApi( transportMode, transportSubmode, fromStopPlace, + toStopPlace, ), }; }, diff --git a/src/pages/departures/details/[id].tsx b/src/pages/departures/details/[id].tsx index a918fc320..8377ed40a 100644 --- a/src/pages/departures/details/[id].tsx +++ b/src/pages/departures/details/[id].tsx @@ -31,15 +31,21 @@ export const getServerSideProps = withAccessLogging( const id = params.id.toString(); const date = new Date(query.date.toString()); const fromQuayId = query.fromQuayId.toString(); + const toQuayId = query.toQuayId?.toString(); const serviceJourney = await client.serviceJourney({ id, date, fromQuayId, + toQuayId, }); return { - props: { fromQuayId, serviceJourney: serviceJourney }, + props: { + fromQuayId, + serviceJourney: serviceJourney, + ...(toQuayId ? { toQuayId } : {}), + }, }; }, ),