@opentripplanner/trip-details 9.0.7 → 9.1.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 +75 -65
- package/esm/components/fares-v2-table.js.map +1 -1
- package/i18n/es.yml +3 -1
- package/i18n/ko.yml +1 -0
- package/i18n/ru.yml +4 -2
- package/i18n/tl.yml +3 -1
- package/i18n/vi.yml +5 -2
- package/i18n/zh_Hans.yml +3 -1
- package/i18n/zh_Hant.yml +3 -1
- package/lib/components/fares-v2-table.d.ts.map +1 -1
- package/lib/components/fares-v2-table.js +74 -63
- package/lib/components/fares-v2-table.js.map +1 -1
- package/package.json +2 -2
- package/src/__snapshots__/TripDetails.story.tsx.snap +49 -64
- package/src/components/fares-v2-table.tsx +118 -100
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -7,8 +7,6 @@ import styled from "styled-components";
|
|
|
7
7
|
import { Transfer } from "@styled-icons/boxicons-regular/Transfer";
|
|
8
8
|
import { renderFare } from "../utils";
|
|
9
9
|
import { InvisibleA11yCaption, InvisibleA11yLabel } from "../styled";
|
|
10
|
-
|
|
11
|
-
// TODO: inline this import? (@opentripplanner/core-utils/src/itinerary)
|
|
12
10
|
var _coreUtils$itinerary = coreUtils.itinerary,
|
|
13
11
|
getLegCost = _coreUtils$itinerary.getLegCost,
|
|
14
12
|
getItineraryCost = _coreUtils$itinerary.getItineraryCost,
|
|
@@ -69,16 +67,28 @@ var FaresV2Table = function FaresV2Table(_ref) {
|
|
|
69
67
|
var mediums = fareProducts.map(function (fp) {
|
|
70
68
|
var _fp$product;
|
|
71
69
|
return (_fp$product = fp.product) === null || _fp$product === void 0 ? void 0 : _fp$product.medium;
|
|
72
|
-
}).filter(function (m) {
|
|
73
|
-
return m !== null;
|
|
74
70
|
}).reduce(categoryReducer, []).sort(categorySorter(favoriteMediumId));
|
|
75
71
|
var riders = fareProducts.map(function (fp) {
|
|
76
72
|
var _fp$product2;
|
|
77
73
|
return (_fp$product2 = fp.product) === null || _fp$product2 === void 0 ? void 0 : _fp$product2.riderCategory;
|
|
78
|
-
}).filter(function (r) {
|
|
79
|
-
return r !== null;
|
|
80
74
|
}).reduce(categoryReducer, []).sort(categorySorter(favoriteRiderCategoryId));
|
|
81
75
|
|
|
76
|
+
// Generate the pairs of riders and mediums, but filter out ones
|
|
77
|
+
// that never occur in the FareProducts
|
|
78
|
+
var riderMediumPairs = mediums.flatMap(function (medium) {
|
|
79
|
+
return riders.map(function (rider) {
|
|
80
|
+
return {
|
|
81
|
+
medium: medium,
|
|
82
|
+
rider: rider
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}).filter(function (rmp) {
|
|
86
|
+
return fareProducts.some(function (fp) {
|
|
87
|
+
var _fp$product3, _rmp$rider, _fp$product4, _rmp$medium;
|
|
88
|
+
return ((_fp$product3 = fp.product) === null || _fp$product3 === void 0 || (_fp$product3 = _fp$product3.riderCategory) === null || _fp$product3 === void 0 ? void 0 : _fp$product3.id) === ((_rmp$rider = rmp.rider) === null || _rmp$rider === void 0 ? void 0 : _rmp$rider.id) && ((_fp$product4 = fp.product) === null || _fp$product4 === void 0 || (_fp$product4 = _fp$product4.medium) === null || _fp$product4 === void 0 ? void 0 : _fp$product4.id) === ((_rmp$medium = rmp.medium) === null || _rmp$medium === void 0 ? void 0 : _rmp$medium.id);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
82
92
|
// Ensure we have at least one rider/medium
|
|
83
93
|
if (riders.length === 0) {
|
|
84
94
|
riders.push({
|
|
@@ -120,70 +130,70 @@ var FaresV2Table = function FaresV2Table(_ref) {
|
|
|
120
130
|
|
|
121
131
|
// non-transit legs don't have fares
|
|
122
132
|
transitLegs.forEach(function (leg, index) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
133
|
+
riderMediumPairs.forEach(function (rmp, currentRowIndex) {
|
|
134
|
+
var _medium$id, _rider$id, _dependentAlternateFa, _legPrice$currency, _legPrice$currency2;
|
|
135
|
+
var medium = rmp.medium,
|
|
136
|
+
rider = rmp.rider;
|
|
137
|
+
var _getLegCost = getLegCost(leg, descope((_medium$id = medium === null || medium === void 0 ? void 0 : medium.id) !== null && _medium$id !== void 0 ? _medium$id : null), descope((_rider$id = rider === null || rider === void 0 ? void 0 : rider.id) !== null && _rider$id !== void 0 ? _rider$id : null), Array.from(productUseIds)),
|
|
138
|
+
alternateFareProducts = _getLegCost.alternateFareProducts,
|
|
139
|
+
isDependent = _getLegCost.isDependent,
|
|
140
|
+
appliedFareProduct = _getLegCost.appliedFareProduct,
|
|
141
|
+
productUseId = _getLegCost.productUseId;
|
|
142
|
+
var legPrice = appliedFareProduct === null || appliedFareProduct === void 0 ? void 0 : appliedFareProduct.legPrice;
|
|
143
|
+
productUseIds.add(productUseId);
|
|
134
144
|
|
|
135
|
-
|
|
136
|
-
|
|
145
|
+
// Only consider alternateFareProducts if current product is dependent
|
|
146
|
+
var dependentAlternateFareProducts = isDependent && alternateFareProducts;
|
|
137
147
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
// Calculate pre-tranfer amount either via alternate fare or fare-id matching (price.originalAmount)
|
|
149
|
+
var 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);
|
|
150
|
+
var newCell = /*#__PURE__*/React.createElement(React.Fragment, null, index === 0 && /*#__PURE__*/React.createElement("th", {
|
|
151
|
+
style: {
|
|
152
|
+
textAlign: "left"
|
|
153
|
+
},
|
|
154
|
+
scope: "row"
|
|
155
|
+
}, (medium === null || medium === void 0 ? void 0 : medium.id) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
156
|
+
id: "config.fares.media.".concat(descope(medium.id)),
|
|
157
|
+
defaultMessage: medium.name
|
|
158
|
+
}), " "), (rider === null || rider === void 0 ? void 0 : rider.id) && /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
159
|
+
id: "config.fares.riderCategory.".concat(descope(rider.id)),
|
|
160
|
+
defaultMessage: rider.name
|
|
161
|
+
}), !(medium !== null && medium !== void 0 && medium.id) && !(rider !== null && rider !== void 0 && rider.id) ? FailDash : null), /*#__PURE__*/React.createElement("td", {
|
|
162
|
+
style: {
|
|
163
|
+
textAlign: legPrice ? "right" : "center"
|
|
164
|
+
},
|
|
165
|
+
title: !Number.isNaN(originalAmount) && originalAmount > 0 && index > 0 && intl.formatMessage({
|
|
166
|
+
description: "Text explaining the transfer discount applied to this fare.",
|
|
167
|
+
id: "otpUi.TripDetails.transferDiscountExplanation"
|
|
168
|
+
}, {
|
|
169
|
+
transferAmount: intl.formatNumber(originalAmount, {
|
|
170
|
+
currency: legPrice === null || legPrice === void 0 || (_legPrice$currency = legPrice.currency) === null || _legPrice$currency === void 0 ? void 0 : _legPrice$currency.code,
|
|
171
|
+
currencyDisplay: "narrowSymbol",
|
|
172
|
+
style: "currency"
|
|
173
|
+
})
|
|
174
|
+
})
|
|
175
|
+
}, !Number.isNaN(originalAmount) && originalAmount > 0 && index > 0 && /*#__PURE__*/React.createElement(TransferIcon, {
|
|
176
|
+
size: 16
|
|
177
|
+
}), legPrice ? 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));
|
|
178
|
+
var nextRowIndex = currentRowIndex + 1;
|
|
179
|
+
if (!rows[nextRowIndex]) {
|
|
180
|
+
rows[nextRowIndex] = [];
|
|
181
|
+
}
|
|
182
|
+
rows[nextRowIndex].push(newCell);
|
|
183
|
+
|
|
184
|
+
// Generate final column
|
|
185
|
+
if (index === transitLegs.length - 1 && transitLegs.length > 1) {
|
|
186
|
+
var _medium$id2, _rider$id2;
|
|
187
|
+
var fare = getItineraryCost(legs, descope((_medium$id2 = medium === null || medium === void 0 ? void 0 : medium.id) !== null && _medium$id2 !== void 0 ? _medium$id2 : null), descope((_rider$id2 = rider === null || rider === void 0 ? void 0 : rider.id) !== null && _rider$id2 !== void 0 ? _rider$id2 : null));
|
|
188
|
+
rows[nextRowIndex].push(/*#__PURE__*/React.createElement("td", {
|
|
152
189
|
style: {
|
|
153
|
-
textAlign:
|
|
190
|
+
textAlign: fare !== null && fare !== void 0 && fare.amount ? "right" : "center"
|
|
154
191
|
},
|
|
155
|
-
title: !
|
|
156
|
-
|
|
157
|
-
id: "otpUi.TripDetails.transferDiscountExplanation"
|
|
158
|
-
}, {
|
|
159
|
-
transferAmount: intl.formatNumber(originalAmount, {
|
|
160
|
-
currency: legPrice === null || legPrice === void 0 || (_legPrice$currency = legPrice.currency) === null || _legPrice$currency === void 0 ? void 0 : _legPrice$currency.code,
|
|
161
|
-
currencyDisplay: "narrowSymbol",
|
|
162
|
-
style: "currency"
|
|
163
|
-
})
|
|
192
|
+
title: !(fare !== null && fare !== void 0 && fare.amount) && intl.formatMessage({
|
|
193
|
+
id: "otpUi.TripDetails.missingFareTotal"
|
|
164
194
|
})
|
|
165
|
-
},
|
|
166
|
-
|
|
167
|
-
}), legPrice ? 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));
|
|
168
|
-
var currentRowIndex = 1 + riderIndex + riders.length * mediumIndex;
|
|
169
|
-
if (!rows[currentRowIndex]) {
|
|
170
|
-
rows[currentRowIndex] = [];
|
|
171
|
-
}
|
|
172
|
-
rows[currentRowIndex].push(newCell);
|
|
173
|
-
|
|
174
|
-
// Generate final column
|
|
175
|
-
if (index === transitLegs.length - 1 && transitLegs.length > 1) {
|
|
176
|
-
var fare = getItineraryCost(legs, descope(medium.id) || null, descope(rider.id) || null);
|
|
177
|
-
rows[currentRowIndex].push(/*#__PURE__*/React.createElement("td", {
|
|
178
|
-
style: {
|
|
179
|
-
textAlign: fare !== null && fare !== void 0 && fare.amount ? "right" : "center"
|
|
180
|
-
},
|
|
181
|
-
title: !(fare !== null && fare !== void 0 && fare.amount) && intl.formatMessage({
|
|
182
|
-
id: "otpUi.TripDetails.missingFareTotal"
|
|
183
|
-
})
|
|
184
|
-
}, /*#__PURE__*/React.createElement("em", null, fare !== null && fare !== void 0 && fare.amount ? renderFare(fare === null || fare === void 0 ? void 0 : fare.currency.code, fare === null || fare === void 0 ? void 0 : fare.amount) : FailDash)));
|
|
185
|
-
}
|
|
186
|
-
});
|
|
195
|
+
}, /*#__PURE__*/React.createElement("em", null, fare !== null && fare !== void 0 && fare.amount ? renderFare(fare === null || fare === void 0 ? void 0 : fare.currency.code, fare === null || fare === void 0 ? void 0 : fare.amount) : FailDash)));
|
|
196
|
+
}
|
|
187
197
|
});
|
|
188
198
|
});
|
|
189
199
|
return /*#__PURE__*/React.createElement(StripedTable, null, /*#__PURE__*/React.createElement(InvisibleA11yCaption, null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fares-v2-table.js","names":["React","coreUtils","FormattedMessage","useIntl","styled","Transfer","renderFare","InvisibleA11yCaption","InvisibleA11yLabel","_coreUtils$itinerary","itinerary","getLegCost","getItineraryCost","descope","getLegRouteName","FailDash","createElement","Fragment","id","TransferIcon","withConfig","displayName","componentId","StripedTable","table","categoryReducer","acc","cur","some","m","push","categorySorter","favoriteId","a","b","aId","bId","FaresV2Table","_ref","legs","favoriteMediumId","favoriteRiderCategoryId","intl","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","concat","_toConsumableArray","tripId","forEach","index","mediumIndex","rider","riderIndex","_dependentAlternateFa","_legPrice$currency","_legPrice$currency2","_getLegCost","Array","from","alternateFareProducts","isDependent","appliedFareProduct","productUseId","legPrice","add","dependentAlternateFareProducts","originalAmount","price","amount","newCell","defaultMessage","title","Number","isNaN","formatMessage","description","transferAmount","formatNumber","currency","code","currencyDisplay","size","currentRowIndex","fare"],"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":";AAAA;AACA,OAAOA,KAAK,MAAM,OAAO;AAEzB,OAAOC,SAAS,MAAM,6BAA6B;AACnD,SAASC,gBAAgB,EAAEC,OAAO,QAAQ,YAAY;AACtD,OAAOC,MAAM,MAAM,mBAAmB;AACtC,SAASC,QAAQ,QAAQ,yCAAyC;AAElE,SAASC,UAAU,QAAQ,UAAU;AACrC,SAASC,oBAAoB,EAAEC,kBAAkB,QAAQ,WAAW;;AAEpE;AACA,IAAAC,oBAAA,GAKIR,SAAS,CAACS,SAAS;EAJrBC,UAAU,GAAAF,oBAAA,CAAVE,UAAU;EACVC,gBAAgB,GAAAH,oBAAA,CAAhBG,gBAAgB;EAChBC,OAAO,GAAAJ,oBAAA,CAAPI,OAAO;EACPC,eAAe,GAAAL,oBAAA,CAAfK,eAAe;AAGjB,IAAMC,QAAQ,gBACZf,KAAA,CAAAgB,aAAA,CAA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AJA,IAAI,CAAEf,MAAM,KACbnD,IAAI,CAACyD,aAAa,CAAC;cACjBjF,EAAE,EAAE;YACN,CAAC;UACF,gBAEDlB,KAAA,CAAAgB,aAAA,aACG4F,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEf,MAAM,GACTvF,UAAU,CAACsG,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEL,QAAQ,CAACC,IAAI,EAAEI,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEf,MAAM,CAAC,GAC7C9E,QACF,CACF,CACN,CAAC;QACH;MACF,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,oBACEf,KAAA,CAAAgB,aAAA,CAACO,YAAY,qBACXvB,KAAA,CAAAgB,aAAA,CAACT,oBAAoB,qBACnBP,KAAA,CAAAgB,aAAA,CAACd,gBAAgB;IAACgB,EAAE,EAAC;EAAoC,CAAE,CACvC,CAAC,EACtB+C,IAAI,CAACf,GAAG,CAAC,UAACU,CAAC,EAAEc,KAAK;IAAA,oBACjB1E,KAAA,CAAAgB,aAAA;MAAIkD,GAAG,EAAEQ;IAAM,GAAEd,CAAM,CAAC;EAAA,CACzB,CACW,CAAC;AAEnB,CAAC;AAED,eAAevB,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"fares-v2-table.js","names":["React","coreUtils","FormattedMessage","useIntl","styled","Transfer","renderFare","InvisibleA11yCaption","InvisibleA11yLabel","_coreUtils$itinerary","itinerary","getLegCost","getItineraryCost","descope","getLegRouteName","FailDash","createElement","Fragment","id","TransferIcon","withConfig","displayName","componentId","StripedTable","table","categoryReducer","acc","cur","some","m","push","categorySorter","favoriteId","a","b","aId","bId","FaresV2Table","_ref","legs","favoriteMediumId","favoriteRiderCategoryId","intl","transitLegs","filter","leg","transitLeg","fareProducts","flatMap","mediums","map","fp","_fp$product","product","medium","reduce","sort","riders","_fp$product2","riderCategory","riderMediumPairs","rider","rmp","_fp$product3","_rmp$rider","_fp$product4","_rmp$medium","length","name","productUseIds","Set","rows","key","style","textAlign","scope","concat","_toConsumableArray","tripId","forEach","index","currentRowIndex","_medium$id","_rider$id","_dependentAlternateFa","_legPrice$currency","_legPrice$currency2","_getLegCost","Array","from","alternateFareProducts","isDependent","appliedFareProduct","productUseId","legPrice","add","dependentAlternateFareProducts","originalAmount","price","amount","newCell","defaultMessage","title","Number","isNaN","formatMessage","description","transferAmount","formatNumber","currency","code","currencyDisplay","size","nextRowIndex","_medium$id2","_rider$id2","fare","r"],"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\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 .reduce(categoryReducer, [])\n .sort(categorySorter(favoriteMediumId));\n const riders = fareProducts\n .map(fp => fp.product?.riderCategory)\n .reduce(categoryReducer, [])\n .sort(categorySorter(favoriteRiderCategoryId));\n\n // Generate the pairs of riders and mediums, but filter out ones\n // that never occur in the FareProducts\n const riderMediumPairs = mediums\n .flatMap(medium =>\n riders.map(rider => ({\n medium,\n rider\n }))\n )\n .filter(rmp =>\n fareProducts.some(\n fp =>\n fp.product?.riderCategory?.id === rmp.rider?.id &&\n fp.product?.medium?.id === rmp.medium?.id\n )\n );\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 riderMediumPairs.forEach((rmp, currentRowIndex) => {\n const { medium, rider } = rmp;\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 - 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 {medium?.id && (\n <>\n <FormattedMessage\n id={`config.fares.media.${descope(medium.id)}`}\n defaultMessage={medium.name}\n />{\" \"}\n </>\n )}\n {rider?.id && (\n <FormattedMessage\n id={`config.fares.riderCategory.${descope(rider.id)}`}\n defaultMessage={rider.name}\n />\n )}\n {!medium?.id && !rider?.id ? FailDash : null}\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 nextRowIndex = currentRowIndex + 1;\n if (!rows[nextRowIndex]) {\n rows[nextRowIndex] = [];\n }\n rows[nextRowIndex].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[nextRowIndex].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 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":";AAAA;AACA,OAAOA,KAAK,MAAM,OAAO;AAEzB,OAAOC,SAAS,MAAM,6BAA6B;AACnD,SAASC,gBAAgB,EAAEC,OAAO,QAAQ,YAAY;AACtD,OAAOC,MAAM,MAAM,mBAAmB;AACtC,SAASC,QAAQ,QAAQ,yCAAyC;AAElE,SAASC,UAAU,QAAQ,UAAU;AACrC,SAASC,oBAAoB,EAAEC,kBAAkB,QAAQ,WAAW;AAEpE,IAAAC,oBAAA,GAKIR,SAAS,CAACS,SAAS;EAJrBC,UAAU,GAAAF,oBAAA,CAAVE,UAAU;EACVC,gBAAgB,GAAAH,oBAAA,CAAhBG,gBAAgB;EAChBC,OAAO,GAAAJ,oBAAA,CAAPI,OAAO;EACPC,eAAe,GAAAL,oBAAA,CAAfK,eAAe;AAGjB,IAAMC,QAAQ,gBACZf,KAAA,CAAAgB,aAAA,CAAAhB,KAAA,CAAAiB,QAAA,QAA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AK,EACH,EAACc,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEjB,MAAM,KACbzD,IAAI,CAAC+D,aAAa,CAAC;YACjBvF,EAAE,EAAE;UACN,CAAC;QACF,gBAEDlB,KAAA,CAAAgB,aAAA,aACGoG,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEjB,MAAM,GACT7F,UAAU,CAAC8G,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEP,QAAQ,CAACC,IAAI,EAAEM,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEjB,MAAM,CAAC,GAC7CpF,QACF,CACF,CACN,CAAC;MACH;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,oBACEf,KAAA,CAAAgB,aAAA,CAACO,YAAY,qBACXvB,KAAA,CAAAgB,aAAA,CAACT,oBAAoB,qBACnBP,KAAA,CAAAgB,aAAA,CAACd,gBAAgB;IAACgB,EAAE,EAAC;EAAoC,CAAE,CACvC,CAAC,EACtBqD,IAAI,CAACrB,GAAG,CAAC,UAACmE,CAAC,EAAErC,KAAK;IAAA,oBACjBhF,KAAA,CAAAgB,aAAA;MAAIwD,GAAG,EAAEQ;IAAM,GAAEqC,CAAM,CAAC;EAAA,CACzB,CACW,CAAC;AAEnB,CAAC;AAED,eAAehF,YAAY","ignoreList":[]}
|
package/i18n/es.yml
CHANGED
|
@@ -21,7 +21,9 @@ otpUi:
|
|
|
21
21
|
{# minuto} other {# minutos}}</strong> en bicicleta.
|
|
22
22
|
title: Detalles del viaje
|
|
23
23
|
tncFare: "{companies} Tarifa: <strong>{minTNCFare} - {maxTNCFare}</strong>"
|
|
24
|
-
transferDiscountExplanation: Se aplica un descuento de transferencia de
|
|
24
|
+
transferDiscountExplanation: Se aplica un descuento de transferencia de
|
|
25
|
+
{transferAmount}
|
|
25
26
|
transitFare: Tarifa de tránsito
|
|
26
27
|
transitFareEntry: "{name} : <strong>{value}</strong>"
|
|
27
28
|
tripIncludesFlex: Este viaje incluye rutas flexibles. {extraMessage}
|
|
29
|
+
total: Total
|
package/i18n/ko.yml
CHANGED
package/i18n/ru.yml
CHANGED
|
@@ -21,8 +21,10 @@ otpUi:
|
|
|
21
21
|
минуту} other {# минуты}}</strong> на ходьбу и<strong>{bikeMinutes,
|
|
22
22
|
plural, one {# минуту} other {# минуты}}</strong> на езду на велосипеде.
|
|
23
23
|
title: Подробные сведения о поездке
|
|
24
|
-
tncFare: "Стоимость проезда в компаниях {companies}: <strong>{minTNCFare}
|
|
25
|
-
transferDiscountExplanation: Применяется скидка на пересадку в размере
|
|
24
|
+
tncFare: "Стоимость проезда в компаниях {companies}: <strong>{minTNCFare} — {maxTNCFare}</strong>"
|
|
25
|
+
transferDiscountExplanation: Применяется скидка на пересадку в размере
|
|
26
|
+
{transferAmount}
|
|
26
27
|
transitFare: Стоимость проезда в общественном транспорте
|
|
27
28
|
transitFareEntry: "{name}: <strong>{value}</strong>"
|
|
28
29
|
tripIncludesFlex: Эта поездка включает гибкие маршруты. {extraMessage}
|
|
30
|
+
total: Всего
|
package/i18n/tl.yml
CHANGED
|
@@ -22,7 +22,9 @@ otpUi:
|
|
|
22
22
|
minuto</strong> sa pagbibisikleta.
|
|
23
23
|
title: Mga Detalye ng Biyahe
|
|
24
24
|
tncFare: "{companies} Pamasahe: <strong>{minTNCFare} - {maxTNCFare}</strong>"
|
|
25
|
-
transferDiscountExplanation: Inilapat ang diskwento sa paglipat na
|
|
25
|
+
transferDiscountExplanation: Inilapat ang diskwento sa paglipat na
|
|
26
|
+
{transferAmount}
|
|
26
27
|
transitFare: Pamasahe sa Pampublikong Transportasyon
|
|
27
28
|
transitFareEntry: "{name}: <strong>{value}</strong>"
|
|
28
29
|
tripIncludesFlex: May mga flexible na ruta ang biyaheng ito. {extraMessage}
|
|
30
|
+
total: Kabuuan
|
package/i18n/vi.yml
CHANGED
|
@@ -21,7 +21,10 @@ otpUi:
|
|
|
21
21
|
đạp.
|
|
22
22
|
title: Chi tiết chuyến đi
|
|
23
23
|
tncFare: "{companies} Giá vé: <strong>{minTNCFare} - {maxTNCFare}</strong>"
|
|
24
|
-
transferDiscountExplanation: Giảm giá chuyển khoản {transferAmount} được áp
|
|
24
|
+
transferDiscountExplanation: Giảm giá chuyển khoản {transferAmount} được áp
|
|
25
|
+
dụng
|
|
25
26
|
transitFare: Giá vé xe công cộng
|
|
26
27
|
transitFareEntry: "{name}: <strong>{value}</strong>"
|
|
27
|
-
tripIncludesFlex: Chuyến đi này bao gồm các tuyến đường linh hoạt.
|
|
28
|
+
tripIncludesFlex: Chuyến đi này bao gồm các tuyến đường linh hoạt.
|
|
29
|
+
{extraMessage}
|
|
30
|
+
total: Tổng
|
package/i18n/zh_Hans.yml
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
otpUi:
|
|
2
2
|
TripDetails:
|
|
3
3
|
co2: "排放的二氧化碳: <strong>{co2}</strong>"
|
|
4
|
-
co2description: CO₂ 强度的计算方法是将行程的每条腿的距离乘以每种模式的 CO₂ 强度。
|
|
4
|
+
co2description: CO₂ 强度的计算方法是将行程的每条腿的距离乘以每种模式的 CO₂ 强度。
|
|
5
|
+
每种模式的二氧化碳强度来自<link>此电子表格</link>。
|
|
5
6
|
departure: >-
|
|
6
7
|
<strong>{departureDate, date, long}</strong> <strong>{departureDate, time,
|
|
7
8
|
short}</strong> 出发
|
|
@@ -21,3 +22,4 @@ otpUi:
|
|
|
21
22
|
transitFare: 公共交通费
|
|
22
23
|
transitFareEntry: "{name}: <strong>{value}</strong>"
|
|
23
24
|
tripIncludesFlex: 这个行程包括灵活的路线. {extraMessage}
|
|
25
|
+
total: 总计
|
package/i18n/zh_Hant.yml
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
otpUi:
|
|
2
2
|
TripDetails:
|
|
3
3
|
co2: 排放的二氧化碳:<strong>{co2}</strong>
|
|
4
|
-
co2description:
|
|
4
|
+
co2description:
|
|
5
|
+
二氧化碳密度是以一個行程每條腿的距離乘以各個模式的二氧化碳密度來計算。各個模式的二氧化碳密度是從<link>此試算表</link>中取得。
|
|
5
6
|
departure: >-
|
|
6
7
|
<strong>{departureDate, date, long}</strong>的<strong>{departureDate, time,
|
|
7
8
|
short}</strong>出發
|
|
@@ -17,3 +18,4 @@ otpUi:
|
|
|
17
18
|
transitFare: 公共交通票價
|
|
18
19
|
transitFareEntry: "{name}:<strong>{value}</strong>"
|
|
19
20
|
tripIncludesFlex: 此行程包括彈性的路線。{extraMessage}
|
|
21
|
+
total: 總計
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fares-v2-table.d.ts","sourceRoot":"","sources":["../../src/components/fares-v2-table.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"fares-v2-table.d.ts","sourceRoot":"","sources":["../../src/components/fares-v2-table.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAyE7C,QAAA,MAAM,YAAY,GAAI,qDAInB;IACD,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC,KAAG,GAAG,CAAC,OAoMP,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -14,7 +14,6 @@ var _utils = require("../utils");
|
|
|
14
14
|
var _styled = require("../styled");
|
|
15
15
|
/* eslint-disable no-underscore-dangle */
|
|
16
16
|
|
|
17
|
-
// TODO: inline this import? (@opentripplanner/core-utils/src/itinerary)
|
|
18
17
|
const {
|
|
19
18
|
getLegCost,
|
|
20
19
|
getItineraryCost,
|
|
@@ -69,11 +68,21 @@ const FaresV2Table = ({
|
|
|
69
68
|
const mediums = fareProducts.map(fp => {
|
|
70
69
|
var _fp$product;
|
|
71
70
|
return (_fp$product = fp.product) === null || _fp$product === void 0 ? void 0 : _fp$product.medium;
|
|
72
|
-
}).
|
|
71
|
+
}).reduce(categoryReducer, []).sort(categorySorter(favoriteMediumId));
|
|
73
72
|
const riders = fareProducts.map(fp => {
|
|
74
73
|
var _fp$product2;
|
|
75
74
|
return (_fp$product2 = fp.product) === null || _fp$product2 === void 0 ? void 0 : _fp$product2.riderCategory;
|
|
76
|
-
}).
|
|
75
|
+
}).reduce(categoryReducer, []).sort(categorySorter(favoriteRiderCategoryId));
|
|
76
|
+
|
|
77
|
+
// Generate the pairs of riders and mediums, but filter out ones
|
|
78
|
+
// that never occur in the FareProducts
|
|
79
|
+
const riderMediumPairs = mediums.flatMap(medium => riders.map(rider => ({
|
|
80
|
+
medium,
|
|
81
|
+
rider
|
|
82
|
+
}))).filter(rmp => fareProducts.some(fp => {
|
|
83
|
+
var _fp$product3, _rmp$rider, _fp$product4, _rmp$medium;
|
|
84
|
+
return ((_fp$product3 = fp.product) === null || _fp$product3 === void 0 || (_fp$product3 = _fp$product3.riderCategory) === null || _fp$product3 === void 0 ? void 0 : _fp$product3.id) === ((_rmp$rider = rmp.rider) === null || _rmp$rider === void 0 ? void 0 : _rmp$rider.id) && ((_fp$product4 = fp.product) === null || _fp$product4 === void 0 || (_fp$product4 = _fp$product4.medium) === null || _fp$product4 === void 0 ? void 0 : _fp$product4.id) === ((_rmp$medium = rmp.medium) === null || _rmp$medium === void 0 ? void 0 : _rmp$medium.id);
|
|
85
|
+
}));
|
|
77
86
|
|
|
78
87
|
// Ensure we have at least one rider/medium
|
|
79
88
|
if (riders.length === 0) {
|
|
@@ -114,71 +123,73 @@ const FaresV2Table = ({
|
|
|
114
123
|
|
|
115
124
|
// non-transit legs don't have fares
|
|
116
125
|
transitLegs.forEach((leg, index) => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
riderMediumPairs.forEach((rmp, currentRowIndex) => {
|
|
127
|
+
var _medium$id, _rider$id, _dependentAlternateFa, _legPrice$currency, _legPrice$currency2;
|
|
128
|
+
const {
|
|
129
|
+
medium,
|
|
130
|
+
rider
|
|
131
|
+
} = rmp;
|
|
132
|
+
const {
|
|
133
|
+
alternateFareProducts,
|
|
134
|
+
isDependent,
|
|
135
|
+
appliedFareProduct,
|
|
136
|
+
productUseId
|
|
137
|
+
} = getLegCost(leg, descope((_medium$id = medium === null || medium === void 0 ? void 0 : medium.id) !== null && _medium$id !== void 0 ? _medium$id : null), descope((_rider$id = rider === null || rider === void 0 ? void 0 : rider.id) !== null && _rider$id !== void 0 ? _rider$id : null), Array.from(productUseIds));
|
|
138
|
+
const legPrice = appliedFareProduct === null || appliedFareProduct === void 0 ? void 0 : appliedFareProduct.legPrice;
|
|
139
|
+
productUseIds.add(productUseId);
|
|
129
140
|
|
|
130
|
-
|
|
131
|
-
|
|
141
|
+
// Only consider alternateFareProducts if current product is dependent
|
|
142
|
+
const dependentAlternateFareProducts = isDependent && alternateFareProducts;
|
|
132
143
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
// Calculate pre-tranfer amount either via alternate fare or fare-id matching (price.originalAmount)
|
|
145
|
+
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);
|
|
146
|
+
const newCell = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, index === 0 && /*#__PURE__*/_react.default.createElement("th", {
|
|
147
|
+
style: {
|
|
148
|
+
textAlign: "left"
|
|
149
|
+
},
|
|
150
|
+
scope: "row"
|
|
151
|
+
}, (medium === null || medium === void 0 ? void 0 : medium.id) && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
|
|
152
|
+
id: `config.fares.media.${descope(medium.id)}`,
|
|
153
|
+
defaultMessage: medium.name
|
|
154
|
+
}), " "), (rider === null || rider === void 0 ? void 0 : rider.id) && /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
|
|
155
|
+
id: `config.fares.riderCategory.${descope(rider.id)}`,
|
|
156
|
+
defaultMessage: rider.name
|
|
157
|
+
}), !(medium !== null && medium !== void 0 && medium.id) && !(rider !== null && rider !== void 0 && rider.id) ? FailDash : null), /*#__PURE__*/_react.default.createElement("td", {
|
|
158
|
+
style: {
|
|
159
|
+
textAlign: legPrice ? "right" : "center"
|
|
160
|
+
},
|
|
161
|
+
title: !Number.isNaN(originalAmount) && originalAmount > 0 && index > 0 && intl.formatMessage({
|
|
162
|
+
description: "Text explaining the transfer discount applied to this fare.",
|
|
163
|
+
id: "otpUi.TripDetails.transferDiscountExplanation"
|
|
164
|
+
}, {
|
|
165
|
+
transferAmount: intl.formatNumber(originalAmount, {
|
|
166
|
+
currency: legPrice === null || legPrice === void 0 || (_legPrice$currency = legPrice.currency) === null || _legPrice$currency === void 0 ? void 0 : _legPrice$currency.code,
|
|
167
|
+
currencyDisplay: "narrowSymbol",
|
|
168
|
+
style: "currency"
|
|
169
|
+
})
|
|
170
|
+
})
|
|
171
|
+
}, !Number.isNaN(originalAmount) && originalAmount > 0 && index > 0 && /*#__PURE__*/_react.default.createElement(TransferIcon, {
|
|
172
|
+
size: 16
|
|
173
|
+
}), 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));
|
|
174
|
+
const nextRowIndex = currentRowIndex + 1;
|
|
175
|
+
if (!rows[nextRowIndex]) {
|
|
176
|
+
rows[nextRowIndex] = [];
|
|
177
|
+
}
|
|
178
|
+
rows[nextRowIndex].push(newCell);
|
|
179
|
+
|
|
180
|
+
// Generate final column
|
|
181
|
+
if (index === transitLegs.length - 1 && transitLegs.length > 1) {
|
|
182
|
+
var _medium$id2, _rider$id2;
|
|
183
|
+
const fare = getItineraryCost(legs, descope((_medium$id2 = medium === null || medium === void 0 ? void 0 : medium.id) !== null && _medium$id2 !== void 0 ? _medium$id2 : null), descope((_rider$id2 = rider === null || rider === void 0 ? void 0 : rider.id) !== null && _rider$id2 !== void 0 ? _rider$id2 : null));
|
|
184
|
+
rows[nextRowIndex].push(/*#__PURE__*/_react.default.createElement("td", {
|
|
147
185
|
style: {
|
|
148
|
-
textAlign:
|
|
186
|
+
textAlign: fare !== null && fare !== void 0 && fare.amount ? "right" : "center"
|
|
149
187
|
},
|
|
150
|
-
title: !
|
|
151
|
-
|
|
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
|
-
})
|
|
188
|
+
title: !(fare !== null && fare !== void 0 && fare.amount) && intl.formatMessage({
|
|
189
|
+
id: "otpUi.TripDetails.missingFareTotal"
|
|
159
190
|
})
|
|
160
|
-
},
|
|
161
|
-
|
|
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
|
-
});
|
|
191
|
+
}, /*#__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)));
|
|
192
|
+
}
|
|
182
193
|
});
|
|
183
194
|
});
|
|
184
195
|
return /*#__PURE__*/_react.default.createElement(StripedTable, null, /*#__PURE__*/_react.default.createElement(_styled.InvisibleA11yCaption, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
|