diff --git a/lib/actions/apiV2.js b/lib/actions/apiV2.js index 3b9eba694..70f116d2a 100644 --- a/lib/actions/apiV2.js +++ b/lib/actions/apiV2.js @@ -46,6 +46,7 @@ import { zoomToPlace } from './map' const { generateCombinations, generateOtp2Query } = coreUtils.queryGen const { getTripOptionsFromQuery, getUrlParams } = coreUtils.query +const { convertGraphQLResponseToLegacy } = coreUtils.itinerary const { randId } = coreUtils.storage const LIGHT_GRAY = '666666' @@ -782,47 +783,6 @@ const pickupDropoffTypeToOtp1 = (otp2Type) => { } } -/** - * Converts a leg from GraphQL format to legacy REST format. - * @param leg OTP2 GraphQL style leg - * @returns REST shaped leg - */ -const processLeg = (leg) => ({ - ...leg, - agencyBrandingUrl: leg.agency?.url, - agencyName: leg.agency?.name, - agencyUrl: leg.agency?.url, - alerts: aggregateAlerts( - leg.agency?.alerts, - leg.route?.alerts, - leg.to?.stop?.alerts, - leg.from?.stop?.alerts - ), - alightRule: pickupDropoffTypeToOtp1(leg.dropoffType), - boardRule: pickupDropoffTypeToOtp1(leg.pickupType), - dropOffBookingInfo: { - latestBookingTime: leg.dropOffBookingInfo - }, - from: { - ...leg.from, - stopCode: leg.from.stop?.code, - stopId: leg.from.stop?.gtfsId - }, - route: leg.route?.shortName, - routeColor: leg.route?.color, - routeId: leg.route?.id, - routeLongName: leg.route?.longName, - routeShortName: leg.route?.shortName, - routeTextColor: leg.route?.textColor, - to: { - ...leg.to, - stopCode: leg.to.stop?.code, - stopId: leg.to.stop?.gtfsId - }, - tripHeadsign: leg.trip?.tripHeadsign, - tripId: leg.trip?.gtfsId -}) - const queryParamConfig = { modeButtons: DelimitedArrayParam } export function routingQuery(searchId = null, updateSearchInReducer) { @@ -962,7 +922,7 @@ export function routingQuery(searchId = null, updateSearchInReducer) { const withCollapsedShortNames = response.data?.plan?.itineraries?.map((itin) => ({ ...itin, - legs: itin.legs?.map(processLeg) + legs: itin.legs?.map(convertGraphQLResponseToLegacy) })) /* It is possible for a NO_TRANSIT_CONNECTION error to be