@opentripplanner/trip-details 9.0.5 → 9.0.7

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.
@@ -1,153 +1,191 @@
1
- /* eslint-disable no-underscore-dangle */
2
- import React from "react";
3
- import coreUtils from "@opentripplanner/core-utils";
4
- import { FormattedMessage, useIntl } from "react-intl";
5
- import styled from "styled-components";
6
- import { Transfer } from "@styled-icons/boxicons-regular/Transfer";
7
- import { renderFare } from "../utils";
8
- import { InvisibleA11yCaption, InvisibleA11yLabel } from "../styled";
9
- // TODO: inline this import? (@opentripplanner/core-utils/src/itinerary)
10
- const { getLegCost, getItineraryCost, descope, getLegRouteName } = coreUtils.itinerary;
11
- const FailDash = (React.createElement(React.Fragment, null,
12
- "-",
13
- React.createElement(InvisibleA11yLabel, null,
14
- React.createElement(FormattedMessage, { id: "otpUi.TripDetails.legMissingFareInfo" }))));
15
- const TransferIcon = styled(Transfer) `
16
- padding-right: 0.25ch;
17
- `;
18
- const StripedTable = styled.table `
19
- text-align: right;
1
+ "use strict";
20
2
 
21
- tr td,
22
- tr th {
23
- padding: 4px;
24
- }
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _coreUtils = _interopRequireDefault(require("@opentripplanner/core-utils"));
10
+ var _reactIntl = require("react-intl");
11
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
12
+ var _Transfer = require("@styled-icons/boxicons-regular/Transfer");
13
+ var _utils = require("../utils");
14
+ var _styled = require("../styled");
15
+ /* eslint-disable no-underscore-dangle */
25
16
 
26
- tr td:nth-of-type(2n + 1),
27
- tr th:nth-of-type(2n) {
28
- background: #cccccc55;
29
- border-color: #cccccc55;
30
- }
31
- `;
17
+ // TODO: inline this import? (@opentripplanner/core-utils/src/itinerary)
18
+ const {
19
+ getLegCost,
20
+ getItineraryCost,
21
+ descope,
22
+ getLegRouteName
23
+ } = _coreUtils.default.itinerary;
24
+ const FailDash = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "-", /*#__PURE__*/_react.default.createElement(_styled.InvisibleA11yLabel, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
25
+ id: "otpUi.TripDetails.legMissingFareInfo"
26
+ })));
27
+ const TransferIcon = (0, _styledComponents.default)(_Transfer.Transfer).withConfig({
28
+ displayName: "fares-v2-table__TransferIcon",
29
+ componentId: "sc-h3t2h2-0"
30
+ })(["padding-right:0.25ch;"]);
31
+ const StripedTable = _styledComponents.default.table.withConfig({
32
+ displayName: "fares-v2-table__StripedTable",
33
+ componentId: "sc-h3t2h2-1"
34
+ })(["text-align:right;tr td,tr th{padding:4px;}tr td:nth-of-type(2n + 1),tr th:nth-of-type(2n){background:#cccccc55;border-color:#cccccc55;}"]);
32
35
  // Removes duplicates
33
36
  const categoryReducer = (acc, cur) => {
34
- if (!acc.some(m => descope(m === null || m === void 0 ? void 0 : m.id) === descope(cur === null || cur === void 0 ? void 0 : cur.id))) {
35
- acc.push(cur);
36
- }
37
- return acc;
37
+ if (!acc.some(m => descope(m === null || m === void 0 ? void 0 : m.id) === descope(cur === null || cur === void 0 ? void 0 : cur.id))) {
38
+ acc.push(cur);
39
+ }
40
+ return acc;
38
41
  };
42
+
39
43
  // Put the preferred medium first, and then all the others alphabetical
40
- const categorySorter = (favoriteId) => (a, b) => {
41
- const aId = descope(a === null || a === void 0 ? void 0 : a.id);
42
- const bId = descope(b === null || b === void 0 ? void 0 : b.id);
43
- if (favoriteId && aId === favoriteId) {
44
- return -1;
45
- }
46
- if (favoriteId && bId === favoriteId) {
47
- return 1;
48
- }
49
- return aId > bId ? 1 : -1;
44
+ const categorySorter = favoriteId => (a, b) => {
45
+ const aId = descope(a === null || a === void 0 ? void 0 : a.id);
46
+ const bId = descope(b === null || b === void 0 ? void 0 : b.id);
47
+ if (favoriteId && aId === favoriteId) {
48
+ return -1;
49
+ }
50
+ if (favoriteId && bId === favoriteId) {
51
+ return 1;
52
+ }
53
+ return aId > bId ? 1 : -1;
50
54
  };
55
+
51
56
  // TODO: This component currently can only show one type of fare per medium
52
- const FaresV2Table = ({ legs, favoriteMediumId, favoriteRiderCategoryId }) => {
53
- const intl = useIntl();
54
- const transitLegs = legs.filter(leg => leg.transitLeg);
55
- // Get all fare products across all legs
56
- const fareProducts = transitLegs.flatMap(leg => leg.fareProducts);
57
- // Reduce these into mediums and riders
58
- const mediums = fareProducts
59
- .map(fp => { var _a; return (_a = fp.product) === null || _a === void 0 ? void 0 : _a.medium; })
60
- .filter(m => m !== null)
61
- .reduce(categoryReducer, [])
62
- .sort(categorySorter(favoriteMediumId));
63
- const riders = fareProducts
64
- .map(fp => { var _a; return (_a = fp.product) === null || _a === void 0 ? void 0 : _a.riderCategory; })
65
- .filter(r => r !== null)
66
- .reduce(categoryReducer, [])
67
- .sort(categorySorter(favoriteRiderCategoryId));
68
- // Ensure we have at least one rider/medium
69
- if (riders.length === 0) {
70
- riders.push({ name: "Fare", id: null });
71
- }
72
- if (mediums.length === 0) {
73
- mediums.push({ name: "Regular", id: null });
74
- }
75
- // Keep track of seen fare ids to indicate transfers
76
- const productUseIds = new Set();
77
- const rows = [
78
- [
79
- React.createElement("th", { key: "faretitle", style: { textAlign: "left" }, scope: "col" },
80
- React.createElement(InvisibleA11yLabel, null,
81
- React.createElement(FormattedMessage, { id: "otpUi.TripDetails.fareCategory" }))),
82
- ...transitLegs.map(leg => (React.createElement("th", { key: leg.tripId, scope: "col" }, getLegRouteName(leg)))),
83
- transitLegs.length > 1 ? (React.createElement("th", { key: "total", style: { textAlign: "right" }, scope: "col" },
84
- React.createElement("em", null,
85
- React.createElement(FormattedMessage, { id: "otpUi.TripDetails.total" })))) : (React.createElement(React.Fragment, null))
86
- ]
87
- ];
88
- // non-transit legs don't have fares
89
- transitLegs.forEach((leg, index) => {
90
- mediums.forEach((medium, mediumIndex) => {
91
- riders.forEach((rider, riderIndex) => {
92
- var _a, _b, _c;
93
- if (!medium || !rider)
94
- return;
95
- const { alternateFareProducts, isDependent, appliedFareProduct, productUseId } = getLegCost(leg, descope(medium.id) || null, descope(rider.id) || null, Array.from(productUseIds));
96
- const legPrice = appliedFareProduct === null || appliedFareProduct === void 0 ? void 0 : appliedFareProduct.legPrice;
97
- productUseIds.add(productUseId);
98
- // Only consider alternateFareProducts if current product is dependent
99
- const dependentAlternateFareProducts = isDependent && alternateFareProducts;
100
- // Calculate pre-tranfer amount either via alternate fare or fare-id matching (price.originalAmount)
101
- const originalAmount = ((_a = dependentAlternateFareProducts === null || dependentAlternateFareProducts === void 0 ? void 0 : dependentAlternateFareProducts[0]) === null || _a === void 0 ? void 0 : _a.price.amount) -
102
- (legPrice === null || legPrice === void 0 ? void 0 : legPrice.amount) ||
103
- (appliedFareProduct === null || appliedFareProduct === void 0 ? void 0 : appliedFareProduct.price.amount) - (legPrice === null || legPrice === void 0 ? void 0 : legPrice.amount);
104
- const newCell = (React.createElement(React.Fragment, null,
105
- index === 0 && (React.createElement("th", { style: { textAlign: "left" }, scope: "row" },
106
- React.createElement(FormattedMessage, { id: `config.fares.media.${descope(medium.id)}`, defaultMessage: medium.name }),
107
- " ",
108
- React.createElement(FormattedMessage, { id: `config.fares.riderCategory.${descope(rider.id)}`, defaultMessage: rider.name }))),
109
- React.createElement("td", { style: { textAlign: legPrice ? "right" : "center" }, title: !Number.isNaN(originalAmount) &&
110
- originalAmount > 0 &&
111
- index > 0 &&
112
- intl.formatMessage({
113
- description: "Text explaining the transfer discount applied to this fare.",
114
- id: "otpUi.TripDetails.transferDiscountExplanation"
115
- }, {
116
- transferAmount: intl.formatNumber(originalAmount, {
117
- currency: (_b = legPrice === null || legPrice === void 0 ? void 0 : legPrice.currency) === null || _b === void 0 ? void 0 : _b.code,
118
- currencyDisplay: "narrowSymbol",
119
- style: "currency"
120
- })
121
- }) },
122
- !Number.isNaN(originalAmount) &&
123
- originalAmount > 0 &&
124
- index > 0 && React.createElement(TransferIcon, { size: 16 }),
125
- legPrice
126
- ? renderFare((_c = legPrice === null || legPrice === void 0 ? void 0 : legPrice.currency) === null || _c === void 0 ? void 0 : _c.code, legPrice === null || legPrice === void 0 ? void 0 : legPrice.amount)
127
- : FailDash)));
128
- const currentRowIndex = 1 + riderIndex + riders.length * mediumIndex;
129
- if (!rows[currentRowIndex]) {
130
- rows[currentRowIndex] = [];
131
- }
132
- rows[currentRowIndex].push(newCell);
133
- // Generate final column
134
- if (index === transitLegs.length - 1 && transitLegs.length > 1) {
135
- const fare = getItineraryCost(legs, descope(medium.id) || null, descope(rider.id) || null);
136
- rows[currentRowIndex].push(React.createElement("td", { style: { textAlign: (fare === null || fare === void 0 ? void 0 : fare.amount) ? "right" : "center" }, title: !(fare === null || fare === void 0 ? void 0 : fare.amount) &&
137
- intl.formatMessage({
138
- id: "otpUi.TripDetails.missingFareTotal"
139
- }) },
140
- React.createElement("em", null, (fare === null || fare === void 0 ? void 0 : fare.amount)
141
- ? renderFare(fare === null || fare === void 0 ? void 0 : fare.currency.code, fare === null || fare === void 0 ? void 0 : fare.amount)
142
- : FailDash)));
143
- }
144
- });
145
- });
57
+ const FaresV2Table = ({
58
+ legs,
59
+ favoriteMediumId,
60
+ favoriteRiderCategoryId
61
+ }) => {
62
+ const intl = (0, _reactIntl.useIntl)();
63
+ const transitLegs = legs.filter(leg => leg.transitLeg);
64
+
65
+ // Get all fare products across all legs
66
+ const fareProducts = transitLegs.flatMap(leg => leg.fareProducts);
67
+
68
+ // Reduce these into mediums and riders
69
+ const mediums = fareProducts.map(fp => {
70
+ var _fp$product;
71
+ return (_fp$product = fp.product) === null || _fp$product === void 0 ? void 0 : _fp$product.medium;
72
+ }).filter(m => m !== null).reduce(categoryReducer, []).sort(categorySorter(favoriteMediumId));
73
+ const riders = fareProducts.map(fp => {
74
+ var _fp$product2;
75
+ return (_fp$product2 = fp.product) === null || _fp$product2 === void 0 ? void 0 : _fp$product2.riderCategory;
76
+ }).filter(r => r !== null).reduce(categoryReducer, []).sort(categorySorter(favoriteRiderCategoryId));
77
+
78
+ // Ensure we have at least one rider/medium
79
+ if (riders.length === 0) {
80
+ riders.push({
81
+ name: "Fare",
82
+ id: null
83
+ });
84
+ }
85
+ if (mediums.length === 0) {
86
+ mediums.push({
87
+ name: "Regular",
88
+ id: null
89
+ });
90
+ }
91
+
92
+ // Keep track of seen fare ids to indicate transfers
93
+ const productUseIds = new Set();
94
+ const rows = [[/*#__PURE__*/_react.default.createElement("th", {
95
+ key: "faretitle",
96
+ style: {
97
+ textAlign: "left"
98
+ },
99
+ scope: "col"
100
+ }, /*#__PURE__*/_react.default.createElement(_styled.InvisibleA11yLabel, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
101
+ id: "otpUi.TripDetails.fareCategory"
102
+ }))), ...transitLegs.map(leg => /*#__PURE__*/_react.default.createElement("th", {
103
+ key: leg.tripId,
104
+ scope: "col"
105
+ }, getLegRouteName(leg))), transitLegs.length > 1 ? /*#__PURE__*/_react.default.createElement("th", {
106
+ key: "total",
107
+ style: {
108
+ textAlign: "right"
109
+ },
110
+ scope: "col"
111
+ }, /*#__PURE__*/_react.default.createElement("em", null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
112
+ id: "otpUi.TripDetails.total"
113
+ }))) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null)]];
114
+
115
+ // non-transit legs don't have fares
116
+ transitLegs.forEach((leg, index) => {
117
+ mediums.forEach((medium, mediumIndex) => {
118
+ riders.forEach((rider, riderIndex) => {
119
+ var _dependentAlternateFa, _legPrice$currency, _legPrice$currency2;
120
+ if (!medium || !rider) return;
121
+ const {
122
+ alternateFareProducts,
123
+ isDependent,
124
+ appliedFareProduct,
125
+ productUseId
126
+ } = getLegCost(leg, descope(medium.id) || null, descope(rider.id) || null, Array.from(productUseIds));
127
+ const legPrice = appliedFareProduct === null || appliedFareProduct === void 0 ? void 0 : appliedFareProduct.legPrice;
128
+ productUseIds.add(productUseId);
129
+
130
+ // Only consider alternateFareProducts if current product is dependent
131
+ const dependentAlternateFareProducts = isDependent && alternateFareProducts;
132
+
133
+ // Calculate pre-tranfer amount either via alternate fare or fare-id matching (price.originalAmount)
134
+ const originalAmount = (dependentAlternateFareProducts === null || dependentAlternateFareProducts === void 0 || (_dependentAlternateFa = dependentAlternateFareProducts[0]) === null || _dependentAlternateFa === void 0 ? void 0 : _dependentAlternateFa.price.amount) - (legPrice === null || legPrice === void 0 ? void 0 : legPrice.amount) || (appliedFareProduct === null || appliedFareProduct === void 0 ? void 0 : appliedFareProduct.price.amount) - (legPrice === null || legPrice === void 0 ? void 0 : legPrice.amount);
135
+ const newCell = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, index === 0 && /*#__PURE__*/_react.default.createElement("th", {
136
+ style: {
137
+ textAlign: "left"
138
+ },
139
+ scope: "row"
140
+ }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
141
+ id: `config.fares.media.${descope(medium.id)}`,
142
+ defaultMessage: medium.name
143
+ }), " ", /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
144
+ id: `config.fares.riderCategory.${descope(rider.id)}`,
145
+ defaultMessage: rider.name
146
+ })), /*#__PURE__*/_react.default.createElement("td", {
147
+ style: {
148
+ textAlign: legPrice ? "right" : "center"
149
+ },
150
+ title: !Number.isNaN(originalAmount) && originalAmount > 0 && index > 0 && intl.formatMessage({
151
+ description: "Text explaining the transfer discount applied to this fare.",
152
+ id: "otpUi.TripDetails.transferDiscountExplanation"
153
+ }, {
154
+ transferAmount: intl.formatNumber(originalAmount, {
155
+ currency: legPrice === null || legPrice === void 0 || (_legPrice$currency = legPrice.currency) === null || _legPrice$currency === void 0 ? void 0 : _legPrice$currency.code,
156
+ currencyDisplay: "narrowSymbol",
157
+ style: "currency"
158
+ })
159
+ })
160
+ }, !Number.isNaN(originalAmount) && originalAmount > 0 && index > 0 && /*#__PURE__*/_react.default.createElement(TransferIcon, {
161
+ size: 16
162
+ }), legPrice ? (0, _utils.renderFare)(legPrice === null || legPrice === void 0 || (_legPrice$currency2 = legPrice.currency) === null || _legPrice$currency2 === void 0 ? void 0 : _legPrice$currency2.code, legPrice === null || legPrice === void 0 ? void 0 : legPrice.amount) : FailDash));
163
+ const currentRowIndex = 1 + riderIndex + riders.length * mediumIndex;
164
+ if (!rows[currentRowIndex]) {
165
+ rows[currentRowIndex] = [];
166
+ }
167
+ rows[currentRowIndex].push(newCell);
168
+
169
+ // Generate final column
170
+ if (index === transitLegs.length - 1 && transitLegs.length > 1) {
171
+ const fare = getItineraryCost(legs, descope(medium.id) || null, descope(rider.id) || null);
172
+ rows[currentRowIndex].push(/*#__PURE__*/_react.default.createElement("td", {
173
+ style: {
174
+ textAlign: fare !== null && fare !== void 0 && fare.amount ? "right" : "center"
175
+ },
176
+ title: !(fare !== null && fare !== void 0 && fare.amount) && intl.formatMessage({
177
+ id: "otpUi.TripDetails.missingFareTotal"
178
+ })
179
+ }, /*#__PURE__*/_react.default.createElement("em", null, fare !== null && fare !== void 0 && fare.amount ? (0, _utils.renderFare)(fare === null || fare === void 0 ? void 0 : fare.currency.code, fare === null || fare === void 0 ? void 0 : fare.amount) : FailDash)));
180
+ }
181
+ });
146
182
  });
147
- return (React.createElement(StripedTable, null,
148
- React.createElement(InvisibleA11yCaption, null,
149
- React.createElement(FormattedMessage, { id: "otpUi.TripDetails.transitFareTable" })),
150
- rows.map((r, index) => (React.createElement("tr", { key: index }, r)))));
183
+ });
184
+ return /*#__PURE__*/_react.default.createElement(StripedTable, null, /*#__PURE__*/_react.default.createElement(_styled.InvisibleA11yCaption, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
185
+ id: "otpUi.TripDetails.transitFareTable"
186
+ })), rows.map((r, index) => /*#__PURE__*/_react.default.createElement("tr", {
187
+ key: index
188
+ }, r)));
151
189
  };
152
- export default FaresV2Table;
190
+ var _default = exports.default = FaresV2Table;
153
191
  //# sourceMappingURL=fares-v2-table.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fares-v2-table.js","sourceRoot":"","sources":["../../src/components/fares-v2-table.tsx"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,SAAS,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAErE,wEAAwE;AACxE,MAAM,EACJ,UAAU,EACV,gBAAgB,EAChB,OAAO,EACP,eAAe,EAChB,GAAG,SAAS,CAAC,SAAS,CAAC;AAExB,MAAM,QAAQ,GAAG,CACf;;IAEE,oBAAC,kBAAkB;QACjB,oBAAC,gBAAgB,IAAC,EAAE,EAAC,sCAAsC,GAAG,CAC3C,CACpB,CACJ,CAAC;AAEF,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;;CAEpC,CAAC;AAEF,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAA;;;;;;;;;;;;;CAahC,CAAC;AAIF,qBAAqB;AACrB,MAAM,eAAe,GAAG,CAAC,GAAiB,EAAE,GAAe,EAAE,EAAE;IAC7D,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,EAAE,CAAC,KAAK,OAAO,CAAC,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,EAAE,CAAC,CAAC,EAAE,CAAC;QACxD,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChB,CAAC;IACD,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,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAM,CAAC;4BAC/C,CAAC,CAAC,QAAQ,CACT,CACF,CACN,CAAC;gBACJ,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,CACL,oBAAC,YAAY;QACX,oBAAC,oBAAoB;YACnB,oBAAC,gBAAgB,IAAC,EAAE,EAAC,oCAAoC,GAAG,CACvC;QACtB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CACtB,4BAAI,GAAG,EAAE,KAAK,IAAG,CAAC,CAAM,CACzB,CAAC,CACW,CAChB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"fares-v2-table.js","names":["_react","_interopRequireDefault","require","_coreUtils","_reactIntl","_styledComponents","_Transfer","_utils","_styled","getLegCost","getItineraryCost","descope","getLegRouteName","coreUtils","itinerary","FailDash","default","createElement","Fragment","InvisibleA11yLabel","FormattedMessage","id","TransferIcon","styled","Transfer","withConfig","displayName","componentId","StripedTable","table","categoryReducer","acc","cur","some","m","push","categorySorter","favoriteId","a","b","aId","bId","FaresV2Table","legs","favoriteMediumId","favoriteRiderCategoryId","intl","useIntl","transitLegs","filter","leg","transitLeg","fareProducts","flatMap","mediums","map","fp","_fp$product","product","medium","reduce","sort","riders","_fp$product2","riderCategory","r","length","name","productUseIds","Set","rows","key","style","textAlign","scope","tripId","forEach","index","mediumIndex","rider","riderIndex","_dependentAlternateFa","_legPrice$currency","_legPrice$currency2","alternateFareProducts","isDependent","appliedFareProduct","productUseId","Array","from","legPrice","add","dependentAlternateFareProducts","originalAmount","price","amount","newCell","defaultMessage","title","Number","isNaN","formatMessage","description","transferAmount","formatNumber","currency","code","currencyDisplay","size","renderFare","currentRowIndex","fare","InvisibleA11yCaption","_default","exports"],"sources":["../../src/components/fares-v2-table.tsx"],"sourcesContent":["/* eslint-disable no-underscore-dangle */\nimport React from \"react\";\nimport { Leg } from \"@opentripplanner/types\";\nimport coreUtils from \"@opentripplanner/core-utils\";\nimport { FormattedMessage, useIntl } from \"react-intl\";\nimport styled from \"styled-components\";\nimport { Transfer } from \"@styled-icons/boxicons-regular/Transfer\";\n\nimport { renderFare } from \"../utils\";\nimport { InvisibleA11yCaption, InvisibleA11yLabel } from \"../styled\";\n\n// TODO: inline this import? (@opentripplanner/core-utils/src/itinerary)\nconst {\n getLegCost,\n getItineraryCost,\n descope,\n getLegRouteName\n} = coreUtils.itinerary;\n\nconst FailDash = (\n <>\n -\n <InvisibleA11yLabel>\n <FormattedMessage id=\"otpUi.TripDetails.legMissingFareInfo\" />\n </InvisibleA11yLabel>\n </>\n);\n\nconst TransferIcon = styled(Transfer)`\n padding-right: 0.25ch;\n`;\n\nconst StripedTable = styled.table`\n text-align: right;\n\n tr td,\n tr th {\n padding: 4px;\n }\n\n tr td:nth-of-type(2n + 1),\n tr th:nth-of-type(2n) {\n background: #cccccc55;\n border-color: #cccccc55;\n }\n`;\n\ntype IdNamePair = { id: string; name: string };\n\n// Removes duplicates\nconst categoryReducer = (acc: IdNamePair[], cur: IdNamePair) => {\n if (!acc.some(m => descope(m?.id) === descope(cur?.id))) {\n acc.push(cur);\n }\n return acc;\n};\n\n// Put the preferred medium first, and then all the others alphabetical\nconst categorySorter = (favoriteId?: string) => (\n a: IdNamePair,\n b: IdNamePair\n): number => {\n const aId = descope(a?.id);\n const bId = descope(b?.id);\n\n if (favoriteId && aId === favoriteId) {\n return -1;\n }\n if (favoriteId && bId === favoriteId) {\n return 1;\n }\n\n return aId > bId ? 1 : -1;\n};\n\n// TODO: This component currently can only show one type of fare per medium\nconst FaresV2Table = ({\n legs,\n favoriteMediumId,\n favoriteRiderCategoryId\n}: {\n legs: Leg[];\n favoriteMediumId?: string;\n favoriteRiderCategoryId?: string;\n}): JSX.Element => {\n const intl = useIntl();\n\n const transitLegs = legs.filter(leg => leg.transitLeg);\n\n // Get all fare products across all legs\n const fareProducts = transitLegs.flatMap(leg => leg.fareProducts);\n\n // Reduce these into mediums and riders\n const mediums = fareProducts\n .map(fp => fp.product?.medium)\n .filter(m => m !== null)\n .reduce(categoryReducer, [])\n .sort(categorySorter(favoriteMediumId));\n const riders = fareProducts\n .map(fp => fp.product?.riderCategory)\n .filter(r => r !== null)\n .reduce(categoryReducer, [])\n .sort(categorySorter(favoriteRiderCategoryId));\n\n // Ensure we have at least one rider/medium\n if (riders.length === 0) {\n riders.push({ name: \"Fare\", id: null });\n }\n if (mediums.length === 0) {\n mediums.push({ name: \"Regular\", id: null });\n }\n\n // Keep track of seen fare ids to indicate transfers\n const productUseIds: Set<string> = new Set();\n\n const rows = [\n [\n <th key=\"faretitle\" style={{ textAlign: \"left\" }} scope=\"col\">\n <InvisibleA11yLabel>\n <FormattedMessage id=\"otpUi.TripDetails.fareCategory\" />\n </InvisibleA11yLabel>\n </th>,\n ...transitLegs.map(leg => (\n <th key={leg.tripId} scope=\"col\">\n {getLegRouteName(leg)}\n </th>\n )),\n transitLegs.length > 1 ? (\n <th key=\"total\" style={{ textAlign: \"right\" }} scope=\"col\">\n <em>\n <FormattedMessage id=\"otpUi.TripDetails.total\" />\n </em>\n </th>\n ) : (\n <></>\n )\n ]\n ];\n\n // non-transit legs don't have fares\n transitLegs.forEach((leg, index) => {\n mediums.forEach((medium, mediumIndex) => {\n riders.forEach((rider, riderIndex) => {\n if (!medium || !rider) return;\n const {\n alternateFareProducts,\n isDependent,\n appliedFareProduct,\n productUseId\n } = getLegCost(\n leg,\n descope(medium.id) || null,\n descope(rider.id) || null,\n Array.from(productUseIds)\n );\n const legPrice = appliedFareProduct?.legPrice;\n\n productUseIds.add(productUseId);\n\n // Only consider alternateFareProducts if current product is dependent\n const dependentAlternateFareProducts =\n isDependent && alternateFareProducts;\n\n // Calculate pre-tranfer amount either via alternate fare or fare-id matching (price.originalAmount)\n const originalAmount =\n dependentAlternateFareProducts?.[0]?.price.amount -\n legPrice?.amount ||\n appliedFareProduct?.price.amount - legPrice?.amount;\n\n const newCell = (\n <>\n {/* Only render the list of fare types once */}\n {index === 0 && (\n <th style={{ textAlign: \"left\" }} scope=\"row\">\n <FormattedMessage\n id={`config.fares.media.${descope(medium.id)}`}\n defaultMessage={medium.name}\n />{\" \"}\n <FormattedMessage\n id={`config.fares.riderCategory.${descope(rider.id)}`}\n defaultMessage={rider.name}\n />\n </th>\n )}\n <td\n style={{ textAlign: legPrice ? \"right\" : \"center\" }}\n title={\n !Number.isNaN(originalAmount) &&\n originalAmount > 0 &&\n index > 0 &&\n intl.formatMessage(\n {\n description:\n \"Text explaining the transfer discount applied to this fare.\",\n id: \"otpUi.TripDetails.transferDiscountExplanation\"\n },\n {\n transferAmount: intl.formatNumber(originalAmount, {\n currency: legPrice?.currency?.code,\n currencyDisplay: \"narrowSymbol\",\n style: \"currency\"\n })\n }\n )\n }\n >\n {!Number.isNaN(originalAmount) &&\n originalAmount > 0 &&\n index > 0 && <TransferIcon size={16} />}\n {/* Leg Price will always be defined if the fare product has a price */}\n {legPrice\n ? renderFare(legPrice?.currency?.code, legPrice?.amount)\n : FailDash}\n </td>\n </>\n );\n const currentRowIndex = 1 + riderIndex + riders.length * mediumIndex;\n if (!rows[currentRowIndex]) {\n rows[currentRowIndex] = [];\n }\n rows[currentRowIndex].push(newCell);\n\n // Generate final column\n if (index === transitLegs.length - 1 && transitLegs.length > 1) {\n const fare = getItineraryCost(\n legs,\n descope(medium.id) || null,\n descope(rider.id) || null\n );\n rows[currentRowIndex].push(\n <td\n style={{ textAlign: fare?.amount ? \"right\" : \"center\" }}\n title={\n !fare?.amount &&\n intl.formatMessage({\n id: \"otpUi.TripDetails.missingFareTotal\"\n })\n }\n >\n <em>\n {fare?.amount\n ? renderFare(fare?.currency.code, fare?.amount)\n : FailDash}\n </em>\n </td>\n );\n }\n });\n });\n });\n\n return (\n <StripedTable>\n <InvisibleA11yCaption>\n <FormattedMessage id=\"otpUi.TripDetails.transitFareTable\" />\n </InvisibleA11yCaption>\n {rows.map((r, index) => (\n <tr key={index}>{r}</tr>\n ))}\n </StripedTable>\n );\n};\n\nexport default FaresV2Table;\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AATA;;AAWA;AACA,MAAM;EACJO,UAAU;EACVC,gBAAgB;EAChBC,OAAO;EACPC;AACF,CAAC,GAAGC,kBAAS,CAACC,SAAS;AAEvB,MAAMC,QAAQ,gBACZf,MAAA,CAAAgB,OAAA,CAAAC,aAAA,CAAAjB,MAAA,CAAAgB,OAAA,CAAAE,QAAA,QAAE,GAEA,eAAAlB,MAAA,CAAAgB,OAAA,CAAAC,aAAA,CAACT,OAAA,CAAAW,kBAAkB,qBACjBnB,MAAA,CAAAgB,OAAA,CAAAC,aAAA,CAACb,UAAA,CAAAgB,gBAAgB;EAACC,EAAE,EAAC;AAAsC,CAAE,CAC3C,CACpB,CACH;AAED,MAAMC,YAAY,GAAG,IAAAC,yBAAM,EAACC,kBAAQ,CAAC,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,6BAEpC;AAED,MAAMC,YAAY,GAAGL,yBAAM,CAACM,KAAK,CAAAJ,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,+IAahC;AAID;AACA,MAAMG,eAAe,GAAGA,CAACC,GAAiB,EAAEC,GAAe,KAAK;EAC9D,IAAI,CAACD,GAAG,CAACE,IAAI,CAACC,CAAC,IAAIvB,OAAO,CAACuB,CAAC,aAADA,CAAC,uBAADA,CAAC,CAAEb,EAAE,CAAC,KAAKV,OAAO,CAACqB,GAAG,aA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MAAA,CAAAgB,OAAA,CAAAC,aAAA;IAAIsD,GAAG,EAAEM;EAAM,GAAEZ,CAAM,CACxB,CACW,CAAC;AAEnB,CAAC;AAAC,IAAAgD,QAAA,GAAAC,OAAA,CAAAlG,OAAA,GAEa0B,YAAY","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"fares.d.ts","sourceRoot":"","sources":["../../src/components/fares.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG5C,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAMxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAM5C,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAClD,eAAe,CAAC,EAAE,mBAAmB,CAAC;CACvC;AAQD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC5B,SAAS,EACT,WAAW,EACX,eAAe,EAChB,EAAE,UAAU,GAAG,YAAY,GAAG,IAAI,CAiJlC"}
1
+ {"version":3,"file":"fares.d.ts","sourceRoot":"","sources":["../../src/components/fares.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG5C,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAMxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAM5C,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAClD,eAAe,CAAC,EAAE,mBAAmB,CAAC;CACvC;AAQD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC5B,SAAS,EACT,WAAW,EACX,eAAe,EAChB,EAAE,UAAU,GAAG,YAAY,GAAG,IAAI,CAmJlC"}
@@ -1,73 +1,133 @@
1
- import React from "react";
2
- import { FormattedMessage } from "react-intl";
3
- import coreUtils from "@opentripplanner/core-utils";
4
- import { MoneyBillAlt } from "@styled-icons/fa-solid";
5
- import { flatten } from "flat";
6
- import * as S from "../styled";
7
- import { boldText, renderFare } from "../utils";
8
- import TripDetail from "../trip-detail";
9
- import FaresV2Table from "./fares-v2-table";
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = Fares;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _reactIntl = require("react-intl");
10
+ var _coreUtils = _interopRequireDefault(require("@opentripplanner/core-utils"));
11
+ var _faSolid = require("@styled-icons/fa-solid");
12
+ var _flat = require("flat");
13
+ var S = _interopRequireWildcard(require("../styled"));
14
+ var _utils = require("../utils");
15
+ var _tripDetail = _interopRequireDefault(require("../trip-detail"));
16
+ var _faresV2Table = _interopRequireDefault(require("./fares-v2-table"));
17
+ var _enUS = _interopRequireDefault(require("../../i18n/en-US.yml"));
18
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
10
19
  // Load the default messages.
11
- import defaultEnglishMessages from "../../i18n/en-US.yml";
20
+
12
21
  // HACK: We should flatten the messages loaded above because
13
22
  // the YAML loaders behave differently between webpack and our version of jest:
14
23
  // - the yaml loader for webpack returns a nested object,
15
24
  // - the yaml loader for jest returns messages with flattened ids.
16
- const defaultMessages = flatten(defaultEnglishMessages);
17
- export default function Fares({ itinerary, FareDetails, defaultFareType }) {
18
- var _a;
19
- // process the transit fare
20
- const fareResult = coreUtils.itinerary.calculateTncFares(itinerary);
21
- const { currencyCode, maxTNCFare, minTNCFare } = fareResult;
22
- const { companies, fareTypes } = itinerary.legs.reduce((prev, leg) => {
23
- if (leg.rideHailingEstimate) {
24
- prev.companies = leg.rideHailingEstimate.provider.id;
25
+ const defaultMessages = (0, _flat.flatten)(_enUS.default);
26
+ function Fares({
27
+ itinerary,
28
+ FareDetails,
29
+ defaultFareType
30
+ }) {
31
+ var _defaultFareTotal$cur;
32
+ // process the transit fare
33
+ const fareResult = _coreUtils.default.itinerary.calculateTncFares(itinerary);
34
+ const {
35
+ currencyCode,
36
+ maxTNCFare,
37
+ minTNCFare
38
+ } = fareResult;
39
+ const {
40
+ companies,
41
+ fareTypes
42
+ } = itinerary.legs.reduce((prev, leg) => {
43
+ if (leg.rideHailingEstimate) {
44
+ prev.companies = leg.rideHailingEstimate.provider.id;
45
+ }
46
+ if (leg.fareProducts) {
47
+ leg.fareProducts.forEach(fp => {
48
+ var _fp$product$medium, _fp$product$riderCate;
49
+ const mediumId = (_fp$product$medium = fp.product.medium) === null || _fp$product$medium === void 0 ? void 0 : _fp$product$medium.id;
50
+ const riderCategoryId = (_fp$product$riderCate = fp.product.riderCategory) === null || _fp$product$riderCate === void 0 ? void 0 : _fp$product$riderCate.id;
51
+ if (!prev.fareTypes.find(ft => ft.mediumId === mediumId && ft.riderCategoryId === riderCategoryId)) {
52
+ prev.fareTypes.push({
53
+ mediumId,
54
+ riderCategoryId
55
+ });
25
56
  }
26
- if (leg.fareProducts) {
27
- leg.fareProducts.forEach(fp => {
28
- var _a, _b;
29
- const mediumId = (_a = fp.product.medium) === null || _a === void 0 ? void 0 : _a.id;
30
- const riderCategoryId = (_b = fp.product.riderCategory) === null || _b === void 0 ? void 0 : _b.id;
31
- if (!prev.fareTypes.find(ft => ft.mediumId === mediumId &&
32
- ft.riderCategoryId === riderCategoryId)) {
33
- prev.fareTypes.push({ mediumId, riderCategoryId });
34
- }
35
- });
36
- }
37
- return prev;
38
- }, { companies: "", fareTypes: [] });
39
- const defaultFareTotal = coreUtils.itinerary.getItineraryCost(itinerary.legs, (defaultFareType === null || defaultFareType === void 0 ? void 0 : defaultFareType.mediumId) || null, (defaultFareType === null || defaultFareType === void 0 ? void 0 : defaultFareType.riderCategoryId) || null);
40
- // Depending on if there are additional fares to display either render a <span> or a <details>
41
- const fare = defaultFareTotal !== undefined && (React.createElement(S.Fare, null,
42
- React.createElement(S.TransitFare, null,
43
- React.createElement("summary", { style: { display: fareTypes.length > 1 ? "list-item" : "" } },
44
- React.createElement(FormattedMessage, { defaultMessage: defaultMessages["otpUi.TripDetails.transitFareEntry"], description: "Text showing the price of tickets on public transportation.", id: "otpUi.TripDetails.transitFareEntry", values: {
45
- name: (React.createElement(FormattedMessage, { defaultMessage: defaultMessages["otpUi.TripDetails.transitFare"], description: "Text showing the price of tickets on public transportation.", id: "otpUi.TripDetails.transitFare" })),
46
- strong: boldText,
47
- value: renderFare(((_a = defaultFareTotal.currency) === null || _a === void 0 ? void 0 : _a.code) || "USD", defaultFareTotal === null || defaultFareTotal === void 0 ? void 0 : defaultFareTotal.amount)
48
- } })),
49
- React.createElement(FaresV2Table, { legs: itinerary.legs, favoriteMediumId: Array.isArray(defaultFareType === null || defaultFareType === void 0 ? void 0 : defaultFareType.mediumId)
50
- ? defaultFareType === null || defaultFareType === void 0 ? void 0 : defaultFareType.mediumId[0]
51
- : defaultFareType === null || defaultFareType === void 0 ? void 0 : defaultFareType.mediumId, favoriteRiderCategoryId: Array.isArray(defaultFareType === null || defaultFareType === void 0 ? void 0 : defaultFareType.riderCategoryId)
52
- ? defaultFareType === null || defaultFareType === void 0 ? void 0 : defaultFareType.riderCategoryId[0]
53
- : defaultFareType === null || defaultFareType === void 0 ? void 0 : defaultFareType.riderCategoryId }))));
54
- const tncFare = minTNCFare !== 0 && (React.createElement(S.Fare, null,
55
- React.createElement(S.TNCFare, null,
56
- React.createElement(FormattedMessage, { defaultMessage: defaultMessages["otpUi.TripDetails.tncFare"], description: "Text showing the price paid to transportation network companies.", id: "otpUi.TripDetails.tncFare", values: {
57
- companies: (
58
- // S.TNCFareCompanies capitalizes the TNC company ID (e.g. "COMPANY")
59
- // after it is converted to lowercase, so it renders as "Company".
60
- React.createElement(S.TNCFareCompanies, null, companies.toLowerCase())),
61
- maxTNCFare: renderFare(currencyCode, maxTNCFare),
62
- minTNCFare: renderFare(currencyCode, minTNCFare),
63
- strong: boldText
64
- } }))));
65
- return (React.createElement(React.Fragment, null,
66
- itinerary.legs.some(leg => leg.fareProducts) && (React.createElement(TripDetail, { className: "fares",
67
- // Any custom description for the transit fare needs to be handled by the slot.
68
- description: FareDetails && (React.createElement(FareDetails, { legs: itinerary.legs, maxTNCFare: maxTNCFare, minTNCFare: minTNCFare })), icon: React.createElement(MoneyBillAlt, { size: 17 }), summary: fare || React.createElement(FaresV2Table, { legs: itinerary.legs }) })),
69
- !!tncFare && (React.createElement(TripDetail, { className: "tnc-fare",
70
- // Any custom description for the transit fare needs to be handled by the slot.
71
- description: FareDetails && (React.createElement(FareDetails, { legs: itinerary.legs, maxTNCFare: maxTNCFare, minTNCFare: minTNCFare })), icon: React.createElement(MoneyBillAlt, { size: 17 }), summary: tncFare }))));
57
+ });
58
+ }
59
+ return prev;
60
+ }, {
61
+ companies: "",
62
+ fareTypes: []
63
+ });
64
+ const defaultFareTotal = _coreUtils.default.itinerary.getItineraryCost(itinerary.legs, (defaultFareType === null || defaultFareType === void 0 ? void 0 : defaultFareType.mediumId) || null, (defaultFareType === null || defaultFareType === void 0 ? void 0 : defaultFareType.riderCategoryId) || null);
65
+ // Depending on if there are additional fares to display either render a <span> or a <details>
66
+ const fare = defaultFareTotal !== undefined && /*#__PURE__*/_react.default.createElement(S.Fare, null, /*#__PURE__*/_react.default.createElement(S.TransitFare, null, /*#__PURE__*/_react.default.createElement("summary", {
67
+ style: {
68
+ display: fareTypes.length > 1 ? "list-item" : ""
69
+ }
70
+ }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
71
+ defaultMessage: defaultMessages["otpUi.TripDetails.transitFareEntry"],
72
+ description: "Text showing the price of tickets on public transportation.",
73
+ id: "otpUi.TripDetails.transitFareEntry",
74
+ values: {
75
+ name: /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
76
+ defaultMessage: defaultMessages["otpUi.TripDetails.transitFare"],
77
+ description: "Text showing the price of tickets on public transportation.",
78
+ id: "otpUi.TripDetails.transitFare"
79
+ }),
80
+ strong: _utils.boldText,
81
+ value: (0, _utils.renderFare)(((_defaultFareTotal$cur = defaultFareTotal.currency) === null || _defaultFareTotal$cur === void 0 ? void 0 : _defaultFareTotal$cur.code) || "USD", defaultFareTotal === null || defaultFareTotal === void 0 ? void 0 : defaultFareTotal.amount)
82
+ }
83
+ })), /*#__PURE__*/_react.default.createElement(_faresV2Table.default, {
84
+ legs: itinerary.legs,
85
+ favoriteMediumId: Array.isArray(defaultFareType === null || defaultFareType === void 0 ? void 0 : defaultFareType.mediumId) ? defaultFareType === null || defaultFareType === void 0 ? void 0 : defaultFareType.mediumId[0] : defaultFareType === null || defaultFareType === void 0 ? void 0 : defaultFareType.mediumId,
86
+ favoriteRiderCategoryId: Array.isArray(defaultFareType === null || defaultFareType === void 0 ? void 0 : defaultFareType.riderCategoryId) ? defaultFareType === null || defaultFareType === void 0 ? void 0 : defaultFareType.riderCategoryId[0] : defaultFareType === null || defaultFareType === void 0 ? void 0 : defaultFareType.riderCategoryId
87
+ })));
88
+ const tncFare = minTNCFare !== 0 && /*#__PURE__*/_react.default.createElement(S.Fare, null, /*#__PURE__*/_react.default.createElement(S.TNCFare, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
89
+ defaultMessage: defaultMessages["otpUi.TripDetails.tncFare"],
90
+ description: "Text showing the price paid to transportation network companies.",
91
+ id: "otpUi.TripDetails.tncFare",
92
+ values: {
93
+ companies:
94
+ /*#__PURE__*/
95
+ // S.TNCFareCompanies capitalizes the TNC company ID (e.g. "COMPANY")
96
+ // after it is converted to lowercase, so it renders as "Company".
97
+ _react.default.createElement(S.TNCFareCompanies, null, companies.toLowerCase()),
98
+ maxTNCFare: (0, _utils.renderFare)(currencyCode, maxTNCFare),
99
+ minTNCFare: (0, _utils.renderFare)(currencyCode, minTNCFare),
100
+ strong: _utils.boldText
101
+ }
102
+ })));
103
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, itinerary.legs.some(leg => leg.fareProducts && leg.fareProducts.length > 0) && /*#__PURE__*/_react.default.createElement(_tripDetail.default, {
104
+ className: "fares"
105
+ // Any custom description for the transit fare needs to be handled by the slot.
106
+ ,
107
+ description: FareDetails && /*#__PURE__*/_react.default.createElement(FareDetails, {
108
+ legs: itinerary.legs,
109
+ maxTNCFare: maxTNCFare,
110
+ minTNCFare: minTNCFare
111
+ }),
112
+ icon: /*#__PURE__*/_react.default.createElement(_faSolid.MoneyBillAlt, {
113
+ size: 17
114
+ }),
115
+ summary: fare || /*#__PURE__*/_react.default.createElement(_faresV2Table.default, {
116
+ legs: itinerary.legs
117
+ })
118
+ }), !!tncFare && /*#__PURE__*/_react.default.createElement(_tripDetail.default, {
119
+ className: "tnc-fare"
120
+ // Any custom description for the transit fare needs to be handled by the slot.
121
+ ,
122
+ description: FareDetails && /*#__PURE__*/_react.default.createElement(FareDetails, {
123
+ legs: itinerary.legs,
124
+ maxTNCFare: maxTNCFare,
125
+ minTNCFare: minTNCFare
126
+ }),
127
+ icon: /*#__PURE__*/_react.default.createElement(_faSolid.MoneyBillAlt, {
128
+ size: 17
129
+ }),
130
+ summary: tncFare
131
+ }));
72
132
  }
73
133
  //# sourceMappingURL=fares.js.map