diff --git a/example-config.yml b/example-config.yml index 554c8ee6a..34bbc4843 100644 --- a/example-config.yml +++ b/example-config.yml @@ -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 diff --git a/lib/actions/apiV2.js b/lib/actions/apiV2.js index 0089de87c..229efd599 100644 --- a/lib/actions/apiV2.js +++ b/lib/actions/apiV2.js @@ -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 { diff --git a/lib/components/narrative/metro/metro-error-renderer.tsx b/lib/components/narrative/metro/metro-error-renderer.tsx index 92a8838f8..fec7bb76b 100644 --- a/lib/components/narrative/metro/metro-error-renderer.tsx +++ b/lib/components/narrative/metro/metro-error-renderer.tsx @@ -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 @@ -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) => ( + + ) }} />