Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions packages/core-utils/src/itinerary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
TncFare
} from "@opentripplanner/types";
import turfAlong from "@turf/along";
import { parseISO } from "date-fns";

// All OTP transit modes
export const transitModes = [
Expand Down Expand Up @@ -244,7 +245,7 @@ export function getCompanyFromLeg(leg: Leg): string {
return from.networks[0];
}
if (from.rentalVehicle) {
return from.rentalVehicle.network;
return from.rentalVehicle?.rentalNetwork?.networkId;
}
if (from.vehicleRentalStation?.rentalNetwork) {
return from.vehicleRentalStation.rentalNetwork.networkId;
Expand Down Expand Up @@ -787,7 +788,8 @@ const pickupDropoffTypeToOtp1 = otp2Type => {
}
};

export const convertGraphQLResponseToLegacy = (leg: any): any => ({
// TODO: Remove this method when moving to PlanConnection
export const convertGraphQLResponseToLegacy = (leg: any): Leg => ({
...leg,
agencyBrandingUrl: leg.agency?.url,
agencyId: leg.agency?.id,
Expand All @@ -804,6 +806,10 @@ export const convertGraphQLResponseToLegacy = (leg: any): any => ({
},
from: {
...leg.from,
endTime: parseISO(leg.from?.end?.estimated || leg.from?.end?.scheduledTime),
startTime: parseISO(
leg.from?.start?.estimated || leg.from?.start?.scheduledTime
),
stopCode: leg.from.stop?.code,
stopId: leg.from.stop?.gtfsId
},
Expand All @@ -815,6 +821,10 @@ export const convertGraphQLResponseToLegacy = (leg: any): any => ({
routeTextColor: leg.route?.textColor,
to: {
...leg.to,
endTime: parseISO(leg.to?.end?.estimated || leg.to?.end?.scheduledTime),
startTime: parseISO(
leg.to?.start?.estimated || leg.to?.start?.scheduledTime
),
stopCode: leg.to.stop?.code,
stopId: leg.to.stop?.gtfsId
},
Expand Down
Loading
Loading