Skip to content

Commit 901901b

Browse files
Merge branch 'dev' into build-with-vite
2 parents 76969a0 + 92742b3 commit 901901b

21 files changed

+886
-743
lines changed

__tests__/components/viewers/__snapshots__/nearby-view.js.snap

Lines changed: 593 additions & 593 deletions
Large diffs are not rendered by default.

__tests__/components/viewers/__snapshots__/stop-schedule-viewer.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ exports[`components > viewers > stop viewer should render with initial stop id a
211211
>
212212
<Styled(styled.span)>
213213
<span
214-
className="sc-bSFUlv sc-jvfqPk gFxSud bAWwqY"
214+
className="sc-hkwmXC sc-bSFUlv eFsrhn gAUjbw"
215215
>
216216
<ArrowLeft>
217217
<StyledIconBase
@@ -267,11 +267,11 @@ exports[`components > viewers > stop viewer should render with initial stop id a
267267
</div>
268268
<styled.div>
269269
<div
270-
className="sc-hRxcUd bbPqpb"
270+
className="sc-bTRMho fIdSEr"
271271
>
272272
<styled.div>
273273
<div
274-
className="sc-hYAvtR eOlYfy"
274+
className="sc-iWRHom bUIXtU"
275275
>
276276
<h1>
277277
<FormattedMessage

example/example-config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@ itinerary:
438438
previewOverlay: false
439439
# Whether to add a OTP_RR_A11Y_ROUTING_ENABLED error to all itineraries with accessibility scores
440440
displayA11yError: false
441+
# Whether to add OTP_RR_MICROBILITY_SUBJECT_TO_CHANGE error to all searches that include micromobiity rental.
442+
displayMicromobilityRentalError: false
441443
# Whether to display itinerary info in the side of the preview or next to the departure times
442444
showInlineItinerarySummary: false
443445
# Whether to sync the sort type with the depart/arrive time in the date/time modal

i18n/en-US.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,9 @@ components:
360360
title: Define Your Mobility Profile
361361
NarrativeItinerariesHeader:
362362
changeSortDir: Change sort direction
363-
howToFindResults: To view results, see the Itineraries Found heading below.
363+
howToFindResults: >-
364+
To view results, see the Itineraries Found heading below. To see itinerary
365+
details, select a time button.
364366
itinerariesFound: >-
365367
{itineraryNum, plural, one {# itinerary found} other {# itineraries found}
366368
}

lib/actions/apiV2.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,8 @@ export const fetchNearby = (position, radius, currentServiceWeek) => {
504504
error.message =
505505
'Check error.cause for more information. Are the OTP server and client on compatible versions?'
506506
error.cause = payload.errors
507-
throw error
507+
// TODO: How to present this error to the user?
508+
console.error({ error })
508509
}
509510
return {
510511
coords: { lat, lon },
@@ -1203,27 +1204,36 @@ export function routingQuery(searchId = null, updateSearchInReducer) {
12031204
response.data?.plan?.routingErrors.filter(
12041205
(re) => re?.code !== 'NO_TRANSIT_CONNECTION'
12051206
)
1206-
if (
1207-
getActiveItineraries(getState())?.length > 0 &&
1208-
response?.data?.plan
1209-
) {
1210-
// Add accessibility error, if it is turned on
1207+
if (withCollapsedShortNames.length > 0 && response?.data?.plan) {
1208+
if (!response.data.plan?.routingErrors) {
1209+
response.data.plan.routingErrors = []
1210+
}
1211+
// Add configurable errors, if they're turned on.
12111212
const state = getState()
1212-
const { displayA11yError } = state.otp.config?.itinerary
1213+
const { displayA11yError, displayMicromobilityRentalWarning } =
1214+
state.otp.config?.itinerary
12131215
if (displayA11yError) {
12141216
if (
1215-
response.data.plan.itineraries.find(
1217+
withCollapsedShortNames.find(
12161218
(itin) => !!itin?.accessibilityScore
12171219
)
12181220
) {
1219-
if (!response.data.plan?.routingErrors) {
1220-
response.data.plan.routingErrors = []
1221-
}
12221221
response.data.plan.routingErrors.push({
12231222
code: 'OTP_RR_A11Y_ROUTING_ENABLED'
12241223
})
12251224
}
12261225
}
1226+
if (displayMicromobilityRentalWarning) {
1227+
if (
1228+
withCollapsedShortNames.find((itin) =>
1229+
itin.legs.find((leg) => leg.rentedBike)
1230+
)
1231+
) {
1232+
response.data.plan.routingErrors.push({
1233+
code: 'OTP_RR_MICROBILITY_SUBJECT_TO_CHANGE'
1234+
})
1235+
}
1236+
}
12271237
}
12281238

12291239
return {

lib/actions/form.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,40 @@ const checkIfOriginSetToCurrentPosition = (query, currentPosition) =>
176176
query?.from?.lat === currentPosition?.coords?.latitude &&
177177
query?.from?.lon === currentPosition?.coords?.longitude
178178

179+
function setTimeToNow() {
180+
return function (dispatch, getState) {
181+
const { homeTimezone } = getState().otp.config
182+
const now = coreUtils.time.getCurrentTime(homeTimezone)
183+
dispatch(settingQueryParam({ time: now }))
184+
}
185+
}
179186
/**
180187
* If departArrive is set to 'NOW', update the query time to current
181188
*/
182189
export function updateQueryTimeIfLeavingNow() {
190+
return function (dispatch, getState) {
191+
const state = getState()
192+
const { currentQuery } = state.otp
193+
if (currentQuery.departArrive === 'NOW') {
194+
dispatch(setTimeToNow())
195+
}
196+
}
197+
}
198+
/**
199+
* If d/t selector is blank, update the form fields on trip plan to avoid confusion
200+
*/
201+
export function updateDateTimeIfEmpty() {
183202
return function (dispatch, getState) {
184203
const state = getState()
185204
const { config, currentQuery } = state.otp
205+
const { date, time } = currentQuery
186206
const { homeTimezone } = config
187-
if (currentQuery.departArrive === 'NOW') {
188-
const now = coreUtils.time.getCurrentTime(homeTimezone)
189-
dispatch(settingQueryParam({ time: now }))
207+
if (!time) {
208+
dispatch(setTimeToNow())
209+
}
210+
if (!date) {
211+
const today = coreUtils.time.getCurrentDate(homeTimezone)
212+
dispatch(settingQueryParam({ date: today }))
190213
}
191214
}
192215
}

lib/components/app/batch-routing-panel.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ interface Props {
3131
mobile?: boolean
3232
routingQuery: () => void
3333
showUserSettings: boolean
34+
updateDateTimeIfEmpty: () => void
3435
updateQueryTimeIfLeavingNow: () => void
3536
}
3637

@@ -81,9 +82,15 @@ class BatchRoutingPanel extends Component<Props> {
8182
handleSubmit = (e: FormEvent) => e.preventDefault()
8283

8384
handlePlanTripClick = () => {
84-
const { currentQuery, intl, routingQuery, updateQueryTimeIfLeavingNow } =
85-
this.props
85+
const {
86+
currentQuery,
87+
intl,
88+
routingQuery,
89+
updateDateTimeIfEmpty,
90+
updateQueryTimeIfLeavingNow
91+
} = this.props
8692
updateQueryTimeIfLeavingNow()
93+
updateDateTimeIfEmpty()
8794
alertUserTripPlan(
8895
intl,
8996
currentQuery,
@@ -217,6 +224,15 @@ class BatchRoutingPanel extends Component<Props> {
217224
overflowY: 'hidden'
218225
}}
219226
>
227+
<InvisibleA11yLabel
228+
aria-live="assertive"
229+
as="div"
230+
role="alert"
231+
>
232+
{activeSearch?.pending > 0 && (
233+
<FormattedMessage id="common.forms.loading" />
234+
)}
235+
</InvisibleA11yLabel>
220236
<NarrativeItineraries />
221237
</div>
222238
</div>
@@ -250,6 +266,7 @@ const mapStateToProps = (state: any) => {
250266

251267
const mapDispatchToProps = {
252268
routingQuery: apiActions.routingQuery,
269+
updateDateTimeIfEmpty: formActions.updateDateTimeIfEmpty,
253270
updateQueryTimeIfLeavingNow: formActions.updateQueryTimeIfLeavingNow
254271
}
255272

lib/components/form/advanced-settings-button.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const StyledTransparentButton = styled.button`
1616
color: ${grey[800]};
1717
display: flex;
1818
gap: 7px;
19-
margin-bottom: 5px;
2019
`
2120

2221
const AdvancedSettingsButton = ({ onClick }: Props): JSX.Element => (

lib/components/form/advanced-settings-panel.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ const PanelOverlay = styled.div`
5858
top: 0;
5959
width: 100%;
6060
z-index: 100;
61+
62+
@media (max-width: 768px) {
63+
padding: 1em;
64+
}
6165
`
6266

6367
const GlobalSettingsContainer = styled.div`
@@ -283,7 +287,7 @@ const AdvancedSettingsPanel = ({
283287
<h1 className="header-text">{headerText}</h1>
284288
</HeaderContainer>
285289
<DtSelectorContainer>
286-
<DateTimeModal />
290+
<DateTimeModal departArriveDropdown />
287291
</DtSelectorContainer>
288292
{processedGlobalSettings.length > 0 && (
289293
<>

0 commit comments

Comments
 (0)