Skip to content

Commit

Permalink
new itinerary flag to enable error on accessible trips
Browse files Browse the repository at this point in the history
  • Loading branch information
miles-grant-ibigroup committed Dec 5, 2023
1 parent 14f33a5 commit 654aea4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions example-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ itinerary:
showScheduleDeviation: true
# Shows the duration of a leg below the leg in the metro itinerary summary
showLegDurations: false
# Whether to add a OTP_RR_A11Y_ROUTING_ENABLED error to all itineraries with accessibility scores
displayA11yError: false
# The sort option to use by default
# Available sort options: 'BEST', 'DURATION', 'ARRIVALTIME', 'WALKTIME', 'COST', 'DEPARTURETIME'
# defaultSort: "BEST" # Default
Expand Down
18 changes: 18 additions & 0 deletions lib/actions/apiV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,24 @@ export function routingQuery(searchId = null, updateSearchInReducer) {
response.data?.plan?.routingErrors.filter(
(re) => re?.code !== 'NO_TRANSIT_CONNECTION'
)

// Add accessibility error, if it is turned on
const state = getState()
const { displayA11yError } = state.otp.config?.itinerary
if (displayA11yError) {
if (
response.data.plan.itineraries.find(
(itin) => !!itin?.accessibilityScore
)
) {
if (!response.data.plan?.routingErrors) {
response.data.plan.routingErrors = []
}
response.data.plan.routingErrors.push({
code: 'OTP_RR_A11Y_ROUTING_ENABLED'
})
}
}
}

return {
Expand Down
13 changes: 12 additions & 1 deletion lib/components/narrative/metro/metro-error-renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import styled from 'styled-components'

import { AppReduxState } from '../../../util/state-types'
import { Icon } from '../../util/styledIcon'
import { LinkOpensNewWindow } from '../../util/externalLink'

type Error = Record<string, string[]>

Expand Down Expand Up @@ -81,7 +82,17 @@ const ErrorRenderer = ({
id={`components.OTP2ErrorRenderer.${error}.body`}
values={{
inputFields: intl.formatList(localizedInputFieldList),
inputFieldsCount: localizedInputFieldList.length
inputFieldsCount: localizedInputFieldList.length,
link: (contents: JSX.Element) => (
<LinkOpensNewWindow
contents={contents}
inline
style={{ color: 'inherit' }}
url={intl.formatMessage({
id: `components.OTP2ErrorRenderer.${error}.link`
})}
/>
)
}}
/>
</p>
Expand Down

0 comments on commit 654aea4

Please sign in to comment.