@opentripplanner/trip-details 8.0.2 → 9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/components/fares-v2-table.js +194 -0
- package/esm/components/fares-v2-table.js.map +1 -0
- package/esm/components/fares.js +34 -60
- package/esm/components/fares.js.map +1 -1
- package/esm/index.js +5 -5
- package/esm/index.js.map +1 -1
- package/esm/styled.js +29 -22
- package/esm/styled.js.map +1 -1
- package/esm/trip-detail.js +1 -8
- package/esm/trip-detail.js.map +1 -1
- package/esm/types.js.map +1 -1
- package/i18n/en-US.yml +2 -7
- package/i18n/es.yml +0 -7
- package/i18n/fr.yml +2 -7
- package/i18n/ko.yml +2 -9
- package/i18n/nb_NO.yml +1 -4
- package/i18n/pl.yml +24 -19
- package/i18n/ru.yml +3 -10
- package/i18n/ta.yml +20 -25
- package/i18n/tl.yml +2 -9
- package/i18n/tr.yml +0 -7
- package/i18n/vi.yml +2 -9
- package/i18n/zh_Hans.yml +2 -9
- package/i18n/zh_Hant.yml +0 -7
- package/lib/components/departure-date.js +45 -42
- package/lib/components/departure-date.js.map +1 -1
- package/lib/components/emissions.js +57 -64
- package/lib/components/emissions.js.map +1 -1
- package/lib/components/fares-v2-table.d.ts +9 -0
- package/lib/components/fares-v2-table.d.ts.map +1 -0
- package/lib/components/fares-v2-table.js +158 -0
- package/lib/components/fares-v2-table.js.map +1 -0
- package/lib/components/fares.d.ts +4 -4
- package/lib/components/fares.d.ts.map +1 -1
- package/lib/components/fares.js +87 -151
- package/lib/components/fares.js.map +1 -1
- package/lib/components/flex-booking-info.js +55 -38
- package/lib/components/flex-booking-info.js.map +1 -1
- package/lib/components/time-active.js +40 -66
- package/lib/components/time-active.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +53 -66
- package/lib/index.js.map +1 -1
- package/lib/styled.d.ts +1 -0
- package/lib/styled.d.ts.map +1 -1
- package/lib/styled.js +120 -86
- package/lib/styled.js.map +1 -1
- package/lib/trip-detail.d.ts.map +1 -1
- package/lib/trip-detail.js +65 -71
- package/lib/trip-detail.js.map +1 -1
- package/lib/types.d.ts +4 -41
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +1 -4
- package/lib/types.js.map +1 -1
- package/lib/utils.js +17 -23
- package/lib/utils.js.map +1 -1
- package/package.json +3 -5
- package/src/TripDetails.story.tsx +47 -158
- package/src/__snapshots__/TripDetails.story.tsx.snap +1726 -924
- package/src/components/fares-v2-table.tsx +262 -0
- package/src/components/fares.tsx +51 -89
- package/src/index.tsx +4 -4
- package/src/styled.ts +11 -2
- package/src/trip-detail.tsx +1 -10
- package/src/types.ts +4 -40
- package/tsconfig.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/__mocks__/custom-english-messages.yml +0 -14
- package/__mocks__/custom-french-messages.yml +0 -9
- package/esm/components/fare-table.js +0 -122
- package/esm/components/fare-table.js.map +0 -1
- package/i18n/i18n-exceptions.json +0 -12
- package/lib/components/fare-table.d.ts +0 -5
- package/lib/components/fare-table.d.ts.map +0 -1
- package/lib/components/fare-table.js +0 -118
- package/lib/components/fare-table.js.map +0 -1
- package/src/components/fare-table.tsx +0 -215
|
@@ -1,75 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.
|
|
5
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
6
17
|
});
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const react_1 = __importDefault(require("react"));
|
|
30
|
+
const react_intl_1 = require("react-intl");
|
|
31
|
+
const Leaf_1 = require("@styled-icons/fa-solid/Leaf");
|
|
32
|
+
const core_utils_1 = __importDefault(require("@opentripplanner/core-utils"));
|
|
33
|
+
const flat_1 = __importDefault(require("flat"));
|
|
34
|
+
const utils_1 = require("../utils");
|
|
35
|
+
const trip_detail_1 = __importDefault(require("../trip-detail"));
|
|
36
|
+
const S = __importStar(require("../styled"));
|
|
19
37
|
// Load the default messages.
|
|
20
|
-
|
|
38
|
+
const en_US_yml_1 = __importDefault(require("../../i18n/en-US.yml"));
|
|
21
39
|
// HACK: We should flatten the messages loaded above because
|
|
22
40
|
// the YAML loaders behave differently between webpack and our version of jest:
|
|
23
41
|
// - the yaml loader for webpack returns a nested object,
|
|
24
42
|
// - the yaml loader for jest returns messages with flattened ids.
|
|
25
|
-
const defaultMessages = (0,
|
|
43
|
+
const defaultMessages = (0, flat_1.default)(en_US_yml_1.default);
|
|
26
44
|
function CO2DescriptionLink(contents) {
|
|
27
|
-
|
|
28
|
-
href: "https://www.itf-oecd.org/sites/default/files/life-cycle-assessment-calculations-2020.xlsx",
|
|
29
|
-
rel: "noopener noreferrer",
|
|
30
|
-
target: "_blank"
|
|
31
|
-
}, contents);
|
|
45
|
+
return (react_1.default.createElement("a", { href: "https://www.itf-oecd.org/sites/default/files/life-cycle-assessment-calculations-2020.xlsx", rel: "noopener noreferrer", target: "_blank" }, contents));
|
|
32
46
|
}
|
|
33
|
-
function Emissions({
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
values: {
|
|
53
|
-
co2: /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedNumber, {
|
|
54
|
-
value: Math.round(co2)
|
|
55
|
-
// eslint-disable-next-line react/style-prop-object
|
|
56
|
-
,
|
|
57
|
-
style: "unit",
|
|
58
|
-
unit: (co2Config === null || co2Config === void 0 ? void 0 : co2Config.units) || "gram",
|
|
59
|
-
unitDisplay: "narrow"
|
|
60
|
-
}),
|
|
61
|
-
strong: _utils.boldText
|
|
62
|
-
}
|
|
63
|
-
})),
|
|
64
|
-
description: /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
|
|
65
|
-
defaultMessage: defaultMessages["otpUi.TripDetails.co2description"],
|
|
66
|
-
description: "Text explaining how the CO\u2082 emissions are calculated.",
|
|
67
|
-
id: "otpUi.TripDetails.co2description",
|
|
68
|
-
values: {
|
|
69
|
-
link: CO2DescriptionLink,
|
|
70
|
-
totalDistance
|
|
71
|
-
}
|
|
72
|
-
})
|
|
73
|
-
});
|
|
47
|
+
function Emissions({ itinerary, co2Config }) {
|
|
48
|
+
// Calculate CO₂ if it's not provided by the itinerary
|
|
49
|
+
const co2 = itinerary.co2 ||
|
|
50
|
+
((co2Config === null || co2Config === void 0 ? void 0 : co2Config.enabled) &&
|
|
51
|
+
core_utils_1.default.itinerary.calculateEmissions(itinerary, co2Config === null || co2Config === void 0 ? void 0 : co2Config.carbonIntensity, co2Config === null || co2Config === void 0 ? void 0 : co2Config.units));
|
|
52
|
+
if (!co2 || co2 < 0 || !(co2Config === null || co2Config === void 0 ? void 0 : co2Config.enabled)) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
const totalDistance = itinerary.legs.reduce((total, leg) => total + leg.distance, 0);
|
|
56
|
+
return (react_1.default.createElement(trip_detail_1.default, { className: "emissions", icon: react_1.default.createElement(Leaf_1.Leaf, { size: 17 }), summary: react_1.default.createElement(S.CO2Summary, null,
|
|
57
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { defaultMessage: defaultMessages["otpUi.TripDetails.co2"], description: "Text showing the quantity of CO\u2082 emitted by this trip.", id: "otpUi.TripDetails.co2", values: {
|
|
58
|
+
co2: (react_1.default.createElement(react_intl_1.FormattedNumber, { value: Math.round(co2),
|
|
59
|
+
// eslint-disable-next-line react/style-prop-object
|
|
60
|
+
style: "unit", unit: (co2Config === null || co2Config === void 0 ? void 0 : co2Config.units) || "gram", unitDisplay: "narrow" })),
|
|
61
|
+
strong: utils_1.boldText
|
|
62
|
+
} })), description: react_1.default.createElement(react_intl_1.FormattedMessage, { defaultMessage: defaultMessages["otpUi.TripDetails.co2description"], description: "Text explaining how the CO\u2082 emissions are calculated.", id: "otpUi.TripDetails.co2description", values: {
|
|
63
|
+
link: CO2DescriptionLink,
|
|
64
|
+
totalDistance
|
|
65
|
+
} }) }));
|
|
74
66
|
}
|
|
67
|
+
exports.default = Emissions;
|
|
75
68
|
//# sourceMappingURL=emissions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emissions.js","
|
|
1
|
+
{"version":3,"file":"emissions.js","sourceRoot":"","sources":["../../src/components/emissions.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAuD;AACvD,2CAA+D;AAE/D,sDAAmD;AACnD,6EAAoD;AACpD,gDAA2B;AAC3B,oCAAoC;AACpC,iEAAwC;AAExC,6CAA+B;AAE/B,6BAA6B;AAC7B,qEAA0D;AAE1D,4DAA4D;AAC5D,+EAA+E;AAC/E,yDAAyD;AACzD,kEAAkE;AAClE,MAAM,eAAe,GAA2B,IAAA,cAAO,EAAC,mBAAsB,CAAC,CAAC;AAEhF,SAAS,kBAAkB,CAAC,QAAmB;IAC7C,OAAO,CACL,qCACE,IAAI,EAAC,2FAA2F,EAChG,GAAG,EAAC,qBAAqB,EACzB,MAAM,EAAC,QAAQ,IAEd,QAAQ,CACP,CACL,CAAC;AACJ,CAAC;AAED,SAAwB,SAAS,CAAC,EAChC,SAAS,EACT,SAAS,EAIV;IACC,sDAAsD;IACtD,MAAM,GAAG,GACP,SAAS,CAAC,GAAG;QACb,CAAC,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO;YACjB,oBAAS,CAAC,SAAS,CAAC,kBAAkB,CACpC,SAAS,EACT,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,eAAe,EAC1B,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,KAAK,CACjB,CAAC,CAAC;IAEP,IAAI,CAAC,GAAG,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,CAAA,EAAE;QAC1C,OAAO,IAAI,CAAC;KACb;IAED,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAC,MAAM,CACzC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,KAAK,GAAG,GAAG,CAAC,QAAQ,EACpC,CAAC,CACF,CAAC;IAEF,OAAO,CACL,8BAAC,qBAAU,IACT,SAAS,EAAC,WAAW,EACrB,IAAI,EAAE,8BAAC,WAAI,IAAC,IAAI,EAAE,EAAE,GAAI,EACxB,OAAO,EACL,8BAAC,CAAC,CAAC,UAAU;YACX,8BAAC,6BAAgB,IACf,cAAc,EAAE,eAAe,CAAC,uBAAuB,CAAC,EACxD,WAAW,EAAC,6DAAwD,EACpE,EAAE,EAAC,uBAAuB,EAC1B,MAAM,EAAE;oBACN,GAAG,EAAE,CACH,8BAAC,4BAAe,IACd,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;wBACtB,mDAAmD;wBACnD,KAAK,EAAC,MAAM,EACZ,IAAI,EAAE,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,KAAK,KAAI,MAAM,EAChC,WAAW,EAAC,QAAQ,GACpB,CACH;oBACD,MAAM,EAAE,gBAAQ;iBACjB,GACD,CACW,EAEjB,WAAW,EACT,8BAAC,6BAAgB,IACf,cAAc,EAAE,eAAe,CAAC,kCAAkC,CAAC,EACnE,WAAW,EAAC,4DAAuD,EACnE,EAAE,EAAC,kCAAkC,EACrC,MAAM,EAAE;gBACN,IAAI,EAAE,kBAAkB;gBACxB,aAAa;aACd,GACD,GAEJ,CACH,CAAC;AACJ,CAAC;AAhED,4BAgEC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Leg } from "@opentripplanner/types";
|
|
3
|
+
declare const FaresV2Table: ({ legs, favoriteMediumId, favoriteRiderCategoryId }: {
|
|
4
|
+
legs: Leg[];
|
|
5
|
+
favoriteMediumId?: string;
|
|
6
|
+
favoriteRiderCategoryId?: string;
|
|
7
|
+
}) => JSX.Element;
|
|
8
|
+
export default FaresV2Table;
|
|
9
|
+
//# sourceMappingURL=fares-v2-table.d.ts.map
|
|
@@ -0,0 +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;AA0E7C,QAAA,MAAM,YAAY;UAKV,GAAG,EAAE;uBACQ,MAAM;8BACC,MAAM;MAC9B,WA+KH,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
/* eslint-disable no-underscore-dangle */
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const core_utils_1 = __importDefault(require("@opentripplanner/core-utils"));
|
|
9
|
+
const react_intl_1 = require("react-intl");
|
|
10
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
11
|
+
const Transfer_1 = require("@styled-icons/boxicons-regular/Transfer");
|
|
12
|
+
const utils_1 = require("../utils");
|
|
13
|
+
const styled_1 = require("../styled");
|
|
14
|
+
// TODO: inline this import? (@opentripplanner/core-utils/src/itinerary)
|
|
15
|
+
const { getLegCost, getItineraryCost, descope, getLegRouteName } = core_utils_1.default.itinerary;
|
|
16
|
+
const FailDash = (react_1.default.createElement(react_1.default.Fragment, null,
|
|
17
|
+
"-",
|
|
18
|
+
react_1.default.createElement(styled_1.InvisibleA11yLabel, null,
|
|
19
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "otpUi.TripDetails.legMissingFareInfo" }))));
|
|
20
|
+
const TransferIcon = (0, styled_components_1.default)(Transfer_1.Transfer) `
|
|
21
|
+
padding-right: 0.25ch;
|
|
22
|
+
`;
|
|
23
|
+
const StripedTable = styled_components_1.default.table `
|
|
24
|
+
text-align: right;
|
|
25
|
+
|
|
26
|
+
tr td,
|
|
27
|
+
tr th {
|
|
28
|
+
padding: 4px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
tr td:nth-of-type(2n + 1),
|
|
32
|
+
tr th:nth-of-type(2n) {
|
|
33
|
+
background: #cccccc55;
|
|
34
|
+
border-color: #cccccc55;
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
// Removes duplicates
|
|
38
|
+
const categoryReducer = (acc, cur) => {
|
|
39
|
+
if (!acc.some(m => descope(m === null || m === void 0 ? void 0 : m.id) === descope(cur === null || cur === void 0 ? void 0 : cur.id))) {
|
|
40
|
+
acc.push(cur);
|
|
41
|
+
}
|
|
42
|
+
return acc;
|
|
43
|
+
};
|
|
44
|
+
// Put the preferred medium first, and then all the others alphabetical
|
|
45
|
+
const categorySorter = (favoriteId) => (a, b) => {
|
|
46
|
+
const aId = descope(a === null || a === void 0 ? void 0 : a.id);
|
|
47
|
+
const bId = descope(b === null || b === void 0 ? void 0 : b.id);
|
|
48
|
+
if (favoriteId && aId === favoriteId) {
|
|
49
|
+
return -1;
|
|
50
|
+
}
|
|
51
|
+
if (favoriteId && bId === favoriteId) {
|
|
52
|
+
return 1;
|
|
53
|
+
}
|
|
54
|
+
return aId > bId ? 1 : -1;
|
|
55
|
+
};
|
|
56
|
+
// TODO: This component currently can only show one type of fare per medium
|
|
57
|
+
const FaresV2Table = ({ legs, favoriteMediumId, favoriteRiderCategoryId }) => {
|
|
58
|
+
const intl = (0, react_intl_1.useIntl)();
|
|
59
|
+
const transitLegs = legs.filter(leg => leg.transitLeg);
|
|
60
|
+
// Get all fare products across all legs
|
|
61
|
+
const fareProducts = transitLegs.flatMap(leg => leg.fareProducts);
|
|
62
|
+
// Reduce these into mediums and riders
|
|
63
|
+
const mediums = fareProducts
|
|
64
|
+
.map(fp => { var _a; return (_a = fp.product) === null || _a === void 0 ? void 0 : _a.medium; })
|
|
65
|
+
.filter(m => m !== null)
|
|
66
|
+
.reduce(categoryReducer, [])
|
|
67
|
+
.sort(categorySorter(favoriteMediumId));
|
|
68
|
+
const riders = fareProducts
|
|
69
|
+
.map(fp => { var _a; return (_a = fp.product) === null || _a === void 0 ? void 0 : _a.riderCategory; })
|
|
70
|
+
.filter(r => r !== null)
|
|
71
|
+
.reduce(categoryReducer, [])
|
|
72
|
+
.sort(categorySorter(favoriteRiderCategoryId));
|
|
73
|
+
// Ensure we have at least one rider/medium
|
|
74
|
+
if (riders.length === 0) {
|
|
75
|
+
riders.push({ name: "Fare", id: null });
|
|
76
|
+
}
|
|
77
|
+
if (mediums.length === 0) {
|
|
78
|
+
mediums.push({ name: "Regular", id: null });
|
|
79
|
+
}
|
|
80
|
+
// Keep track of seen fare ids to indicate transfers
|
|
81
|
+
const productUseIds = new Set();
|
|
82
|
+
const rows = [
|
|
83
|
+
[
|
|
84
|
+
react_1.default.createElement("th", { key: "faretitle", style: { textAlign: "left" } },
|
|
85
|
+
react_1.default.createElement(styled_1.InvisibleA11yLabel, null,
|
|
86
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "otpUi.TripDetails.transitFare" }))),
|
|
87
|
+
...transitLegs.map(leg => (react_1.default.createElement("th", { key: leg.tripId }, getLegRouteName(leg)))),
|
|
88
|
+
transitLegs.length > 1 ? (react_1.default.createElement("th", { key: "total", style: { textAlign: "right" } },
|
|
89
|
+
react_1.default.createElement("em", null,
|
|
90
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "otpUi.TripDetails.total" })))) : (react_1.default.createElement(react_1.default.Fragment, null))
|
|
91
|
+
]
|
|
92
|
+
];
|
|
93
|
+
// non-transit legs don't have fares
|
|
94
|
+
transitLegs.forEach((leg, index) => {
|
|
95
|
+
mediums.forEach((medium, mediumIndex) => {
|
|
96
|
+
riders.forEach((rider, riderIndex) => {
|
|
97
|
+
var _a, _b, _c;
|
|
98
|
+
if (!medium || !rider)
|
|
99
|
+
return;
|
|
100
|
+
const { alternateFareProducts, isDependent, appliedFareProduct, productUseId } = getLegCost(leg, descope(medium.id) || null, descope(rider.id) || null, Array.from(productUseIds));
|
|
101
|
+
const legPrice = appliedFareProduct === null || appliedFareProduct === void 0 ? void 0 : appliedFareProduct.legPrice;
|
|
102
|
+
productUseIds.add(productUseId);
|
|
103
|
+
// Only consider alternateFareProducts if current product is dependent
|
|
104
|
+
const dependentAlternateFareProducts = isDependent && alternateFareProducts;
|
|
105
|
+
// Calculate pre-tranfer amount either via alternate fare or fare-id matching (price.originalAmount)
|
|
106
|
+
const originalAmount = ((_a = dependentAlternateFareProducts === null || dependentAlternateFareProducts === void 0 ? void 0 : dependentAlternateFareProducts[0]) === null || _a === void 0 ? void 0 : _a.price.amount) -
|
|
107
|
+
(legPrice === null || legPrice === void 0 ? void 0 : legPrice.amount) ||
|
|
108
|
+
(appliedFareProduct === null || appliedFareProduct === void 0 ? void 0 : appliedFareProduct.price.amount) - (legPrice === null || legPrice === void 0 ? void 0 : legPrice.amount);
|
|
109
|
+
const newCell = (react_1.default.createElement(react_1.default.Fragment, null,
|
|
110
|
+
index === 0 && (react_1.default.createElement("th", { style: { textAlign: "left" } },
|
|
111
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: `config.fares.media.${descope(medium.id)}`, defaultMessage: medium.name }),
|
|
112
|
+
" ",
|
|
113
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: `config.fares.riderCategory.${descope(rider.id)}`, defaultMessage: rider.name }))),
|
|
114
|
+
react_1.default.createElement("td", { style: { textAlign: legPrice ? "right" : "center" }, title: !Number.isNaN(originalAmount) &&
|
|
115
|
+
originalAmount > 0 &&
|
|
116
|
+
index > 0 &&
|
|
117
|
+
intl.formatMessage({
|
|
118
|
+
description: "Text explaining the transfer discount applied to this fare.",
|
|
119
|
+
id: "otpUi.TripDetails.transferDiscountExplanation"
|
|
120
|
+
}, {
|
|
121
|
+
transferAmount: intl.formatNumber(originalAmount, {
|
|
122
|
+
currency: (_b = legPrice === null || legPrice === void 0 ? void 0 : legPrice.currency) === null || _b === void 0 ? void 0 : _b.code,
|
|
123
|
+
currencyDisplay: "narrowSymbol",
|
|
124
|
+
style: "currency"
|
|
125
|
+
})
|
|
126
|
+
}) },
|
|
127
|
+
!Number.isNaN(originalAmount) &&
|
|
128
|
+
originalAmount > 0 &&
|
|
129
|
+
index > 0 && react_1.default.createElement(TransferIcon, { size: 16 }),
|
|
130
|
+
legPrice
|
|
131
|
+
? (0, utils_1.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)
|
|
132
|
+
: FailDash)));
|
|
133
|
+
const currentRowIndex = 1 + riderIndex + riders.length * mediumIndex;
|
|
134
|
+
if (!rows[currentRowIndex]) {
|
|
135
|
+
rows[currentRowIndex] = [];
|
|
136
|
+
}
|
|
137
|
+
rows[currentRowIndex].push(newCell);
|
|
138
|
+
// Generate final column
|
|
139
|
+
if (index === transitLegs.length - 1 && transitLegs.length > 1) {
|
|
140
|
+
const fare = getItineraryCost(legs, descope(medium.id) || null, descope(rider.id) || null);
|
|
141
|
+
rows[currentRowIndex].push(react_1.default.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) &&
|
|
142
|
+
intl.formatMessage({
|
|
143
|
+
id: "otpUi.TripDetails.missingFareTotal"
|
|
144
|
+
}) },
|
|
145
|
+
react_1.default.createElement("em", null, (fare === null || fare === void 0 ? void 0 : fare.amount)
|
|
146
|
+
? (0, utils_1.renderFare)(fare === null || fare === void 0 ? void 0 : fare.currency.code, fare === null || fare === void 0 ? void 0 : fare.amount)
|
|
147
|
+
: FailDash)));
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
return (react_1.default.createElement(StripedTable, null,
|
|
153
|
+
react_1.default.createElement(styled_1.InvisibleA11yCaption, null,
|
|
154
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "otpUi.TripDetails.transitFareTable" })),
|
|
155
|
+
rows.map((r, index) => (react_1.default.createElement("tr", { key: index }, r)))));
|
|
156
|
+
};
|
|
157
|
+
exports.default = FaresV2Table;
|
|
158
|
+
//# sourceMappingURL=fares-v2-table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fares-v2-table.js","sourceRoot":"","sources":["../../src/components/fares-v2-table.tsx"],"names":[],"mappings":";;;;;AAAA,yCAAyC;AACzC,kDAA0B;AAE1B,6EAAoD;AACpD,2CAAuD;AACvD,0EAAuC;AACvC,sEAAmE;AAEnE,oCAAsC;AACtC,sCAAqE;AAErE,wEAAwE;AACxE,MAAM,EACJ,UAAU,EACV,gBAAgB,EAChB,OAAO,EACP,eAAe,EAChB,GAAG,oBAAS,CAAC,SAAS,CAAC;AAExB,MAAM,QAAQ,GAAG,CACf;;IAEE,8BAAC,2BAAkB;QACjB,8BAAC,6BAAgB,IAAC,EAAE,EAAC,sCAAsC,GAAG,CAC3C,CACpB,CACJ,CAAC;AAEF,MAAM,YAAY,GAAG,IAAA,2BAAM,EAAC,mBAAQ,CAAC,CAAA;;CAEpC,CAAC;AAEF,MAAM,YAAY,GAAG,2BAAM,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;QACvD,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACf;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,uEAAuE;AACvE,MAAM,cAAc,GAAG,CAAC,UAAmB,EAAE,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nB,8BAAC,6BAAgB,IAAC,EAAE,EAAC,oCAAoC,GAAG,CACvC;QACtB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CACtB,sCAAI,GAAG,EAAE,KAAK,IAAG,CAAC,CAAM,CACzB,CAAC,CACW,CAChB,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,YAAY,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React, { ReactElement } from "react";
|
|
2
|
-
import { Itinerary } from "@opentripplanner/types";
|
|
3
|
-
import {
|
|
2
|
+
import { FareProductSelector, Itinerary } from "@opentripplanner/types";
|
|
3
|
+
import { FareDetailsProps } from "../types";
|
|
4
4
|
export interface FaresProps {
|
|
5
5
|
itinerary: Itinerary;
|
|
6
6
|
FareDetails?: React.ElementType<FareDetailsProps>;
|
|
7
|
-
|
|
7
|
+
defaultFareType?: FareProductSelector;
|
|
8
8
|
}
|
|
9
|
-
export default function Fares({ itinerary, FareDetails,
|
|
9
|
+
export default function Fares({ itinerary, FareDetails, defaultFareType }: FaresProps): ReactElement | null;
|
|
10
10
|
//# sourceMappingURL=fares.d.ts.map
|
|
@@ -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;
|
|
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,CAyIlC"}
|