From a00648d1f0668cd26d1a7949353332c3fc0926cb Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Tue, 4 Jun 2024 14:27:19 -0400 Subject: [PATCH] support agency clearlist for field trip requests --- lib/actions/apiV2.js | 4 +++- lib/actions/field-trip.js | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/actions/apiV2.js b/lib/actions/apiV2.js index b51cf1cbc..8a0472b87 100644 --- a/lib/actions/apiV2.js +++ b/lib/actions/apiV2.js @@ -939,7 +939,8 @@ export function routingQuery(searchId = null, updateSearchInReducer) { modes, numItineraries, routingType, - time + time, + unpreferred } = currentQuery const arriveBy = departArrive === 'ARRIVE' @@ -997,6 +998,7 @@ export function routingQuery(searchId = null, updateSearchInReducer) { numItineraries: numItineraries || config?.modes?.numItineraries || 7, time, to: currentQuery.to, + unpreferred, // TODO: Does this break everything? ...currentQuery } diff --git a/lib/actions/field-trip.js b/lib/actions/field-trip.js index da34ec27b..9c2b771dd 100644 --- a/lib/actions/field-trip.js +++ b/lib/actions/field-trip.js @@ -495,6 +495,9 @@ export function saveRequestTripItineraries(request, outbound, intl) { function prepareQueryParams(request, outbound) { return async function (dispatch, getState) { const { config } = getState().otp + const { modules, transitOperators } = config + const fieldTripOptions = modules?.find((m) => m.id === 'ft')?.options + const queryParams = { date: format(parseDate(request.travelDate), OTP_API_DATE_FORMAT) } @@ -520,6 +523,16 @@ function prepareQueryParams(request, outbound) { OTP_API_TIME_FORMAT ) } + // Generate banned list from clear list + if (fieldTripOptions?.allowedAgencies) { + const bannedAgencies = transitOperators + .map((to) => to.agencyId) + .filter((to) => !fieldTripOptions.allowedAgencies.includes(to)) + + queryParams.unpreferred = { + agencies: bannedAgencies + } + } const locations = await planParamsToQueryAsync(locationsToGeocode, config) return dispatch(setQueryParam({ ...locations, ...queryParams })) }