@opentripplanner/trip-details 8.0.2 → 9.0.1
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/fares-v2-table.js +194 -0
- package/esm/components/fares-v2-table.js.map +1 -0
- package/esm/components/fares.js +34 -60
- package/esm/components/fares.js.map +1 -1
- package/esm/index.js +5 -5
- package/esm/index.js.map +1 -1
- package/esm/styled.js +29 -22
- package/esm/styled.js.map +1 -1
- package/esm/trip-detail.js +1 -8
- package/esm/trip-detail.js.map +1 -1
- package/esm/types.js.map +1 -1
- package/i18n/en-US.yml +2 -7
- package/i18n/es.yml +0 -7
- package/i18n/fr.yml +2 -7
- package/i18n/ko.yml +2 -9
- package/i18n/nb_NO.yml +1 -4
- package/i18n/pl.yml +24 -19
- package/i18n/ru.yml +3 -10
- package/i18n/ta.yml +20 -25
- package/i18n/tl.yml +2 -9
- package/i18n/tr.yml +0 -7
- package/i18n/vi.yml +2 -9
- package/i18n/zh_Hans.yml +2 -9
- package/i18n/zh_Hant.yml +0 -7
- package/lib/components/departure-date.js +45 -42
- package/lib/components/departure-date.js.map +1 -1
- package/lib/components/emissions.js +57 -64
- package/lib/components/emissions.js.map +1 -1
- package/lib/components/fares-v2-table.d.ts +9 -0
- package/lib/components/fares-v2-table.d.ts.map +1 -0
- package/lib/components/fares-v2-table.js +158 -0
- package/lib/components/fares-v2-table.js.map +1 -0
- package/lib/components/fares.d.ts +4 -4
- package/lib/components/fares.d.ts.map +1 -1
- package/lib/components/fares.js +87 -151
- package/lib/components/fares.js.map +1 -1
- package/lib/components/flex-booking-info.js +55 -38
- package/lib/components/flex-booking-info.js.map +1 -1
- package/lib/components/time-active.js +40 -66
- package/lib/components/time-active.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +53 -66
- package/lib/index.js.map +1 -1
- package/lib/styled.d.ts +1 -0
- package/lib/styled.d.ts.map +1 -1
- package/lib/styled.js +120 -86
- package/lib/styled.js.map +1 -1
- package/lib/trip-detail.d.ts.map +1 -1
- package/lib/trip-detail.js +65 -71
- package/lib/trip-detail.js.map +1 -1
- package/lib/types.d.ts +4 -41
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +1 -4
- package/lib/types.js.map +1 -1
- package/lib/utils.js +17 -23
- package/lib/utils.js.map +1 -1
- package/package.json +3 -5
- package/src/TripDetails.story.tsx +47 -158
- package/src/__snapshots__/TripDetails.story.tsx.snap +1726 -924
- package/src/components/fares-v2-table.tsx +262 -0
- package/src/components/fares.tsx +51 -89
- package/src/index.tsx +4 -4
- package/src/styled.ts +11 -2
- package/src/trip-detail.tsx +1 -10
- package/src/types.ts +4 -40
- package/tsconfig.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/__mocks__/custom-english-messages.yml +0 -14
- package/__mocks__/custom-french-messages.yml +0 -9
- package/esm/components/fare-table.js +0 -122
- package/esm/components/fare-table.js.map +0 -1
- package/i18n/i18n-exceptions.json +0 -12
- package/lib/components/fare-table.d.ts +0 -5
- package/lib/components/fare-table.d.ts.map +0 -1
- package/lib/components/fare-table.js +0 -118
- package/lib/components/fare-table.js.map +0 -1
- package/src/components/fare-table.tsx +0 -215
package/lib/types.d.ts
CHANGED
|
@@ -13,24 +13,6 @@ export interface CO2ConfigType {
|
|
|
13
13
|
export interface DepartureDetailsProps {
|
|
14
14
|
departureDate: Date;
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
17
|
-
* This is the interface used to define the layout for a particular fare table.
|
|
18
|
-
* The table with be rendered with the columns defined here,
|
|
19
|
-
* with each row being an individual transit leg from the itinerary.
|
|
20
|
-
*/
|
|
21
|
-
export interface FareTableLayout {
|
|
22
|
-
cols: (FareProductSelector & {
|
|
23
|
-
columnHeaderKey: string;
|
|
24
|
-
})[];
|
|
25
|
-
headerKey: string;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Interface containing the lgs and the layout of the fare table.
|
|
29
|
-
*/
|
|
30
|
-
export interface FareLegTableProps {
|
|
31
|
-
layout?: FareTableLayout[];
|
|
32
|
-
legs: Leg[];
|
|
33
|
-
}
|
|
34
16
|
export type FareTotals = (FareProductSelector & {
|
|
35
17
|
price: Money;
|
|
36
18
|
})[];
|
|
@@ -39,25 +21,6 @@ export interface FareDetailsProps {
|
|
|
39
21
|
maxTNCFare: number;
|
|
40
22
|
minTNCFare: number;
|
|
41
23
|
}
|
|
42
|
-
export interface FareConfig {
|
|
43
|
-
/**
|
|
44
|
-
* Determines which transit fare should be displayed by default, should there be multiple transit fare types.
|
|
45
|
-
* Header key is used only in the old fare display.
|
|
46
|
-
*/
|
|
47
|
-
defaultFareType?: {
|
|
48
|
-
headerKey?: string;
|
|
49
|
-
} & FareProductSelector;
|
|
50
|
-
/**
|
|
51
|
-
* Column and table configuration for fare details/fare by leg table.
|
|
52
|
-
*/
|
|
53
|
-
fareDetailsLayout?: FareTableLayout[];
|
|
54
|
-
/**
|
|
55
|
-
* Mapping between fare keys and human-readable names for them.
|
|
56
|
-
*/
|
|
57
|
-
fareKeyNameMap?: {
|
|
58
|
-
[name: string]: string;
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
24
|
export interface TripDetailsProps {
|
|
62
25
|
/**
|
|
63
26
|
* Used for additional styling with styled components for example.
|
|
@@ -67,6 +30,10 @@ export interface TripDetailsProps {
|
|
|
67
30
|
* Object containing the CO₂ config.
|
|
68
31
|
*/
|
|
69
32
|
co2Config?: CO2ConfigType;
|
|
33
|
+
/**
|
|
34
|
+
* Determines which transit fare should be displayed by default, should there be multiple transit fare types.
|
|
35
|
+
*/
|
|
36
|
+
defaultFareType?: FareProductSelector;
|
|
70
37
|
/**
|
|
71
38
|
* Slot for a custom component to render the expandable section for departure.
|
|
72
39
|
*/
|
|
@@ -75,10 +42,6 @@ export interface TripDetailsProps {
|
|
|
75
42
|
* Slot for a custom component to render the expandable section for fares.
|
|
76
43
|
*/
|
|
77
44
|
FareDetails?: React.ElementType<FareDetailsProps>;
|
|
78
|
-
/**
|
|
79
|
-
* Configuration for fare details/fare by leg table.
|
|
80
|
-
*/
|
|
81
|
-
fareConfig?: FareConfig;
|
|
82
45
|
/**
|
|
83
46
|
* Itinerary that the user has selected to view, contains multiple legs.
|
|
84
47
|
*/
|
package/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EACV,mBAAmB,EACnB,SAAS,EACT,GAAG,EACH,cAAc,EACd,KAAK,EACL,MAAM,wBAAwB,CAAC;AAEjC,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,IAAI,CAAC;CACrB;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EACV,mBAAmB,EACnB,SAAS,EACT,GAAG,EACH,cAAc,EACd,KAAK,EACL,MAAM,wBAAwB,CAAC;AAEjC,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,IAAI,CAAC;CACrB;AAID,MAAM,MAAM,UAAU,GAAG,CAAC,mBAAmB,GAAG;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC,EAAE,CAAA;AAEnE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACjB;;KAEC;IACH,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B;;OAEG;IACH,eAAe,CAAC,EAAE,mBAAmB,CAAC;IACtC;;OAEG;IACH,gBAAgB,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAC5D;;OAEG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAClD;;OAEG;IACH,SAAS,EAAE,SAAS,CAAC;IACrB;;OAEG;IACH,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC;;OAEG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAC;CAC/D"}
|
package/lib/types.js
CHANGED
package/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/lib/utils.js
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _reactIntl = require("react-intl");
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.renderFare = exports.boldText = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const react_intl_1 = require("react-intl");
|
|
11
9
|
/**
|
|
12
10
|
* Format text bold (used with FormattedMessage).
|
|
13
11
|
*/
|
|
14
12
|
function boldText(contents) {
|
|
15
|
-
|
|
13
|
+
return react_1.default.createElement("strong", null, contents);
|
|
16
14
|
}
|
|
17
|
-
|
|
15
|
+
exports.boldText = boldText;
|
|
18
16
|
/**
|
|
19
17
|
* Render formatted fare.
|
|
20
18
|
* @param currencyCode The ISO currency code to use (USD, GBP, EUR).
|
|
@@ -22,17 +20,13 @@ function boldText(contents) {
|
|
|
22
20
|
* @returns The formatted fare value according to the selected locale.
|
|
23
21
|
*/
|
|
24
22
|
function renderFare(currencyCode, fare) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
value: fare
|
|
33
|
-
// eslint-disable-next-line react/style-prop-object
|
|
34
|
-
,
|
|
35
|
-
style: "currency"
|
|
36
|
-
});
|
|
23
|
+
return (react_1.default.createElement(react_intl_1.FormattedNumber, { currency: currencyCode,
|
|
24
|
+
// For dollars in locales such as 'fr',
|
|
25
|
+
// this will limit the display to just the dollar sign
|
|
26
|
+
// (otherwise it will render e.g. '2,50 $US' instead of '2,50 $').
|
|
27
|
+
currencyDisplay: "narrowSymbol", value: fare,
|
|
28
|
+
// eslint-disable-next-line react/style-prop-object
|
|
29
|
+
style: "currency" }));
|
|
37
30
|
}
|
|
31
|
+
exports.renderFare = renderFare;
|
|
38
32
|
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAAuD;AACvD,2CAA6C;AAE7C;;GAEG;AACH,SAAgB,QAAQ,CAAC,QAAmB;IAC1C,OAAO,8CAAS,QAAQ,CAAU,CAAC;AACrC,CAAC;AAFD,4BAEC;AAED;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,YAAoB,EAAE,IAAY;IAC3D,OAAO,CACL,8BAAC,4BAAe,IACd,QAAQ,EAAE,YAAY;QACtB,uCAAuC;QACvC,sDAAsD;QACtD,kEAAkE;QAClE,eAAe,EAAC,cAAc,EAC9B,KAAK,EAAE,IAAI;QACX,mDAAmD;QACnD,KAAK,EAAC,UAAU,GAChB,CACH,CAAC;AACJ,CAAC;AAbD,gCAaC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentripplanner/trip-details",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.1",
|
|
4
4
|
"description": "A component for displaying details about a trip planning itinerary",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -12,13 +12,11 @@
|
|
|
12
12
|
"private": false,
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@styled-icons/fa-solid": "^10.34.0",
|
|
15
|
-
"flat": "^5.0.2",
|
|
16
15
|
"react-animate-height": "^3.0.4",
|
|
17
|
-
"@opentripplanner/core-utils": "
|
|
16
|
+
"@opentripplanner/core-utils": "14.2.0"
|
|
18
17
|
},
|
|
19
18
|
"devDependencies": {
|
|
20
|
-
"@types
|
|
21
|
-
"@opentripplanner/types": "6.5.3"
|
|
19
|
+
"@opentripplanner/types": "8.2.0"
|
|
22
20
|
},
|
|
23
21
|
"peerDependencies": {
|
|
24
22
|
"react": "^18.2.0",
|
|
@@ -1,37 +1,30 @@
|
|
|
1
|
-
import flatten from "flat";
|
|
2
1
|
import React, { ReactElement } from "react";
|
|
3
2
|
import { FormattedDate } from "react-intl";
|
|
4
|
-
import { Meta, Parameters,
|
|
3
|
+
import { Meta, Parameters, StoryObj } from "@storybook/react";
|
|
5
4
|
import styled from "styled-components";
|
|
6
|
-
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
import
|
|
5
|
+
|
|
6
|
+
// import mock itinaries. These are all trip plan outputs from OTP.
|
|
7
|
+
import tncTransitTncItinerary from "../../itinerary-body/src/__mocks__/itineraries/tnc-transit-tnc.json";
|
|
8
|
+
import walkOnlyItinerary from "../../itinerary-body/src/__mocks__/itineraries/walk-only.json";
|
|
9
|
+
import walkTransitWalkItinerary from "../../itinerary-body/src/__mocks__/itineraries/walk-transit-walk.json";
|
|
10
|
+
import walkTransitWalkTransitWalkItinerary from "../../itinerary-body/src/__mocks__/itineraries/walk-transit-walk-transit-walk.json";
|
|
11
|
+
import flexItinerary from "../../itinerary-body/src/__mocks__/itineraries/otp2.4-transit-itinerary.json";
|
|
12
|
+
import otp2ScooterItinerary from "../../itinerary-body/src/__mocks__/itineraries/otp2-scooter.json";
|
|
13
|
+
import otp2FareProducts from "../../itinerary-body/src/__mocks__/itineraries/leg-fare-products.json";
|
|
14
|
+
import multipleFareOptionsItinerary from "../../itinerary-body/src/__mocks__/itineraries/fares-v2-multiple-options.json";
|
|
15
|
+
import faresv2ItineraryWithTransfer from "../../itinerary-body/src/__mocks__/itineraries/fares-v2-with-transfer.json";
|
|
16
|
+
import faresv2Itinerary from "../../itinerary-body/src/__mocks__/itineraries/fares-v2-fare-components.json";
|
|
17
|
+
import bikeOnlyItinerary from "../../itinerary-body/src/__mocks__/itineraries/bike-only.json";
|
|
10
18
|
import * as TripDetailsClasses from "./styled";
|
|
19
|
+
// eslint-disable-next-line import/no-named-as-default
|
|
20
|
+
import TripDetails, { FaresV2Table } from ".";
|
|
11
21
|
import {
|
|
12
22
|
TimeActiveDetailsProps,
|
|
13
23
|
DepartureDetailsProps,
|
|
14
24
|
FareDetailsProps,
|
|
15
|
-
FareTableLayout,
|
|
16
25
|
TripDetailsProps
|
|
17
26
|
} from "./types";
|
|
18
27
|
|
|
19
|
-
import customEnglishMessages from "../__mocks__/custom-english-messages.yml";
|
|
20
|
-
import customFrenchMessages from "../__mocks__/custom-french-messages.yml";
|
|
21
|
-
|
|
22
|
-
// import mock itinaries. These are all trip plan outputs from OTP.
|
|
23
|
-
const bikeOnlyItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/bike-only.json");
|
|
24
|
-
const tncTransitTncItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/tnc-transit-tnc.json");
|
|
25
|
-
const walkOnlyItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/walk-only.json");
|
|
26
|
-
const walkTransitWalkItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/walk-transit-walk.json");
|
|
27
|
-
const walkTransitWalkTransitWalkItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/walk-transit-walk-transit-walk.json");
|
|
28
|
-
const flexItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/flex-itinerary.json");
|
|
29
|
-
const otp2ScooterItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/otp2-scooter.json");
|
|
30
|
-
const otp2FareProducts = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/leg-fare-products.json");
|
|
31
|
-
|
|
32
|
-
const flattenedEnglishMessages = flatten(customEnglishMessages);
|
|
33
|
-
const flattenedFrenchMessages = flatten(customFrenchMessages);
|
|
34
|
-
|
|
35
28
|
// Change currency code on one of the itineraries for illustration.
|
|
36
29
|
// (other currency fields in the itinerary object are not used for display).
|
|
37
30
|
const itinCurrency =
|
|
@@ -44,96 +37,6 @@ const StyledTripDetails = styled(TripDetails)`
|
|
|
44
37
|
}
|
|
45
38
|
`;
|
|
46
39
|
|
|
47
|
-
const orcaFareByLegLayout: FareTableLayout[] = [
|
|
48
|
-
{
|
|
49
|
-
cols: [
|
|
50
|
-
{
|
|
51
|
-
columnHeaderKey: "cash",
|
|
52
|
-
mediumId: "orca:cash",
|
|
53
|
-
riderCategoryId: "orca:regular"
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
columnHeaderKey: "electronic",
|
|
57
|
-
mediumId: "orca:electronic",
|
|
58
|
-
riderCategoryId: "orca:regular"
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
columnHeaderKey: "special",
|
|
62
|
-
mediumId: "orca:electronic",
|
|
63
|
-
riderCategoryId: "orca:special"
|
|
64
|
-
}
|
|
65
|
-
],
|
|
66
|
-
headerKey: "regular"
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
cols: [
|
|
70
|
-
{
|
|
71
|
-
columnHeaderKey: "cash",
|
|
72
|
-
mediumId: "orca:cash",
|
|
73
|
-
riderCategoryId: "orca:youth"
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
columnHeaderKey: "electronic",
|
|
77
|
-
mediumId: "orca:electronic",
|
|
78
|
-
riderCategoryId: "orca:youth"
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
columnHeaderKey: "test",
|
|
82
|
-
mediumId: "invalidkey",
|
|
83
|
-
riderCategoryId: "invalidkey"
|
|
84
|
-
}
|
|
85
|
-
],
|
|
86
|
-
headerKey: "youth"
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
headerKey: "senior",
|
|
90
|
-
cols: [
|
|
91
|
-
{
|
|
92
|
-
columnHeaderKey: "cash",
|
|
93
|
-
mediumId: "orca:cash",
|
|
94
|
-
riderCategoryId: "orca:senior"
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
columnHeaderKey: "electronic",
|
|
98
|
-
mediumId: "orca:electronic",
|
|
99
|
-
riderCategoryId: "orca:senior"
|
|
100
|
-
}
|
|
101
|
-
]
|
|
102
|
-
}
|
|
103
|
-
];
|
|
104
|
-
|
|
105
|
-
const orcaDefaultFareType = {
|
|
106
|
-
headerKey: "cash-regular",
|
|
107
|
-
mediumId: "orca:cash",
|
|
108
|
-
riderCategoryId: "orca:regular"
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const englishFareKeyMap = {
|
|
112
|
-
regular: "Transit Fare",
|
|
113
|
-
student: "Student Fare",
|
|
114
|
-
senior: "Senior Fare",
|
|
115
|
-
tram: "Tram Fare",
|
|
116
|
-
special: "Special Fare",
|
|
117
|
-
youth: "Youth Fare",
|
|
118
|
-
electronicRegular: "Orca Fare",
|
|
119
|
-
electronicYouth: "Orca Youth Fare",
|
|
120
|
-
electronicSpecial: "Orca Special Fare",
|
|
121
|
-
electronicSenior: "Orca Senior Fare"
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const frenchFareKeyMap = {
|
|
125
|
-
regular: "Tarif en transports",
|
|
126
|
-
student: "Tarif étudiants",
|
|
127
|
-
senior: "Tarif séniors",
|
|
128
|
-
tram: "Tarif tram",
|
|
129
|
-
special: "Tarif spécial",
|
|
130
|
-
youth: "Tarif jeunes",
|
|
131
|
-
electronicRegular: "Tarif Orca",
|
|
132
|
-
electronicYouth: "Tarif Orca jeunes",
|
|
133
|
-
electronicSpecial: "Tarif Orca spécial",
|
|
134
|
-
electronicSenior: "Tarif Orca séniors"
|
|
135
|
-
};
|
|
136
|
-
|
|
137
40
|
const defaultCo2Config = {
|
|
138
41
|
enabled: true
|
|
139
42
|
};
|
|
@@ -180,33 +83,24 @@ const CustomTimeActiveDetails = ({
|
|
|
180
83
|
*/
|
|
181
84
|
function createTripDetailsTemplate(
|
|
182
85
|
Component: typeof TripDetails = TripDetails
|
|
183
|
-
)
|
|
184
|
-
const TripDetailsTemplate = (
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}: TripDetailsProps,
|
|
193
|
-
{ globals, parameters }: StoryContext
|
|
194
|
-
): ReactElement => {
|
|
195
|
-
const { locale } = globals;
|
|
196
|
-
const { useCustomFareKeyMap } = parameters;
|
|
197
|
-
if (useCustomFareKeyMap) {
|
|
198
|
-
fareConfig.fareKeyNameMap =
|
|
199
|
-
locale === "en-US" ? englishFareKeyMap : frenchFareKeyMap;
|
|
200
|
-
}
|
|
86
|
+
) {
|
|
87
|
+
const TripDetailsTemplate = ({
|
|
88
|
+
defaultFareType,
|
|
89
|
+
DepartureDetails,
|
|
90
|
+
FareDetails,
|
|
91
|
+
itinerary,
|
|
92
|
+
TimeActiveDetails,
|
|
93
|
+
showApproximateMinutesActive
|
|
94
|
+
}: TripDetailsProps): ReactElement => {
|
|
201
95
|
return (
|
|
202
96
|
<Component
|
|
203
|
-
|
|
97
|
+
co2Config={defaultCo2Config}
|
|
98
|
+
defaultFareType={defaultFareType}
|
|
204
99
|
DepartureDetails={DepartureDetails}
|
|
205
100
|
FareDetails={FareDetails}
|
|
206
|
-
fareConfig={fareConfig}
|
|
207
101
|
itinerary={itinerary}
|
|
208
|
-
co2Config={defaultCo2Config}
|
|
209
102
|
showApproximateMinutesActive={showApproximateMinutesActive}
|
|
103
|
+
TimeActiveDetails={TimeActiveDetails}
|
|
210
104
|
/>
|
|
211
105
|
);
|
|
212
106
|
};
|
|
@@ -228,9 +122,6 @@ function makeStory(
|
|
|
228
122
|
}
|
|
229
123
|
|
|
230
124
|
export default {
|
|
231
|
-
args: {
|
|
232
|
-
defaultFareKey: "regular"
|
|
233
|
-
},
|
|
234
125
|
component: TripDetails,
|
|
235
126
|
parameters: {
|
|
236
127
|
date: new Date("March 10, 2021 10:00:00"),
|
|
@@ -270,11 +161,8 @@ export const StyledItinerary = makeStory(
|
|
|
270
161
|
);
|
|
271
162
|
|
|
272
163
|
export const LegFareProductsItinerary = makeStory({
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
fareDetailsLayout: orcaFareByLegLayout
|
|
276
|
-
},
|
|
277
|
-
itinerary: otp2FareProducts
|
|
164
|
+
itinerary: otp2FareProducts,
|
|
165
|
+
defaultFareType: { mediumId: "electronic", riderCategoryId: "regular" }
|
|
278
166
|
});
|
|
279
167
|
|
|
280
168
|
// The render of this itinerary is uninteresting, but the test
|
|
@@ -295,13 +183,6 @@ export const TncTransitItinerary = makeStory(
|
|
|
295
183
|
|
|
296
184
|
export const TncTransitItineraryWithCustomMessages = makeStory(
|
|
297
185
|
{
|
|
298
|
-
fareConfig: {
|
|
299
|
-
defaultFareType: {
|
|
300
|
-
headerKey: "electronicRegular",
|
|
301
|
-
mediumId: "orca:electronic",
|
|
302
|
-
riderCategoryId: "orca:regular"
|
|
303
|
-
}
|
|
304
|
-
},
|
|
305
186
|
DepartureDetails: CustomDepartureDetails,
|
|
306
187
|
itinerary: tncTransitTncItinerary,
|
|
307
188
|
TimeActiveDetails: CustomTimeActiveDetails
|
|
@@ -309,12 +190,6 @@ export const TncTransitItineraryWithCustomMessages = makeStory(
|
|
|
309
190
|
{
|
|
310
191
|
// For illustration purposes,
|
|
311
192
|
// override a subset of localized strings with custom messages.
|
|
312
|
-
reactIntl: {
|
|
313
|
-
messages: {
|
|
314
|
-
"en-US": flattenedEnglishMessages,
|
|
315
|
-
fr: flattenedFrenchMessages
|
|
316
|
-
}
|
|
317
|
-
},
|
|
318
193
|
useCustomFareKeyMap: true
|
|
319
194
|
},
|
|
320
195
|
StyledTripDetails
|
|
@@ -322,7 +197,21 @@ export const TncTransitItineraryWithCustomMessages = makeStory(
|
|
|
322
197
|
|
|
323
198
|
export const OTP2FlexItinerary = makeStory({ itinerary: flexItinerary });
|
|
324
199
|
|
|
325
|
-
export const
|
|
326
|
-
|
|
327
|
-
|
|
200
|
+
export const FaresV2TableStory = (): ReactElement => {
|
|
201
|
+
return (
|
|
202
|
+
<>
|
|
203
|
+
<h5>Corrupt Data</h5>
|
|
204
|
+
<FaresV2Table legs={multipleFareOptionsItinerary.legs} />
|
|
205
|
+
<h5>Paid Transfer</h5>
|
|
206
|
+
<FaresV2Table legs={faresv2Itinerary.legs} favoriteMediumId="3" />
|
|
207
|
+
<h5>Free Transfer</h5>
|
|
208
|
+
<FaresV2Table legs={faresv2ItineraryWithTransfer.legs} />
|
|
209
|
+
<h5>Custom Fare Class Data</h5>
|
|
210
|
+
<FaresV2Table legs={otp2FareProducts.legs} />
|
|
211
|
+
{/*
|
|
212
|
+
// TODO: Activate this once the stories are sourced from OTP2
|
|
213
|
+
<h5>Single Ride</h5>
|
|
214
|
+
<FaresV2Table legs={walkTransitWalkItinerary.legs} /> */}
|
|
215
|
+
</>
|
|
216
|
+
);
|
|
328
217
|
};
|