From 2c6aacd1fd1c6563a48a8dc3507fa51acf68605d Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Tue, 29 Aug 2023 16:19:20 -0400 Subject: [PATCH] fix(batch ui): OTP2 fare support --- lib/components/narrative/default/default-itinerary.js | 8 ++++---- lib/util/state.js | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/components/narrative/default/default-itinerary.js b/lib/components/narrative/default/default-itinerary.js index f7f98e49c..bfbf25518 100644 --- a/lib/components/narrative/default/default-itinerary.js +++ b/lib/components/narrative/default/default-itinerary.js @@ -20,8 +20,8 @@ import { getAccessibilityScoreForItinerary, itineraryHasAccessibilityScores } from '../../../util/accessibility-routing' +import { getFare, getTotalFare } from '../../../util/state' import { getFirstLegStartTime } from '../../../util/itinerary' -import { getTotalFare } from '../../../util/state' import { Icon, StyledIconWrapperTextAlign } from '../../util/styledIcon' import { localizeGradationMap } from '../utils' import FieldTripGroupSize from '../../admin/field-trip-itinerary-group-size' @@ -121,7 +121,7 @@ const ITINERARY_ATTRIBUTES = [ id: 'cost', order: 2, render: (itinerary, options, defaultFareType) => { - const fare = getTotalFare(itinerary, options.configCosts, defaultFareType) + const fare = getFare(itinerary, defaultFareType) const currency = getItineraryCost( itinerary.legs, defaultFareType.mediumId, @@ -142,11 +142,11 @@ const ITINERARY_ATTRIBUTES = [ return ( ) } diff --git a/lib/util/state.js b/lib/util/state.js index 1d2f35f15..c25b0b615 100644 --- a/lib/util/state.js +++ b/lib/util/state.js @@ -99,8 +99,10 @@ export function getTotalFare( let drivingCost = 0 let hasBikeshare = false let transitFareNotProvided = false + let rideHailTrip = false itinerary.legs.forEach((leg) => { - if (leg.mode === 'CAR') { + rideHailTrip = rideHailTrip || leg?.rideHailingEstimate + if (leg.mode === 'CAR' && !rideHailTrip) { // Convert meters to miles and multiple by cost per mile. drivingCost += leg.distance * 0.000621371 * costs.drivingCentsPerMile } @@ -121,7 +123,7 @@ export function getTotalFare( if (transitFareNotProvided) return null const bikeshareCost = hasBikeshare ? costs.bikeshareTripCostCents : 0 // If some leg uses driving, add parking cost to the total. - if (drivingCost > 0) drivingCost += costs.carParkingCostCents + if (drivingCost > 0 && !rideHailTrip) drivingCost += costs.carParkingCostCents return bikeshareCost + drivingCost + transitFare + maxTNCFare * 100 }