@opentripplanner/trip-details 8.0.2 → 9.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.
Files changed (78) hide show
  1. package/esm/components/fares-v2-table.js +194 -0
  2. package/esm/components/fares-v2-table.js.map +1 -0
  3. package/esm/components/fares.js +28 -58
  4. package/esm/components/fares.js.map +1 -1
  5. package/esm/index.js +5 -5
  6. package/esm/index.js.map +1 -1
  7. package/esm/styled.js +29 -22
  8. package/esm/styled.js.map +1 -1
  9. package/esm/trip-detail.js +1 -8
  10. package/esm/trip-detail.js.map +1 -1
  11. package/esm/types.js.map +1 -1
  12. package/i18n/en-US.yml +2 -7
  13. package/i18n/es.yml +0 -7
  14. package/i18n/fr.yml +2 -7
  15. package/i18n/ko.yml +2 -9
  16. package/i18n/nb_NO.yml +1 -4
  17. package/i18n/pl.yml +24 -19
  18. package/i18n/ru.yml +3 -10
  19. package/i18n/ta.yml +20 -25
  20. package/i18n/tl.yml +2 -9
  21. package/i18n/tr.yml +0 -7
  22. package/i18n/vi.yml +2 -9
  23. package/i18n/zh_Hans.yml +2 -9
  24. package/i18n/zh_Hant.yml +0 -7
  25. package/lib/components/departure-date.js +45 -42
  26. package/lib/components/departure-date.js.map +1 -1
  27. package/lib/components/emissions.js +57 -64
  28. package/lib/components/emissions.js.map +1 -1
  29. package/lib/components/fares-v2-table.d.ts +9 -0
  30. package/lib/components/fares-v2-table.d.ts.map +1 -0
  31. package/lib/components/fares-v2-table.js +158 -0
  32. package/lib/components/fares-v2-table.js.map +1 -0
  33. package/lib/components/fares.d.ts +4 -4
  34. package/lib/components/fares.d.ts.map +1 -1
  35. package/lib/components/fares.js +87 -151
  36. package/lib/components/fares.js.map +1 -1
  37. package/lib/components/flex-booking-info.js +55 -38
  38. package/lib/components/flex-booking-info.js.map +1 -1
  39. package/lib/components/time-active.js +40 -66
  40. package/lib/components/time-active.js.map +1 -1
  41. package/lib/index.d.ts +3 -3
  42. package/lib/index.d.ts.map +1 -1
  43. package/lib/index.js +53 -66
  44. package/lib/index.js.map +1 -1
  45. package/lib/styled.d.ts +1 -0
  46. package/lib/styled.d.ts.map +1 -1
  47. package/lib/styled.js +120 -86
  48. package/lib/styled.js.map +1 -1
  49. package/lib/trip-detail.d.ts.map +1 -1
  50. package/lib/trip-detail.js +65 -71
  51. package/lib/trip-detail.js.map +1 -1
  52. package/lib/types.d.ts +4 -41
  53. package/lib/types.d.ts.map +1 -1
  54. package/lib/types.js +1 -4
  55. package/lib/types.js.map +1 -1
  56. package/lib/utils.js +17 -23
  57. package/lib/utils.js.map +1 -1
  58. package/package.json +3 -5
  59. package/src/TripDetails.story.tsx +47 -158
  60. package/src/__snapshots__/TripDetails.story.tsx.snap +1726 -924
  61. package/src/components/fares-v2-table.tsx +262 -0
  62. package/src/components/fares.tsx +48 -87
  63. package/src/index.tsx +4 -4
  64. package/src/styled.ts +11 -2
  65. package/src/trip-detail.tsx +1 -10
  66. package/src/types.ts +4 -40
  67. package/tsconfig.json +1 -1
  68. package/tsconfig.tsbuildinfo +1 -1
  69. package/__mocks__/custom-english-messages.yml +0 -14
  70. package/__mocks__/custom-french-messages.yml +0 -9
  71. package/esm/components/fare-table.js +0 -122
  72. package/esm/components/fare-table.js.map +0 -1
  73. package/i18n/i18n-exceptions.json +0 -12
  74. package/lib/components/fare-table.d.ts +0 -5
  75. package/lib/components/fare-table.d.ts.map +0 -1
  76. package/lib/components/fare-table.js +0 -118
  77. package/lib/components/fare-table.js.map +0 -1
  78. 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
  */
@@ -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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gB;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
@@ -1,6 +1,3 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
6
3
  //# sourceMappingURL=types.js.map
package/lib/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["// Prettier does not recognize the import type syntax.\n// eslint-disable-next-line prettier/prettier\nimport type { \n FareProductSelector, \n Itinerary, \n Leg, \n MassUnitOption,\n Money\n } from \"@opentripplanner/types\";\n\nexport interface TimeActiveDetailsProps {\n bikeMinutes: number;\n minutesActive?: number;\n walkMinutes: number;\n}\n\nexport interface CO2ConfigType {\n carbonIntensity?: Record<string, number>;\n units?: MassUnitOption;\n enabled?: boolean;\n}\n\nexport interface DepartureDetailsProps {\n departureDate: Date;\n}\n\n/**\n * This is the interface used to define the layout for a particular fare table.\n * The table with be rendered with the columns defined here,\n * with each row being an individual transit leg from the itinerary.\n */\nexport interface FareTableLayout {\n cols: (FareProductSelector & {\n columnHeaderKey: string;\n })[]\n headerKey: string;\n}\n/**\n * Interface containing the lgs and the layout of the fare table.\n */\nexport interface FareLegTableProps {\n layout?: FareTableLayout[];\n legs: Leg[];\n}\n\n// Total fare amount corresponding to a fare key\nexport type FareTotals = (FareProductSelector & { price: Money })[]\n\nexport interface FareDetailsProps {\n legs: Leg[];\n maxTNCFare: number;\n minTNCFare: number;\n}\n\nexport interface FareConfig {\n /**\n * Determines which transit fare should be displayed by default, should there be multiple transit fare types.\n * Header key is used only in the old fare display.\n */\n defaultFareType?: { headerKey?: string } & FareProductSelector;\n /**\n * Column and table configuration for fare details/fare by leg table.\n */\n fareDetailsLayout?: FareTableLayout[];\n /**\n * Mapping between fare keys and human-readable names for them.\n */\n fareKeyNameMap?: {\n [name: string]: string;\n };\n}\n\nexport interface TripDetailsProps {\n /**\n * Used for additional styling with styled components for example.\n */\n className?: string;\n /**\n * Object containing the CO₂ config.\n */\n co2Config?: CO2ConfigType;\n /**\n * Slot for a custom component to render the expandable section for departure.\n */\n DepartureDetails?: React.ElementType<DepartureDetailsProps>;\n /**\n * Slot for a custom component to render the expandable section for fares.\n */\n FareDetails?: React.ElementType<FareDetailsProps>;\n /**\n * Configuration for fare details/fare by leg table.\n */\n fareConfig?: FareConfig;\n /**\n * Itinerary that the user has selected to view, contains multiple legs.\n */\n itinerary: Itinerary;\n /**\n * show the '~' symbol in the trip details panel\n */\n showApproximateMinutesActive?: boolean;\n /**\n * Slot for a custom component to render the expandable section for time active.\n */\n TimeActiveDetails?: React.ElementType<TimeActiveDetailsProps>;\n}"],"mappings":"","ignoreList":[]}
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
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.boldText = boldText;
8
- exports.renderFare = renderFare;
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
- return /*#__PURE__*/_react.default.createElement("strong", null, contents);
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
- return /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedNumber, {
26
- currency: currencyCode
27
- // For dollars in locales such as 'fr',
28
- // this will limit the display to just the dollar sign
29
- // (otherwise it will render e.g. '2,50 $US' instead of '2,50 $').
30
- ,
31
- currencyDisplay: "narrowSymbol",
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","names":["_react","_interopRequireDefault","require","_reactIntl","boldText","contents","default","createElement","renderFare","currencyCode","fare","FormattedNumber","currency","currencyDisplay","value","style"],"sources":["../src/utils.tsx"],"sourcesContent":["import React, { ReactElement, ReactNode } from \"react\";\nimport { FormattedNumber } from \"react-intl\";\n\n/**\n * Format text bold (used with FormattedMessage).\n */\nexport function boldText(contents: ReactNode): ReactElement {\n return <strong>{contents}</strong>;\n}\n\n/**\n * Render formatted fare.\n * @param currencyCode The ISO currency code to use (USD, GBP, EUR).\n * @param fare The fare value, in currency units, to be shown.\n * @returns The formatted fare value according to the selected locale.\n */\nexport function renderFare(currencyCode: string, fare: number): ReactElement {\n return (\n <FormattedNumber\n currency={currencyCode}\n // For dollars in locales such as 'fr',\n // this will limit the display to just the dollar sign\n // (otherwise it will render e.g. '2,50 $US' instead of '2,50 $').\n currencyDisplay=\"narrowSymbol\"\n value={fare}\n // eslint-disable-next-line react/style-prop-object\n style=\"currency\"\n />\n );\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACO,SAASE,QAAQA,CAACC,QAAmB,EAAgB;EAC1D,oBAAOL,MAAA,CAAAM,OAAA,CAAAC,aAAA,iBAASF,QAAiB,CAAC;AACpC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,UAAUA,CAACC,YAAoB,EAAEC,IAAY,EAAgB;EAC3E,oBACEV,MAAA,CAAAM,OAAA,CAAAC,aAAA,CAACJ,UAAA,CAAAQ,eAAe;IACdC,QAAQ,EAAEH;IACV;IACA;IACA;IAAA;IACAI,eAAe,EAAC,cAAc;IAC9BC,KAAK,EAAEJ;IACP;IAAA;IACAK,KAAK,EAAC;EAAU,CACjB,CAAC;AAEN","ignoreList":[]}
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": "8.0.2",
3
+ "version": "9.0.0",
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": "13.0.1"
16
+ "@opentripplanner/core-utils": "14.0.0"
18
17
  },
19
18
  "devDependencies": {
20
- "@types/flat": "^5.0.2",
21
- "@opentripplanner/types": "6.5.3"
19
+ "@opentripplanner/types": "8.0.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, StoryContext, StoryObj } from "@storybook/react";
3
+ import { Meta, Parameters, StoryObj } from "@storybook/react";
5
4
  import styled from "styled-components";
6
- import { convertGraphQLResponseToLegacy } from "@opentripplanner/core-utils/lib/itinerary";
7
- // The below eslint-disable is due to https://github.com/storybookjs/storybook/issues/13408
8
- // eslint-disable-next-line import/no-named-as-default
9
- import TripDetails, { FareLegTable } from ".";
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
- ): StoryObj<typeof TripDetails> {
184
- const TripDetailsTemplate = (
185
- {
186
- DepartureDetails,
187
- FareDetails,
188
- fareConfig = {},
189
- itinerary,
190
- TimeActiveDetails,
191
- showApproximateMinutesActive
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
- TimeActiveDetails={TimeActiveDetails}
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
- fareConfig: {
274
- defaultFareType: orcaDefaultFareType,
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 FareLegTableStoryLegProducts = (): ReactElement => {
326
- const otp1legs = otp2FareProducts.legs.map(convertGraphQLResponseToLegacy);
327
- return <FareLegTable layout={orcaFareByLegLayout} legs={otp1legs} />;
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
  };