Skip to content

Commit

Permalink
Merge branch 'dev' into date-restricted-requests
Browse files Browse the repository at this point in the history
  • Loading branch information
miles-grant-ibigroup authored Sep 25, 2024
2 parents f908764 + 711fac9 commit 7453827
Show file tree
Hide file tree
Showing 6 changed files with 268 additions and 29 deletions.
253 changes: 230 additions & 23 deletions __tests__/components/viewers/__snapshots__/nearby-view.js.snap

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions i18n/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ components:
distanceAway: "{localizedDistanceString} away"
error: An error occurred loading nearby amenities.
header: Nearby View
headsign: "{destination}"
nearbyListIntro: List of {count} nearby entities.
nothingNearby: There are no places nearby.
spacesAvailable: "{spacesAvailable} empty spaces available"
Expand Down
1 change: 1 addition & 0 deletions i18n/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ components:
distanceAway: à {localizedDistanceString}
error: Erreur lors du chargement des services à proximité.
header: À proximité
headsign: "{destination}"
nearbyListIntro: Liste de {count} entités à proximité.
nothingNearby: Aucun lieu à proximité.
spacesAvailable: "{spacesAvailable} emplacements libres disponibles"
Expand Down
28 changes: 25 additions & 3 deletions lib/components/map/default-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ class DefaultMap extends Component {
setLocation,
setViewedStop,
vehicleRentalQuery,
vehicleRentalStations
vehicleRentalStations,
viewedRouteStops
} = this.props
const { getCustomMapOverlays, getTransitiveRouteLabel, ModeIcon } =
this.context
Expand Down Expand Up @@ -405,7 +406,7 @@ class DefaultMap extends Component {
vectorTilesEndpoint,
setLocation,
setViewedStop,
null,
viewedRouteStops,
config.companies
)
default:
Expand All @@ -428,6 +429,26 @@ class DefaultMap extends Component {

const mapStateToProps = (state) => {
const activeSearch = getActiveSearch(state)
const viewedRoute = state.otp?.ui?.viewedRoute?.routeId
const nearbyViewerActive =
state.otp.ui.mainPanelContent === MainPanelContent.NEARBY_VIEW

const viewedRoutePatterns = Object.entries(
state.otp?.transitIndex?.routes?.[viewedRoute]?.patterns || {}
)
const viewedRouteStops =
viewedRoute && !nearbyViewerActive
? // Ensure we don't have duplicates
Array.from(
new Set(
// Generate a list of every stop id the pattern stops at
viewedRoutePatterns.reduce((acc, cur) => {
// Convert pattern object to list of the pattern's stops
return [...cur?.[1]?.stops.map((s) => s.id), ...acc]
}, [])
)
)
: null

return {
bikeRentalStations: state.otp.overlay.bikeRental.stations,
Expand All @@ -439,7 +460,8 @@ const mapStateToProps = (state) => {
state.otp.ui.mainPanelContent === MainPanelContent.NEARBY_VIEW,
pending: activeSearch ? Boolean(activeSearch.pending) : false,
query: state.otp.currentQuery,
vehicleRentalStations: state.otp.overlay.vehicleRental.stations
vehicleRentalStations: state.otp.overlay.vehicleRental.stations,
viewedRouteStops
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/components/map/point-popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function MapPopup({
// Override inline style supplied by react-map-gl to accommodate long "plan a trip" translations.
style={{ maxWidth: '260px', width: '260px' }}
>
<FocusTrapWrapper closePopup={clearMapPopupLocation} id="stop-popup">
<FocusTrapWrapper closePopup={clearMapPopupLocation} id="point-popup">
<PopupTitleWrapper>
<PopupTitle>
{typeof popupName === 'string' && popupName.split(',').length > 3
Expand Down
12 changes: 10 additions & 2 deletions lib/components/viewers/pattern-row.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Calendar } from '@styled-icons/fa-regular'
import { format, utcToZonedTime } from 'date-fns-tz'
import { FormattedMessage } from 'react-intl'
import { getMostReadableTextColor } from '@opentripplanner/core-utils/lib/route'
import { isSameDay } from 'date-fns'
import React, { useContext } from 'react'
Expand Down Expand Up @@ -108,8 +109,15 @@ const PatternRow = ({
{pattern.route.longName}
</strong>
)}
{extractHeadsignFromPattern(pattern) ||
(pattern.route.longName !== routeName && pattern.route.longName)}
<FormattedMessage
id="components.NearbyView.headsign"
values={{
destination:
extractHeadsignFromPattern(pattern) ||
(pattern.route.longName !== routeName &&
pattern.route.longName)
}}
/>
</span>
</div>
{/* next departure preview (only shows up to 3 entries) */}
Expand Down

0 comments on commit 7453827

Please sign in to comment.