@opentripplanner/trip-details 7.0.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/components/departure-date.js +42 -0
- package/esm/components/departure-date.js.map +1 -0
- package/esm/components/emissions.js +68 -0
- package/esm/components/emissions.js.map +1 -0
- package/esm/{fare-table.js → components/fare-table.js} +6 -6
- package/esm/components/fare-table.js.map +1 -0
- package/esm/components/fares.js +151 -0
- package/esm/components/fares.js.map +1 -0
- package/esm/components/flex-booking-info.js +51 -0
- package/esm/components/flex-booking-info.js.map +1 -0
- package/esm/components/time-active.js +69 -0
- package/esm/components/time-active.js.map +1 -0
- package/esm/index.js +40 -289
- package/esm/index.js.map +1 -1
- package/esm/trip-detail.js +4 -2
- package/esm/trip-detail.js.map +1 -1
- package/esm/types.js.map +1 -1
- package/lib/components/departure-date.d.ts +10 -0
- package/lib/components/departure-date.d.ts.map +1 -0
- package/lib/components/departure-date.js +51 -0
- package/lib/components/departure-date.js.map +1 -0
- package/lib/components/emissions.d.ts +8 -0
- package/lib/components/emissions.d.ts.map +1 -0
- package/lib/components/emissions.js +75 -0
- package/lib/components/emissions.js.map +1 -0
- package/lib/{fare-table.d.ts → components/fare-table.d.ts} +1 -1
- package/lib/components/fare-table.d.ts.map +1 -0
- package/lib/{fare-table.js → components/fare-table.js} +6 -6
- package/lib/components/fare-table.js.map +1 -0
- package/lib/components/fares.d.ts +10 -0
- package/lib/components/fares.d.ts.map +1 -0
- package/lib/components/fares.js +162 -0
- package/lib/components/fares.js.map +1 -0
- package/lib/components/flex-booking-info.d.ts +6 -0
- package/lib/components/flex-booking-info.d.ts.map +1 -0
- package/lib/components/flex-booking-info.js +47 -0
- package/lib/components/flex-booking-info.js.map +1 -0
- package/lib/components/time-active.d.ts +14 -0
- package/lib/components/time-active.d.ts.map +1 -0
- package/lib/components/time-active.js +79 -0
- package/lib/components/time-active.js.map +1 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +27 -262
- package/lib/index.js.map +1 -1
- package/lib/trip-detail.d.ts +2 -1
- package/lib/trip-detail.d.ts.map +1 -1
- package/lib/trip-detail.js +4 -2
- package/lib/trip-detail.js.map +1 -1
- package/lib/types.d.ts +20 -19
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +3 -3
- package/src/TripDetails.story.tsx +26 -28
- package/src/__snapshots__/TripDetails.story.tsx.snap +108 -108
- package/src/components/departure-date.tsx +53 -0
- package/src/components/emissions.tsx +97 -0
- package/src/{fare-table.tsx → components/fare-table.tsx} +4 -4
- package/src/components/fares.tsx +205 -0
- package/src/components/flex-booking-info.tsx +57 -0
- package/src/components/time-active.tsx +90 -0
- package/src/index.tsx +28 -365
- package/src/trip-detail.tsx +8 -2
- package/src/types.ts +18 -17
- package/tsconfig.tsbuildinfo +1 -1
- package/esm/fare-table.js.map +0 -1
- package/lib/fare-table.d.ts.map +0 -1
- package/lib/fare-table.js.map +0 -1
package/src/index.tsx
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import React, { ReactElement, ReactNode } from "react";
|
|
4
|
-
import { FormattedMessage, FormattedNumber } from "react-intl";
|
|
5
|
-
import { CalendarAlt } from "@styled-icons/fa-solid/CalendarAlt";
|
|
6
|
-
import { Heartbeat } from "@styled-icons/fa-solid/Heartbeat";
|
|
7
|
-
import { MoneyBillAlt } from "@styled-icons/fa-solid/MoneyBillAlt";
|
|
8
|
-
import { Leaf } from "@styled-icons/fa-solid/Leaf";
|
|
9
|
-
import { Route } from "@styled-icons/fa-solid/Route";
|
|
1
|
+
import React, { ReactElement } from "react";
|
|
2
|
+
import { FormattedMessage } from "react-intl";
|
|
10
3
|
import { flatten } from "flat";
|
|
11
4
|
import * as S from "./styled";
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
import
|
|
5
|
+
import FareLegTable from "./components/fare-table";
|
|
6
|
+
import { TripDetailsProps } from "./types";
|
|
7
|
+
import FlexBookingInfo from "./components/flex-booking-info";
|
|
8
|
+
import Emissions from "./components/emissions";
|
|
9
|
+
import Fares from "./components/fares";
|
|
10
|
+
import TimeActive, { DefaultTimeActiveDetails } from "./components/time-active";
|
|
11
|
+
import DepartureDate from "./components/departure-date";
|
|
17
12
|
|
|
18
13
|
// Load the default messages.
|
|
19
14
|
import defaultEnglishMessages from "../i18n/en-US.yml";
|
|
@@ -24,39 +19,8 @@ import defaultEnglishMessages from "../i18n/en-US.yml";
|
|
|
24
19
|
// - the yaml loader for jest returns messages with flattened ids.
|
|
25
20
|
const defaultMessages: Record<string, string> = flatten(defaultEnglishMessages);
|
|
26
21
|
|
|
27
|
-
function
|
|
28
|
-
return
|
|
29
|
-
<a
|
|
30
|
-
href="https://www.itf-oecd.org/sites/default/files/life-cycle-assessment-calculations-2020.xlsx"
|
|
31
|
-
rel="noopener noreferrer"
|
|
32
|
-
target="_blank"
|
|
33
|
-
>
|
|
34
|
-
{contents}
|
|
35
|
-
</a>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Default rendering if no component is provided for the TimeActiveDetails
|
|
40
|
-
* slot in the TripDetails component.
|
|
41
|
-
*/
|
|
42
|
-
function DefaultTimeActiveDetails({
|
|
43
|
-
bikeMinutes,
|
|
44
|
-
walkMinutes
|
|
45
|
-
}: TimeActiveDetailsProps): ReactElement {
|
|
46
|
-
return (
|
|
47
|
-
<FormattedMessage
|
|
48
|
-
defaultMessage={
|
|
49
|
-
defaultMessages["otpUi.TripDetails.timeActiveDescription"]
|
|
50
|
-
}
|
|
51
|
-
description="Text describing the walking and biking durations of a trip."
|
|
52
|
-
id="otpUi.TripDetails.timeActiveDescription"
|
|
53
|
-
values={{
|
|
54
|
-
bikeMinutes,
|
|
55
|
-
strong: boldText,
|
|
56
|
-
walkMinutes
|
|
57
|
-
}}
|
|
58
|
-
/>
|
|
59
|
-
);
|
|
22
|
+
function cn(className: string, arg1: string): string {
|
|
23
|
+
return className ? `${className} ${arg1}` : arg1;
|
|
60
24
|
}
|
|
61
25
|
|
|
62
26
|
/**
|
|
@@ -65,188 +29,15 @@ function DefaultTimeActiveDetails({
|
|
|
65
29
|
export function TripDetails({
|
|
66
30
|
className = "",
|
|
67
31
|
co2Config,
|
|
68
|
-
defaultFareType,
|
|
69
32
|
DepartureDetails = null,
|
|
70
|
-
displayTimeActive = true,
|
|
71
33
|
FareDetails = null,
|
|
72
|
-
|
|
73
|
-
fareKeyNameMap = {},
|
|
34
|
+
fareConfig,
|
|
74
35
|
itinerary,
|
|
75
36
|
showApproximateMinutesActive,
|
|
76
37
|
TimeActiveDetails = DefaultTimeActiveDetails
|
|
77
38
|
}: TripDetailsProps): ReactElement {
|
|
78
|
-
// process the transit fare
|
|
79
|
-
const fareResult = coreUtils.itinerary.calculateTncFares(itinerary);
|
|
80
|
-
const { currencyCode, maxTNCFare, minTNCFare } = fareResult;
|
|
81
|
-
|
|
82
|
-
const { companies, fareTypes } = itinerary.legs.reduce<{
|
|
83
|
-
companies: string;
|
|
84
|
-
fareTypes: FareProductSelector[];
|
|
85
|
-
}>(
|
|
86
|
-
(prev, leg) => {
|
|
87
|
-
if (leg.rideHailingEstimate) {
|
|
88
|
-
prev.companies = leg.rideHailingEstimate.provider.id;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (leg.fareProducts) {
|
|
92
|
-
leg.fareProducts.forEach(fp => {
|
|
93
|
-
const mediumId = fp.product.medium?.id;
|
|
94
|
-
const riderCategoryId = fp.product.riderCategory?.id;
|
|
95
|
-
if (
|
|
96
|
-
!prev.fareTypes.find(
|
|
97
|
-
ft =>
|
|
98
|
-
ft.mediumId === mediumId &&
|
|
99
|
-
ft.riderCategoryId === riderCategoryId
|
|
100
|
-
)
|
|
101
|
-
) {
|
|
102
|
-
prev.fareTypes.push({ mediumId, riderCategoryId });
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
return prev;
|
|
107
|
-
},
|
|
108
|
-
{ companies: "", fareTypes: [] }
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
let fare;
|
|
112
|
-
if (fareTypes.length > 0 && defaultFareType) {
|
|
113
|
-
const defaultFareTotal = coreUtils.itinerary.getItineraryCost(
|
|
114
|
-
itinerary.legs,
|
|
115
|
-
defaultFareType.mediumId,
|
|
116
|
-
defaultFareType.riderCategoryId
|
|
117
|
-
);
|
|
118
|
-
// Depending on if there are additional fares to display either render a <span> or a <details>
|
|
119
|
-
const TransitFareWrapper =
|
|
120
|
-
fareTypes.length > 1 ? S.TransitFare : S.TransitFareSingle;
|
|
121
|
-
|
|
122
|
-
const fareNameFallback = (
|
|
123
|
-
<FormattedMessage
|
|
124
|
-
defaultMessage={defaultMessages["otpUi.TripDetails.transitFare"]}
|
|
125
|
-
description="Text showing the price of tickets on public transportation."
|
|
126
|
-
id="otpUi.TripDetails.transitFare"
|
|
127
|
-
/>
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
fare = defaultFareTotal !== undefined && (
|
|
131
|
-
<S.Fare>
|
|
132
|
-
<TransitFareWrapper>
|
|
133
|
-
<summary style={{ display: fareTypes.length > 1 ? "list-item" : "" }}>
|
|
134
|
-
<FormattedMessage
|
|
135
|
-
defaultMessage={
|
|
136
|
-
defaultMessages["otpUi.TripDetails.transitFareEntry"]
|
|
137
|
-
}
|
|
138
|
-
description="Text showing the price of tickets on public transportation."
|
|
139
|
-
id="otpUi.TripDetails.transitFareEntry"
|
|
140
|
-
values={{
|
|
141
|
-
name:
|
|
142
|
-
fareKeyNameMap[defaultFareType.headerKey] || fareNameFallback,
|
|
143
|
-
strong: boldText,
|
|
144
|
-
value: renderFare(
|
|
145
|
-
defaultFareTotal.currency?.code || "USD",
|
|
146
|
-
defaultFareTotal?.amount
|
|
147
|
-
)
|
|
148
|
-
}}
|
|
149
|
-
/>
|
|
150
|
-
</summary>
|
|
151
|
-
{fareDetailsLayout ? (
|
|
152
|
-
// Show full ƒare details by leg
|
|
153
|
-
<FareLegTable layout={fareDetailsLayout} legs={itinerary.legs} />
|
|
154
|
-
) : (
|
|
155
|
-
// Just show the fares for each payment type
|
|
156
|
-
fareTypes.map(fareType => {
|
|
157
|
-
// Don't show the default fare twice!
|
|
158
|
-
if (fareType) {
|
|
159
|
-
return null;
|
|
160
|
-
}
|
|
161
|
-
return (
|
|
162
|
-
<FormattedMessage
|
|
163
|
-
defaultMessage={
|
|
164
|
-
defaultMessages["otpUi.TripDetails.transitFareEntry"]
|
|
165
|
-
}
|
|
166
|
-
description="Text showing the price of tickets on public transportation."
|
|
167
|
-
id="otpUi.TripDetails.transitFareEntry"
|
|
168
|
-
key={Object.values(fareType).join("-")}
|
|
169
|
-
values={{
|
|
170
|
-
name:
|
|
171
|
-
fareKeyNameMap[defaultFareType.headerKey] ||
|
|
172
|
-
fareNameFallback,
|
|
173
|
-
strong: boldText,
|
|
174
|
-
value: renderFare(
|
|
175
|
-
defaultFareTotal.currency?.code || "USD",
|
|
176
|
-
defaultFareTotal?.amount /
|
|
177
|
-
defaultFareTotal?.currency?.digits
|
|
178
|
-
)
|
|
179
|
-
}}
|
|
180
|
-
/>
|
|
181
|
-
);
|
|
182
|
-
})
|
|
183
|
-
)}
|
|
184
|
-
</TransitFareWrapper>
|
|
185
|
-
</S.Fare>
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
const tncFare = minTNCFare !== 0 && (
|
|
189
|
-
<S.Fare>
|
|
190
|
-
<S.TNCFare>
|
|
191
|
-
<FormattedMessage
|
|
192
|
-
defaultMessage={defaultMessages["otpUi.TripDetails.tncFare"]}
|
|
193
|
-
description="Text showing the price paid to transportation network companies."
|
|
194
|
-
id="otpUi.TripDetails.tncFare"
|
|
195
|
-
values={{
|
|
196
|
-
companies: (
|
|
197
|
-
// S.TNCFareCompanies capitalizes the TNC company ID (e.g. "COMPANY")
|
|
198
|
-
// after it is converted to lowercase, so it renders as "Company".
|
|
199
|
-
<S.TNCFareCompanies>{companies.toLowerCase()}</S.TNCFareCompanies>
|
|
200
|
-
),
|
|
201
|
-
maxTNCFare: renderFare(currencyCode, maxTNCFare),
|
|
202
|
-
minTNCFare: renderFare(currencyCode, minTNCFare),
|
|
203
|
-
strong: boldText
|
|
204
|
-
}}
|
|
205
|
-
/>
|
|
206
|
-
</S.TNCFare>
|
|
207
|
-
</S.Fare>
|
|
208
|
-
);
|
|
209
|
-
|
|
210
|
-
const departureDate = new Date(itinerary.startTime);
|
|
211
|
-
|
|
212
|
-
// Compute total time spent active.
|
|
213
|
-
|
|
214
|
-
// TODO: separate into two reducers
|
|
215
|
-
let walkDurationSeconds = 0;
|
|
216
|
-
let bikeDurationSeconds = 0;
|
|
217
|
-
itinerary.legs.forEach(leg => {
|
|
218
|
-
if (leg.mode.startsWith("WALK")) walkDurationSeconds += leg.duration;
|
|
219
|
-
if (leg.mode.startsWith("BICYCLE")) bikeDurationSeconds += leg.duration;
|
|
220
|
-
});
|
|
221
|
-
const bikeMinutes = Math.round(bikeDurationSeconds / 60);
|
|
222
|
-
const walkMinutes = Math.round(walkDurationSeconds / 60);
|
|
223
|
-
const minutesActive = bikeMinutes + walkMinutes;
|
|
224
|
-
|
|
225
|
-
// Calculate CO₂ if it's not provided by the itinerary
|
|
226
|
-
const co2 =
|
|
227
|
-
itinerary.co2 ||
|
|
228
|
-
(co2Config?.enabled &&
|
|
229
|
-
coreUtils.itinerary.calculateEmissions(
|
|
230
|
-
itinerary,
|
|
231
|
-
co2Config?.carbonIntensity,
|
|
232
|
-
co2Config?.units
|
|
233
|
-
));
|
|
234
|
-
|
|
235
|
-
// Parse flex info and generate appropriate strings
|
|
236
|
-
const containsFlex = itinerary.legs.some(coreUtils.itinerary.isFlex);
|
|
237
|
-
const pickupBookingInfo = itinerary.legs
|
|
238
|
-
.map(leg => leg.pickupBookingInfo)
|
|
239
|
-
.filter(info => !!info);
|
|
240
|
-
const dropOffBookingInfo = itinerary.legs
|
|
241
|
-
.map(leg => leg.dropOffBookingInfo)
|
|
242
|
-
.filter(info => !!info);
|
|
243
|
-
const totalDistance = itinerary.legs.reduce(
|
|
244
|
-
(total, leg) => total + leg.distance,
|
|
245
|
-
0
|
|
246
|
-
);
|
|
247
|
-
|
|
248
39
|
return (
|
|
249
|
-
<S.TripDetails className={className}>
|
|
40
|
+
<S.TripDetails className={cn(className, "trip-details")}>
|
|
250
41
|
{/* this can be presentation as S.TripDetails is already labeled by this */}
|
|
251
42
|
<S.TripDetailsHeader id="trip-details-header">
|
|
252
43
|
<FormattedMessage
|
|
@@ -256,150 +47,22 @@ export function TripDetails({
|
|
|
256
47
|
/>
|
|
257
48
|
</S.TripDetailsHeader>
|
|
258
49
|
<S.TripDetailsBody>
|
|
259
|
-
<
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
id="otpUi.TripDetails.departure"
|
|
273
|
-
values={{
|
|
274
|
-
departureDate,
|
|
275
|
-
strong: boldText
|
|
276
|
-
}}
|
|
277
|
-
/>
|
|
278
|
-
</S.Timing>
|
|
279
|
-
}
|
|
50
|
+
<DepartureDate
|
|
51
|
+
itinerary={itinerary}
|
|
52
|
+
DepartureDetails={DepartureDetails}
|
|
53
|
+
/>
|
|
54
|
+
<Fares
|
|
55
|
+
itinerary={itinerary}
|
|
56
|
+
fareConfig={fareConfig}
|
|
57
|
+
FareDetails={FareDetails}
|
|
58
|
+
/>
|
|
59
|
+
<TimeActive
|
|
60
|
+
itinerary={itinerary}
|
|
61
|
+
TimeActiveDetails={TimeActiveDetails}
|
|
62
|
+
showApproximateMinutesActive={showApproximateMinutesActive}
|
|
280
63
|
/>
|
|
281
|
-
{
|
|
282
|
-
|
|
283
|
-
// Any custom description for the transit fare needs to be handled by the slot.
|
|
284
|
-
description={
|
|
285
|
-
FareDetails && (
|
|
286
|
-
<FareDetails
|
|
287
|
-
legs={itinerary.legs}
|
|
288
|
-
maxTNCFare={maxTNCFare}
|
|
289
|
-
minTNCFare={minTNCFare}
|
|
290
|
-
/>
|
|
291
|
-
)
|
|
292
|
-
}
|
|
293
|
-
icon={<MoneyBillAlt size={17} />}
|
|
294
|
-
summary={fare}
|
|
295
|
-
/>
|
|
296
|
-
)}
|
|
297
|
-
{tncFare && (
|
|
298
|
-
<TripDetail
|
|
299
|
-
// Any custom description for the transit fare needs to be handled by the slot.
|
|
300
|
-
description={
|
|
301
|
-
FareDetails && (
|
|
302
|
-
<FareDetails
|
|
303
|
-
legs={itinerary.legs}
|
|
304
|
-
maxTNCFare={maxTNCFare}
|
|
305
|
-
minTNCFare={minTNCFare}
|
|
306
|
-
/>
|
|
307
|
-
)
|
|
308
|
-
}
|
|
309
|
-
icon={<MoneyBillAlt size={17} />}
|
|
310
|
-
summary={tncFare}
|
|
311
|
-
/>
|
|
312
|
-
)}
|
|
313
|
-
{displayTimeActive && minutesActive > 0 && (
|
|
314
|
-
<TripDetail
|
|
315
|
-
icon={<Heartbeat size={17} />}
|
|
316
|
-
summary={
|
|
317
|
-
<FormattedMessage
|
|
318
|
-
defaultMessage={
|
|
319
|
-
defaultMessages["otpUi.TripDetails.minutesActive"]
|
|
320
|
-
}
|
|
321
|
-
description="Text showing the number of minutes spent walking or biking throughout trip."
|
|
322
|
-
id="otpUi.TripDetails.minutesActive"
|
|
323
|
-
values={{
|
|
324
|
-
approximatePrefix: showApproximateMinutesActive,
|
|
325
|
-
minutes: minutesActive,
|
|
326
|
-
strong: boldText
|
|
327
|
-
}}
|
|
328
|
-
/>
|
|
329
|
-
}
|
|
330
|
-
description={
|
|
331
|
-
TimeActiveDetails && (
|
|
332
|
-
<TimeActiveDetails
|
|
333
|
-
bikeMinutes={bikeMinutes}
|
|
334
|
-
walkMinutes={walkMinutes}
|
|
335
|
-
/>
|
|
336
|
-
)
|
|
337
|
-
}
|
|
338
|
-
/>
|
|
339
|
-
)}
|
|
340
|
-
{co2 > 0 && co2Config?.enabled && (
|
|
341
|
-
<TripDetail
|
|
342
|
-
icon={<Leaf size={17} />}
|
|
343
|
-
summary={
|
|
344
|
-
<S.CO2Summary>
|
|
345
|
-
<FormattedMessage
|
|
346
|
-
defaultMessage={defaultMessages["otpUi.TripDetails.co2"]}
|
|
347
|
-
description="Text showing the quantity of CO₂ emitted by this trip."
|
|
348
|
-
id="otpUi.TripDetails.co2"
|
|
349
|
-
values={{
|
|
350
|
-
co2: (
|
|
351
|
-
<FormattedNumber
|
|
352
|
-
value={Math.round(co2)}
|
|
353
|
-
// eslint-disable-next-line react/style-prop-object
|
|
354
|
-
style="unit"
|
|
355
|
-
unit={co2Config?.units || "gram"}
|
|
356
|
-
unitDisplay="narrow"
|
|
357
|
-
/>
|
|
358
|
-
),
|
|
359
|
-
strong: boldText
|
|
360
|
-
}}
|
|
361
|
-
/>
|
|
362
|
-
</S.CO2Summary>
|
|
363
|
-
}
|
|
364
|
-
description={
|
|
365
|
-
<FormattedMessage
|
|
366
|
-
defaultMessage={
|
|
367
|
-
defaultMessages["otpUi.TripDetails.co2description"]
|
|
368
|
-
}
|
|
369
|
-
description="Text explaining how the CO₂ emissions are calculated."
|
|
370
|
-
id="otpUi.TripDetails.co2description"
|
|
371
|
-
values={{
|
|
372
|
-
link: CO2DescriptionLink,
|
|
373
|
-
totalDistance
|
|
374
|
-
}}
|
|
375
|
-
/>
|
|
376
|
-
}
|
|
377
|
-
/>
|
|
378
|
-
)}
|
|
379
|
-
{containsFlex && (
|
|
380
|
-
<TripDetail
|
|
381
|
-
summary={
|
|
382
|
-
<S.FlexSummary>
|
|
383
|
-
<FormattedMessage
|
|
384
|
-
defaultMessage={
|
|
385
|
-
defaultMessages["otpUi.TripDetails.tripIncludesFlex"]
|
|
386
|
-
}
|
|
387
|
-
description="Text stating that portions of the trip include a flex (on-demand) transit service."
|
|
388
|
-
id="otpUi.TripDetails.tripIncludesFlex"
|
|
389
|
-
values={{
|
|
390
|
-
extraMessage: [
|
|
391
|
-
...new Set([
|
|
392
|
-
...pickupBookingInfo.map(info => info.message),
|
|
393
|
-
...dropOffBookingInfo.map(info => info.message)
|
|
394
|
-
])
|
|
395
|
-
].join(" ")
|
|
396
|
-
}}
|
|
397
|
-
/>
|
|
398
|
-
</S.FlexSummary>
|
|
399
|
-
}
|
|
400
|
-
icon={<Route size={17} />}
|
|
401
|
-
/>
|
|
402
|
-
)}
|
|
64
|
+
<FlexBookingInfo itinerary={itinerary} />
|
|
65
|
+
<Emissions itinerary={itinerary} co2Config={co2Config} />
|
|
403
66
|
</S.TripDetailsBody>
|
|
404
67
|
</S.TripDetails>
|
|
405
68
|
);
|
package/src/trip-detail.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import { useIntl } from "react-intl";
|
|
|
7
7
|
import * as S from "./styled";
|
|
8
8
|
|
|
9
9
|
type Props = {
|
|
10
|
+
className?: string;
|
|
10
11
|
description?: ReactElement | string;
|
|
11
12
|
icon: ReactElement;
|
|
12
13
|
summary: ReactElement | string;
|
|
@@ -32,7 +33,12 @@ function uuidv4(): string {
|
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
const TripDetail = ({
|
|
36
|
+
const TripDetail = ({
|
|
37
|
+
icon,
|
|
38
|
+
summary,
|
|
39
|
+
description,
|
|
40
|
+
className
|
|
41
|
+
}: Props): JSX.Element => {
|
|
36
42
|
const intl = useIntl();
|
|
37
43
|
const [expanded, setExpanded] = useState(false);
|
|
38
44
|
|
|
@@ -43,7 +49,7 @@ const TripDetail = ({ icon, summary, description }: Props): JSX.Element => {
|
|
|
43
49
|
};
|
|
44
50
|
|
|
45
51
|
return (
|
|
46
|
-
<S.TripDetail role="group">
|
|
52
|
+
<S.TripDetail role="group" className={className}>
|
|
47
53
|
<S.TripDetailIcon role="presentation">{icon}</S.TripDetailIcon>
|
|
48
54
|
{/* TODO: Adjust the summary and description to be a `summary`/`details` pair, therefore semantically correct */}
|
|
49
55
|
{/* https://github.com/opentripplanner/otp-ui/pull/530#discussion_r1074006057 */}
|
package/src/types.ts
CHANGED
|
@@ -52,6 +52,22 @@ export interface FareDetailsProps {
|
|
|
52
52
|
minTNCFare: number;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
export interface FareConfig {
|
|
56
|
+
/**
|
|
57
|
+
* Determines which transit fare should be displayed by default, should there be multiple transit fare types.
|
|
58
|
+
*/
|
|
59
|
+
defaultFareType?: { headerKey: string } & FareProductSelector;
|
|
60
|
+
/**
|
|
61
|
+
* Column and table configuration for fare details/fare by leg table.
|
|
62
|
+
*/
|
|
63
|
+
fareDetailsLayout?: FareTableLayout[];
|
|
64
|
+
/**
|
|
65
|
+
* Mapping between fare keys and human-readable names for them.
|
|
66
|
+
*/
|
|
67
|
+
fareKeyNameMap?: {
|
|
68
|
+
[name: string]: string;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
55
71
|
|
|
56
72
|
export interface TripDetailsProps {
|
|
57
73
|
/**
|
|
@@ -62,33 +78,18 @@ export interface TripDetailsProps {
|
|
|
62
78
|
* Object containing the CO₂ config.
|
|
63
79
|
*/
|
|
64
80
|
co2Config?: CO2ConfigType;
|
|
65
|
-
/**
|
|
66
|
-
* Determines which transit fare should be displayed by default, should there be multiple transit fare types.
|
|
67
|
-
*/
|
|
68
|
-
defaultFareType?: { headerKey: string } & FareProductSelector;
|
|
69
81
|
/**
|
|
70
82
|
* Slot for a custom component to render the expandable section for departure.
|
|
71
83
|
*/
|
|
72
84
|
DepartureDetails?: React.ElementType<DepartureDetailsProps>;
|
|
73
|
-
/**
|
|
74
|
-
* If this is set to true, a row will be added to the trip details displaying how
|
|
75
|
-
* many minutes in total the user will spend walking or biking.
|
|
76
|
-
*/
|
|
77
|
-
displayTimeActive?: boolean;
|
|
78
85
|
/**
|
|
79
86
|
* Slot for a custom component to render the expandable section for fares.
|
|
80
87
|
*/
|
|
81
88
|
FareDetails?: React.ElementType<FareDetailsProps>;
|
|
82
89
|
/**
|
|
83
|
-
*
|
|
84
|
-
*/
|
|
85
|
-
fareDetailsLayout?: FareTableLayout[];
|
|
86
|
-
/**
|
|
87
|
-
* Mapping between fare keys and human-readable names for them.
|
|
90
|
+
* Configuration for fare details/fare by leg table.
|
|
88
91
|
*/
|
|
89
|
-
|
|
90
|
-
[name: string]: string;
|
|
91
|
-
};
|
|
92
|
+
fareConfig?: FareConfig;
|
|
92
93
|
/**
|
|
93
94
|
* Itinerary that the user has selected to view, contains multiple legs.
|
|
94
95
|
*/
|