@edx/frontend-app-alacarte-checkout 1.41.0 → 1.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/{HelpCenter → OrderHistory/HelpCenter}/HelpCenter.js +1 -1
- package/dist/components/OrderHistory/HelpCenter/HelpCenter.js.map +1 -0
- package/dist/components/OrderHistory/HelpCenter/messages.js.map +1 -0
- package/dist/components/OrderHistory/OrderHistory.js +6 -3
- package/dist/components/OrderHistory/OrderHistory.js.map +1 -1
- package/dist/components/OrderHistory/OrderHistoryDetails.js +132 -10
- package/dist/components/OrderHistory/OrderHistoryDetails.js.map +1 -1
- package/dist/components/OrderHistory/OrderHistoryTabDetails/PaymentHistory.d.ts +6 -0
- package/dist/components/OrderHistory/OrderHistoryTabDetails/{CoursePayments.js → PaymentHistory.js} +12 -6
- package/dist/components/OrderHistory/OrderHistoryTabDetails/PaymentHistory.js.map +1 -0
- package/dist/components/OrderHistory/OrderHistoryTabDetails/SubscriptionDetails.d.ts +3 -0
- package/dist/components/OrderHistory/OrderHistoryTabDetails/{SubscriptionPayments.js → SubscriptionDetails.js} +4 -4
- package/dist/components/OrderHistory/OrderHistoryTabDetails/SubscriptionDetails.js.map +1 -0
- package/dist/components/OrderHistory/OrderHistoryTabDetails/messages.d.ts +10 -0
- package/dist/components/OrderHistory/OrderHistoryTabDetails/messages.js +12 -2
- package/dist/components/OrderHistory/OrderHistoryTabDetails/messages.js.map +1 -1
- package/dist/components/OrderHistory/OrderHistoryTabs/OrderHistoryTabs.d.ts +5 -1
- package/dist/components/OrderHistory/OrderHistoryTabs/OrderHistoryTabs.js +11 -11
- package/dist/components/OrderHistory/OrderHistoryTabs/OrderHistoryTabs.js.map +1 -1
- package/dist/components/OrderHistory/OrderList.js +1 -1
- package/dist/components/OrderHistory/OrderList.js.map +1 -1
- package/dist/components/OrderHistory/ProgramItemsTable.d.ts +8 -0
- package/dist/components/OrderHistory/ProgramItemsTable.js +49 -0
- package/dist/components/OrderHistory/ProgramItemsTable.js.map +1 -0
- package/dist/components/OrderHistory/RefundNotice/RefundNotice.d.ts +3 -0
- package/dist/components/OrderHistory/RefundNotice/RefundNotice.js +15 -0
- package/dist/components/OrderHistory/RefundNotice/RefundNotice.js.map +1 -0
- package/dist/components/OrderHistory/RefundNotice/messages.d.ts +18 -0
- package/dist/components/OrderHistory/RefundNotice/messages.js +20 -0
- package/dist/components/OrderHistory/RefundNotice/messages.js.map +1 -0
- package/dist/components/OrderHistory/data/orderDetailsData.d.ts +27 -5
- package/dist/components/OrderHistory/data/orderDetailsData.js +1 -35
- package/dist/components/OrderHistory/data/orderDetailsData.js.map +1 -1
- package/dist/components/OrderHistory/data/receiptRows.d.ts +2 -2
- package/dist/components/OrderHistory/data/receiptRows.js +5 -5
- package/dist/components/OrderHistory/data/receiptRows.js.map +1 -1
- package/dist/components/OrderHistory/messages.d.ts +20 -0
- package/dist/components/OrderHistory/messages.js +29 -9
- package/dist/components/OrderHistory/messages.js.map +1 -1
- package/dist/data/hooks/keys.d.ts +1 -0
- package/dist/data/hooks/keys.js +1 -0
- package/dist/data/hooks/keys.js.map +1 -1
- package/dist/data/hooks/useAlacarteQueries.d.ts +2 -0
- package/dist/data/hooks/useAlacarteQueries.js +11 -0
- package/dist/data/hooks/useAlacarteQueries.js.map +1 -1
- package/dist/routes.js +1 -1
- package/dist/routes.js.map +1 -1
- package/dist/styles/components/orderHistory.scss +29 -0
- package/dist/types/alacarte.d.ts +1 -0
- package/dist/types/alacarte.js.map +1 -1
- package/dist/utils/alacarteApi.d.ts +1 -0
- package/dist/utils/alacarteApi.js +8 -1
- package/dist/utils/alacarteApi.js.map +1 -1
- package/dist/utils/alacarteCheckout.js +1 -0
- package/dist/utils/alacarteCheckout.js.map +1 -1
- package/dist/utils/alacarteQueries.d.ts +2 -0
- package/dist/utils/alacarteQueries.js +4 -0
- package/dist/utils/alacarteQueries.js.map +1 -1
- package/dist/utils/orderHistory.js +2 -2
- package/dist/utils/orderHistory.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/HelpCenter/HelpCenter.js.map +0 -1
- package/dist/components/HelpCenter/messages.js.map +0 -1
- package/dist/components/OrderHistory/OrderHistoryTabDetails/CoursePayments.d.ts +0 -3
- package/dist/components/OrderHistory/OrderHistoryTabDetails/CoursePayments.js.map +0 -1
- package/dist/components/OrderHistory/OrderHistoryTabDetails/SubscriptionPayments.d.ts +0 -3
- package/dist/components/OrderHistory/OrderHistoryTabDetails/SubscriptionPayments.js.map +0 -1
- /package/dist/components/{HelpCenter → OrderHistory/HelpCenter}/HelpCenter.d.ts +0 -0
- /package/dist/components/{HelpCenter → OrderHistory/HelpCenter}/messages.d.ts +0 -0
- /package/dist/components/{HelpCenter → OrderHistory/HelpCenter}/messages.js +0 -0
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Link } from 'react-router-dom';
|
|
3
3
|
import { useIntl } from '@openedx/frontend-base';
|
|
4
4
|
import messages from './messages';
|
|
5
|
-
import { LEARNER_HELP_CENTER_URL } from '
|
|
5
|
+
import { LEARNER_HELP_CENTER_URL } from '../../../constants';
|
|
6
6
|
import Icon from '@openedx/paragon/dist/Icon';
|
|
7
7
|
import { Launch } from '@openedx/paragon/icons';
|
|
8
8
|
const HelpCenter = () => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HelpCenter.js","sourceRoot":"","sources":["../../../../src/components/OrderHistory/HelpCenter/HelpCenter.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,IAAI,MAAM,4BAA4B,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,MAAM,UAAU,GAAa,GAAG,EAAE;IAChC,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;IAEpC,OAAO,CACL,cAAK,SAAS,EAAC,kCAAkC,YAC/C,aAAG,SAAS,EAAC,yCAAyC,aACnD,aAAa,CAAC,QAAQ,CAAC,YAAY,CAAC,EACpC,GAAG,EACJ,MAAC,IAAI,IAAC,EAAE,EAAE,uBAAuB,EAAE,SAAS,EAAC,qEAAqE,EAAC,MAAM,EAAC,QAAQ,EAAC,GAAG,EAAC,qBAAqB,aACzJ,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,EACjC,KAAC,IAAI,IAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAC,gBAAgB,iBAAa,kBAAkB,GAAG,IAC1E,IACL,GACA,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import React from 'react';\nimport { Link } from 'react-router-dom';\nimport { useIntl } from '@openedx/frontend-base';\n\nimport messages from './messages';\nimport { LEARNER_HELP_CENTER_URL } from '../../../constants';\nimport Icon from '@openedx/paragon/dist/Icon';\nimport { Launch } from '@openedx/paragon/icons';\n\nconst HelpCenter: React.FC = () => {\n const { formatMessage } = useIntl();\n\n return (\n <div className=\"manage-help mt-5 pt-4 border-top\">\n <p className=\"manage-help__text text-black small mb-0\">\n {formatMessage(messages.helpLinkText)}\n {' '}\n <Link to={LEARNER_HELP_CENTER_URL} className=\"manage-help__link text-primary-500 d-inline-flex align-items-center\" target=\"_blank\" rel=\"noopener noreferrer\">\n {formatMessage(messages.helpLink)}\n <Icon src={Launch} className=\"icon mr-1 ml-1\" data-testid=\"help-center-icon\" />\n </Link>\n </p>\n </div>\n );\n};\n\nexport default HelpCenter;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../../src/components/OrderHistory/HelpCenter/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,QAAQ,GAAG,cAAc,CAAC;IAC9B,YAAY,EAAE;QACZ,EAAE,EAAE,cAAc;QAClB,cAAc,EAAE,2BAA2B;QAC3C,WAAW,EAAE,kCAAkC;KAChD;IACD,QAAQ,EAAE;QACR,EAAE,EAAE,UAAU;QACd,cAAc,EAAE,qBAAqB;QACrC,WAAW,EAAE,+BAA+B;KAC7C;CACF,CAAC,CAAC;AAEH,eAAe,QAAQ,CAAC","sourcesContent":["import { defineMessages } from '@openedx/frontend-base';\n\nconst messages = defineMessages({\n helpLinkText: {\n id: 'helpLinkText',\n defaultMessage: 'Need more help? Visit the',\n description: 'Text before the help center link',\n },\n helpLink: {\n id: 'helpLink',\n defaultMessage: 'Learner Help Center',\n description: 'Text for the help center link',\n },\n});\n\nexport default messages;\n"]}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Container } from '@openedx/paragon';
|
|
3
4
|
import OrderHistoryTabs from './OrderHistoryTabs/OrderHistoryTabs';
|
|
4
5
|
import OrderHistoryHeader from './OrderHistoryHeader';
|
|
5
|
-
import HelpCenter from '
|
|
6
|
+
import HelpCenter from './HelpCenter/HelpCenter';
|
|
7
|
+
import RefundNotice from './RefundNotice/RefundNotice';
|
|
6
8
|
const OrderHistory = () => {
|
|
7
|
-
|
|
9
|
+
const [hasOrders, setHasOrders] = useState(false);
|
|
10
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Container, { className: "orderHistory", fluid: true, size: "xl", children: [_jsx(OrderHistoryHeader, {}), _jsx("div", { children: _jsx(OrderHistoryTabs, { onHasOrdersChange: setHasOrders }) })] }), _jsx(Container, { fluid: true, className: "mt-4 bg-light-300", children: _jsxs(Container, { fluid: true, size: "xl", className: "orderHistory mb-4", children: [hasOrders && _jsx(RefundNotice, {}), _jsx(HelpCenter, {})] }) })] }));
|
|
8
11
|
};
|
|
9
12
|
export default OrderHistory;
|
|
10
13
|
//# sourceMappingURL=OrderHistory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderHistory.js","sourceRoot":"","sources":["../../../src/components/OrderHistory/OrderHistory.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"OrderHistory.js","sourceRoot":"","sources":["../../../src/components/OrderHistory/OrderHistory.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,gBAAgB,MAAM,qCAAqC,CAAC;AACnE,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,OAAO,YAAY,MAAM,6BAA6B,CAAC;AAEvD,MAAM,YAAY,GAAa,GAAG,EAAE;IAClC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAElD,OAAO,CACL,8BACE,MAAC,SAAS,IAAC,SAAS,EAAC,cAAc,EAAC,KAAK,QAAC,IAAI,EAAC,IAAI,aACjD,KAAC,kBAAkB,KAAG,EACtB,wBACE,KAAC,gBAAgB,IAAC,iBAAiB,EAAE,YAAY,GAAI,GACjD,IACI,EACZ,KAAC,SAAS,IAAC,KAAK,QAAC,SAAS,EAAC,mBAAmB,YAC5C,MAAC,SAAS,IAAC,KAAK,QAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,mBAAmB,aACrD,SAAS,IAAI,KAAC,YAAY,KAAG,EAC9B,KAAC,UAAU,KAAG,IACJ,GACF,IACX,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import React, { useState } from 'react';\nimport { Container } from '@openedx/paragon';\nimport OrderHistoryTabs from './OrderHistoryTabs/OrderHistoryTabs';\nimport OrderHistoryHeader from './OrderHistoryHeader';\nimport HelpCenter from './HelpCenter/HelpCenter';\nimport RefundNotice from './RefundNotice/RefundNotice';\n\nconst OrderHistory: React.FC = () => {\n const [hasOrders, setHasOrders] = useState(false);\n\n return (\n <>\n <Container className=\"orderHistory\" fluid size=\"xl\">\n <OrderHistoryHeader />\n <div>\n <OrderHistoryTabs onHasOrdersChange={setHasOrders} />\n </div>\n </Container>\n <Container fluid className=\"mt-4 bg-light-300\">\n <Container fluid size=\"xl\" className=\"orderHistory mb-4\">\n {hasOrders && <RefundNotice />}\n <HelpCenter />\n </Container>\n </Container>\n </>\n );\n};\n\nexport default OrderHistory;\n"]}
|
|
@@ -1,34 +1,156 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo } from 'react';
|
|
2
3
|
import { useParams } from 'react-router-dom';
|
|
3
4
|
import { Container } from '@openedx/paragon';
|
|
4
|
-
import { useIntl } from '@openedx/frontend-base';
|
|
5
|
+
import { getAppConfig, getSiteConfig, useIntl } from '@openedx/frontend-base';
|
|
6
|
+
import { appId } from '../../constants';
|
|
7
|
+
import { useViaxSessionQuery } from '../../data/hooks/useCheckoutQueries';
|
|
8
|
+
import { useOrderDetailsQuery } from '../../data/hooks/useAlacarteQueries';
|
|
9
|
+
import { createAlacarteCheckoutClient } from '../../utils/alacarteCheckout';
|
|
5
10
|
import orders from './data/orderDetailsData';
|
|
6
11
|
import messages from './messages';
|
|
7
12
|
import { getOrderSummaryRows, getOrderItemRows, } from './data/receiptRows';
|
|
8
13
|
import ALCBreadcrumb from '../Breadcrumb/ALCBreadcrumb';
|
|
9
|
-
|
|
14
|
+
import { ProgramItemsTable } from './ProgramItemsTable';
|
|
15
|
+
import getFormattedCurrency from '../../utils/orderHistory';
|
|
10
16
|
const formatDate = (isoDate) => (new Date(isoDate).toLocaleDateString('en-US', {
|
|
11
17
|
month: 'short',
|
|
12
18
|
day: 'numeric',
|
|
13
19
|
year: 'numeric',
|
|
14
20
|
}));
|
|
15
|
-
const
|
|
21
|
+
const normalizeDiscountCode = (value) => {
|
|
22
|
+
var _a;
|
|
23
|
+
if (!value) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const cleaned = (_a = value.split(':')[0]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
27
|
+
return cleaned || null;
|
|
28
|
+
};
|
|
29
|
+
const normalizeOrderDetails = (payload) => {
|
|
30
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17;
|
|
31
|
+
if (!payload || typeof payload !== 'object') {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const order = (_a = payload.order) !== null && _a !== void 0 ? _a : payload;
|
|
35
|
+
if (!order || typeof order !== 'object') {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const totals = (_b = order.totals) !== null && _b !== void 0 ? _b : {
|
|
39
|
+
amount: (_c = order.amount) !== null && _c !== void 0 ? _c : 0,
|
|
40
|
+
currency: (_d = order.currency) !== null && _d !== void 0 ? _d : 'USD',
|
|
41
|
+
};
|
|
42
|
+
const totalAmount = Number((_h = (_g = (_f = (_e = order.pricing) === null || _e === void 0 ? void 0 : _e.total) === null || _f === void 0 ? void 0 : _f.amount) !== null && _g !== void 0 ? _g : totals === null || totals === void 0 ? void 0 : totals.paid) !== null && _h !== void 0 ? _h : 0);
|
|
43
|
+
const totalCurrency = (_m = (_l = (_k = (_j = order.pricing) === null || _j === void 0 ? void 0 : _j.total) === null || _k === void 0 ? void 0 : _k.currency) !== null && _l !== void 0 ? _l : totals === null || totals === void 0 ? void 0 : totals.currency) !== null && _m !== void 0 ? _m : 'USD';
|
|
44
|
+
const discountAmount = Array.isArray((_o = order.pricing) === null || _o === void 0 ? void 0 : _o.discounts)
|
|
45
|
+
? order.pricing.discounts.reduce((sum, item) => { var _a; return sum + Number((_a = item === null || item === void 0 ? void 0 : item.amount) !== null && _a !== void 0 ? _a : 0); }, 0)
|
|
46
|
+
: Number((_r = (_q = (_p = order.totals) === null || _p === void 0 ? void 0 : _p.discount) !== null && _q !== void 0 ? _q : order.discount) !== null && _r !== void 0 ? _r : 0);
|
|
47
|
+
const firstDiscount = Array.isArray((_s = order.pricing) === null || _s === void 0 ? void 0 : _s.discounts) ? order.pricing.discounts[0] : null;
|
|
48
|
+
const discountCode = normalizeDiscountCode((_v = (_u = (_t = firstDiscount === null || firstDiscount === void 0 ? void 0 : firstDiscount.code) !== null && _t !== void 0 ? _t : firstDiscount === null || firstDiscount === void 0 ? void 0 : firstDiscount.offerId) !== null && _u !== void 0 ? _u : order.discountCode) !== null && _v !== void 0 ? _v : null);
|
|
49
|
+
const item = Array.isArray(order.items) ? order.items[0] : Array.isArray(order.lines) ? order.lines[0] : null;
|
|
50
|
+
const itemName = (_z = (_y = (_x = (_w = item === null || item === void 0 ? void 0 : item.name) !== null && _w !== void 0 ? _w : item === null || item === void 0 ? void 0 : item.productName) !== null && _x !== void 0 ? _x : item === null || item === void 0 ? void 0 : item.title) !== null && _y !== void 0 ? _y : order.name) !== null && _z !== void 0 ? _z : 'Order';
|
|
51
|
+
const subtotalAmount = Number((_2 = (_1 = (_0 = order.pricing) === null || _0 === void 0 ? void 0 : _0.subtotal) === null || _1 === void 0 ? void 0 : _1.amount) !== null && _2 !== void 0 ? _2 : 0);
|
|
52
|
+
const itemPriceAmount = Number((_4 = (_3 = item === null || item === void 0 ? void 0 : item.price) === null || _3 === void 0 ? void 0 : _3.amount) !== null && _4 !== void 0 ? _4 : 0);
|
|
53
|
+
const normalizedSubtotal = {
|
|
54
|
+
amount: Number.isFinite(subtotalAmount) ? subtotalAmount : 0,
|
|
55
|
+
currency: String(totalCurrency),
|
|
56
|
+
};
|
|
57
|
+
const normalizedItemPrice = {
|
|
58
|
+
amount: Number.isFinite(itemPriceAmount) ? itemPriceAmount : 0,
|
|
59
|
+
currency: String(totalCurrency),
|
|
60
|
+
};
|
|
61
|
+
const normalizedTotal = {
|
|
62
|
+
amount: Number.isFinite(totalAmount) ? totalAmount : 0,
|
|
63
|
+
currency: String(totalCurrency),
|
|
64
|
+
};
|
|
65
|
+
const normalizedDiscountAmount = {
|
|
66
|
+
amount: Number.isFinite(discountAmount) ? discountAmount : 0,
|
|
67
|
+
currency: String(totalCurrency),
|
|
68
|
+
};
|
|
69
|
+
const firstItem = Array.isArray(order.items) ? order.items[0] : null;
|
|
70
|
+
const isProgramOrder = (firstItem === null || firstItem === void 0 ? void 0 : firstItem.kind) === 'program';
|
|
71
|
+
if (isProgramOrder) {
|
|
72
|
+
const programCourses = Array.isArray(firstItem === null || firstItem === void 0 ? void 0 : firstItem.courses) ? firstItem.courses : [];
|
|
73
|
+
return {
|
|
74
|
+
orderId: String((_5 = order.orderId) !== null && _5 !== void 0 ? _5 : ''),
|
|
75
|
+
orderNumber: String((_6 = order.orderNumber) !== null && _6 !== void 0 ? _6 : ''),
|
|
76
|
+
purchasedAt: String((_9 = (_8 = (_7 = order.purchasedAt) !== null && _7 !== void 0 ? _7 : order.placedAt) !== null && _8 !== void 0 ? _8 : order.createdAt) !== null && _9 !== void 0 ? _9 : new Date().toISOString()),
|
|
77
|
+
paymentIntentId: String((_10 = order.paymentIntentId) !== null && _10 !== void 0 ? _10 : ''),
|
|
78
|
+
name: String((_11 = firstItem === null || firstItem === void 0 ? void 0 : firstItem.name) !== null && _11 !== void 0 ? _11 : itemName),
|
|
79
|
+
subtotalAmount: normalizedSubtotal,
|
|
80
|
+
itemPriceAmount: normalizedItemPrice,
|
|
81
|
+
discountCode,
|
|
82
|
+
total: normalizedTotal,
|
|
83
|
+
discountAmount: normalizedDiscountAmount,
|
|
84
|
+
itemType: 'program',
|
|
85
|
+
items: programCourses.map((entry) => {
|
|
86
|
+
var _a, _b, _c, _d, _e, _f;
|
|
87
|
+
return ({
|
|
88
|
+
productId: entry.productId,
|
|
89
|
+
courseRunKey: entry.courseRunKey,
|
|
90
|
+
name: (_a = entry.name) !== null && _a !== void 0 ? _a : itemName,
|
|
91
|
+
price: (_b = entry.price) !== null && _b !== void 0 ? _b : { amount: Number((_c = entry.amount) !== null && _c !== void 0 ? _c : 0), currency: String(totalCurrency) },
|
|
92
|
+
discount: (_d = entry.discount) !== null && _d !== void 0 ? _d : { amount: 0, currency: String(totalCurrency) },
|
|
93
|
+
total: (_e = entry.total) !== null && _e !== void 0 ? _e : { amount: Number((_f = entry.amount) !== null && _f !== void 0 ? _f : 0), currency: String(totalCurrency) },
|
|
94
|
+
});
|
|
95
|
+
}),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
orderId: String((_12 = order.orderId) !== null && _12 !== void 0 ? _12 : ''),
|
|
100
|
+
orderNumber: String((_13 = order.orderNumber) !== null && _13 !== void 0 ? _13 : ''),
|
|
101
|
+
purchasedAt: String((_16 = (_15 = (_14 = order.purchasedAt) !== null && _14 !== void 0 ? _14 : order.placedAt) !== null && _15 !== void 0 ? _15 : order.createdAt) !== null && _16 !== void 0 ? _16 : new Date().toISOString()),
|
|
102
|
+
paymentIntentId: String((_17 = order.paymentIntentId) !== null && _17 !== void 0 ? _17 : ''),
|
|
103
|
+
name: String(itemName),
|
|
104
|
+
subtotalAmount: normalizedSubtotal,
|
|
105
|
+
itemPriceAmount: normalizedItemPrice,
|
|
106
|
+
discountCode,
|
|
107
|
+
total: normalizedTotal,
|
|
108
|
+
discountAmount: normalizedDiscountAmount,
|
|
109
|
+
itemType: 'course',
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
const ReceiptRow = ({ label, children }) => (_jsxs("div", { className: "d-flex align-items-baseline mb-2", children: [_jsx("span", { className: "font-weight-bold text-gray-700", children: label }), _jsx("span", { className: "flex-grow-1 mx-2 text-gray-700", style: { borderBottom: '1px dotted #B4B1A8' } }), _jsx("span", { children: children })] }));
|
|
16
113
|
const OrderReceipt = ({ order }) => {
|
|
114
|
+
var _a, _b, _c, _d, _e, _f;
|
|
17
115
|
const { formatMessage } = useIntl();
|
|
18
116
|
const orderDate = formatDate(order.purchasedAt);
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
117
|
+
const subtotal = getFormattedCurrency((_a = order.subtotalAmount) !== null && _a !== void 0 ? _a : order.total);
|
|
118
|
+
const itemPrice = getFormattedCurrency((_b = order.itemPriceAmount) !== null && _b !== void 0 ? _b : order.total);
|
|
119
|
+
const total = getFormattedCurrency(order.total);
|
|
120
|
+
const discountAmountValue = (_c = order.discountAmount) !== null && _c !== void 0 ? _c : { amount: 0, currency: order.total.currency };
|
|
121
|
+
const discountAmount = getFormattedCurrency({
|
|
122
|
+
amount: -Math.abs(discountAmountValue.amount),
|
|
123
|
+
currency: discountAmountValue.currency,
|
|
124
|
+
});
|
|
125
|
+
const discountCode = (_e = normalizeDiscountCode((_d = order.discountCode) !== null && _d !== void 0 ? _d : null)) !== null && _e !== void 0 ? _e : 'None';
|
|
126
|
+
const orderSummaryRows = getOrderSummaryRows(order, orderDate, subtotal, total, discountAmount, discountCode);
|
|
127
|
+
const orderItemRows = getOrderItemRows(order, itemPrice, total, discountAmount);
|
|
23
128
|
const renderRows = (rows) => rows.map(({ label, value }) => (_jsx(ReceiptRow, { label: formatMessage(label), children: value }, label.id)));
|
|
24
129
|
return (_jsxs(_Fragment, { children: [_jsx("div", { className: "my-2", children: _jsx(ALCBreadcrumb, { items: [
|
|
25
130
|
{ label: 'Order History', href: '/aca-order-history' },
|
|
26
131
|
{ label: `Order date: ${orderDate}` },
|
|
27
|
-
] }) }), _jsxs("h1", { className: "h1 mb-4 mt-4 text-primary-500 orderHistoryTitle", children: [formatMessage(messages.orderDateTitle), ": ", orderDate] }), _jsx("h3", { className: "h3 font-weight-bold mb-3 text-primary-500", children: formatMessage(messages.orderSummaryTitle) }), renderRows(orderSummaryRows), _jsx("hr", { className: "my-4 divider" }), _jsx("h3", { className: "font-weight-bold mb-3 text-primary-500", children: formatMessage(messages.orderItemsTitle) }), renderRows(orderItemRows), _jsx("hr", { className: "my-4 divider" }), _jsx("h3", { className: "font-weight-bold mb-3 text-primary-500", children: formatMessage(messages.paymentTitle) }), _jsx(ReceiptRow, { label: formatMessage(messages.receiptAmountLabel), children: total })] }));
|
|
132
|
+
] }) }), _jsxs("h1", { className: "h1 mb-4 mt-4 text-primary-500 orderHistoryTitle", children: [formatMessage(messages.orderDateTitle), ": ", orderDate] }), _jsx("h3", { className: "h3 font-weight-bold mb-3 text-primary-500", children: formatMessage(messages.orderSummaryTitle) }), renderRows(orderSummaryRows), _jsx("hr", { className: "my-4 divider" }), _jsx("h3", { className: "font-weight-bold mb-3 text-primary-500", children: formatMessage(messages.orderItemsTitle) }), order.itemType === 'program' ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "mb-2 text-gray-700 mb-1", children: [_jsx("span", { className: "font-weight-bold", children: formatMessage(messages.receiptNameLabel) }), ' ', _jsx("span", { children: order.name })] }), _jsx(ProgramItemsTable, { items: (_f = order.items) !== null && _f !== void 0 ? _f : [], currency: order.total.currency })] })) : renderRows(orderItemRows), _jsx("hr", { className: "my-4 divider" }), _jsx("h3", { className: "font-weight-bold mb-3 text-primary-500", children: formatMessage(messages.paymentTitle) }), _jsx(ReceiptRow, { label: formatMessage(messages.receiptAmountLabel), children: total })] }));
|
|
28
133
|
};
|
|
29
134
|
const OrderHistoryDetails = () => {
|
|
30
|
-
const {
|
|
31
|
-
const
|
|
135
|
+
const { orderNumber } = useParams();
|
|
136
|
+
const config = getAppConfig(appId);
|
|
137
|
+
const siteConfig = getSiteConfig();
|
|
138
|
+
const lmsBaseUrl = siteConfig.lmsBaseUrl.replace(/\/$/, '');
|
|
139
|
+
const isDevelopment = siteConfig.environment === 'development';
|
|
140
|
+
const apiUrl = config.VIAX_API_URL;
|
|
141
|
+
const edxSessionUrl = `${isDevelopment ? 'https://courses.stage.edx.org' : lmsBaseUrl}/api/edx-session`;
|
|
142
|
+
const client = useMemo(() => (apiUrl ? createAlacarteCheckoutClient({ apiUrl }) : null), [apiUrl]);
|
|
143
|
+
const sessionQuery = useViaxSessionQuery(edxSessionUrl);
|
|
144
|
+
useEffect(() => {
|
|
145
|
+
if (sessionQuery.data && client) {
|
|
146
|
+
client.setToken(sessionQuery.data.viaxToken);
|
|
147
|
+
}
|
|
148
|
+
}, [client, sessionQuery.data]);
|
|
149
|
+
const orderDetailsQuery = useOrderDetailsQuery(client, orderNumber !== null && orderNumber !== void 0 ? orderNumber : null, !!sessionQuery.data);
|
|
150
|
+
const order = useMemo(() => {
|
|
151
|
+
var _a, _b;
|
|
152
|
+
return (_b = (_a = normalizeOrderDetails(orderDetailsQuery.data)) !== null && _a !== void 0 ? _a : orders.find(item => item.orderNumber === orderNumber || item.orderId === orderNumber)) !== null && _b !== void 0 ? _b : null;
|
|
153
|
+
}, [orderDetailsQuery.data, orderNumber]);
|
|
32
154
|
return (_jsx(Container, { fluid: true, size: "xl", className: "py-4 orderHistory", children: order && _jsx(OrderReceipt, { order: order }) }));
|
|
33
155
|
};
|
|
34
156
|
export default OrderHistoryDetails;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderHistoryDetails.js","sourceRoot":"","sources":["../../../src/components/OrderHistory/OrderHistoryDetails.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,MAAiC,MAAM,yBAAyB,CAAC;AACxE,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,EACL,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC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AC/B,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,EAAE,CAAC;IAChC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC;IAE5D,OAAO,CACL,KAAC,SAAS,IAAC,KAAK,QAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,mBAAmB,YACrD,KAAK,IAAI,KAAC,YAAY,IAAC,KAAK,EAAE,KAAK,GAAI,GAC9B,CACb,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["import type { ReactNode } from 'react';\nimport { useParams } from 'react-router-dom';\nimport { Container } from '@openedx/paragon';\nimport { useIntl } from '@openedx/frontend-base';\n\nimport orders, { type OrderDetailsData } from './data/orderDetailsData';\nimport messages from './messages';\nimport {\n getOrderSummaryRows,\n getOrderItemRows,\n} from './data/receiptRows';\nimport ALCBreadcrumb from '../Breadcrumb/ALCBreadcrumb';\n\nconst formatAmount = (amount: number, currency: string) => (\n `${currency === 'USD' ? '$' : ''}${amount.toFixed(2)} ${currency}`\n);\n\nconst formatDate = (isoDate: string) => (\n new Date(isoDate).toLocaleDateString('en-US', {\n month: 'short',\n day: 'numeric',\n year: 'numeric',\n })\n);\n\ninterface ReceiptRowProps {\n label: string,\n children: ReactNode,\n}\n\nconst ReceiptRow = ({ label, children }: ReceiptRowProps) => (\n <div className=\"d-flex align-items-baseline mb-2\">\n <span className=\"font-weight-bold text-gray-700\">{label}</span>\n <span\n className=\"flex-grow-1 mx-2 text-gray-700\"\n style={{ borderBottom: '1px dotted currentColor' }}\n />\n <span>{children}</span>\n </div>\n);\n\nconst OrderReceipt = ({ order }: { order: OrderDetailsData }) => {\n const { formatMessage } = useIntl();\n const orderDate = formatDate(order.purchasedAt);\n const total = formatAmount(order.total.amount, order.total.currency);\n const discountAmount = formatAmount(0, order.total.currency);\n\n const orderSummaryRows = getOrderSummaryRows(order, orderDate, total, discountAmount);\n\n const orderItemRows = getOrderItemRows(order, total, discountAmount);\n\n const renderRows = (rows: typeof orderSummaryRows | typeof orderItemRows) =>\n rows.map(({ label, value }) => (\n <ReceiptRow key={label.id} label={formatMessage(label)}>\n {value}\n </ReceiptRow>\n ));\n\n return (\n <>\n <div className=\"my-2\">\n <ALCBreadcrumb\n items={[\n { label: 'Order History', href: '/aca-order-history' },\n { label: `Order date: ${orderDate}` },\n ]}\n />\n </div>\n <h1 className=\"h1 mb-4 mt-4 text-primary-500 orderHistoryTitle\">\n {formatMessage(messages.orderDateTitle)}: {orderDate}\n </h1>\n\n <h3 className=\"h3 font-weight-bold mb-3 text-primary-500\">\n {formatMessage(messages.orderSummaryTitle)}\n </h3>\n {renderRows(orderSummaryRows)}\n\n <hr className=\"my-4 divider\" />\n\n <h3 className=\"font-weight-bold mb-3 text-primary-500\">\n {formatMessage(messages.orderItemsTitle)}\n </h3>\n {renderRows(orderItemRows)}\n\n <hr className=\"my-4 divider\" />\n\n <h3 className=\"font-weight-bold mb-3 text-primary-500\">\n {formatMessage(messages.paymentTitle)}\n </h3>\n <ReceiptRow label={formatMessage(messages.receiptAmountLabel)}>\n {total}\n </ReceiptRow>\n </>\n );\n};\n\nconst OrderHistoryDetails = () => {\n const { orderId } = useParams();\n const order = orders.find(item => item.orderId === orderId);\n\n return (\n <Container fluid size=\"xl\" className=\"py-4 orderHistory\">\n {order && <OrderReceipt order={order} />}\n </Container>\n );\n};\n\nexport default OrderHistoryDetails;\n"]}
|
|
1
|
+
{"version":3,"file":"OrderHistoryDetails.js","sourceRoot":"","sources":["../../../src/components/OrderHistory/OrderHistoryDetails.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,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AAI,EAAC,IAAI,EAAC,SAAS,EAAC,mBAAmB,YACrD,KAAK,IAAI,KAAC,YAAY,IAAC,KAAK,EAAE,KAAK,GAAI,GAC9B,CACb,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["import type { ReactNode } from 'react';\nimport { useEffect, useMemo } from 'react';\nimport { useParams } from 'react-router-dom';\nimport { Container } from '@openedx/paragon';\nimport { getAppConfig, getSiteConfig, useIntl } from '@openedx/frontend-base';\n\nimport { appId } from '../../constants';\nimport { useViaxSessionQuery } from '../../data/hooks/useCheckoutQueries';\nimport { useOrderDetailsQuery } from '../../data/hooks/useAlacarteQueries';\nimport { createAlacarteCheckoutClient } from '../../utils/alacarteCheckout';\nimport orders, { type OrderDetailsData } from './data/orderDetailsData';\nimport messages from './messages';\nimport {\n getOrderSummaryRows,\n getOrderItemRows,\n} from './data/receiptRows';\nimport ALCBreadcrumb from '../Breadcrumb/ALCBreadcrumb';\nimport { ProgramItemsTable } from './ProgramItemsTable';\nimport getFormattedCurrency from '@src/utils/orderHistory';\n\nconst formatDate = (isoDate: string) => (\n new Date(isoDate).toLocaleDateString('en-US', {\n month: 'short',\n day: 'numeric',\n year: 'numeric',\n })\n);\n\nconst normalizeDiscountCode = (value?: string | null): string | null => {\n if (!value) {\n return null;\n }\n\n const cleaned = value.split(':')[0]?.trim();\n return cleaned || null;\n};\n\nconst normalizeOrderDetails = (payload: any): OrderDetailsData | null => {\n if (!payload || typeof payload !== 'object') {\n return null;\n }\n\n const order = payload.order ?? payload;\n if (!order || typeof order !== 'object') {\n return null;\n }\n\n const totals = order.totals ?? {\n amount: order.amount ?? 0,\n currency: order.currency ?? 'USD',\n };\n\n const totalAmount = Number(\n order.pricing?.total?.amount ?? totals?.paid ?? 0,\n );\n const totalCurrency = order.pricing?.total?.currency ?? totals?.currency ?? 'USD';\n\n const discountAmount = Array.isArray(order.pricing?.discounts)\n ? order.pricing.discounts.reduce((sum: number, item: any) => sum + Number(item?.amount ?? 0), 0)\n : Number(order.totals?.discount ?? order.discount ?? 0);\n\n const firstDiscount = Array.isArray(order.pricing?.discounts) ? order.pricing.discounts[0] : null;\n const discountCode = normalizeDiscountCode(firstDiscount?.code ?? firstDiscount?.offerId ?? order.discountCode ?? null);\n const item = Array.isArray(order.items) ? order.items[0] : Array.isArray(order.lines) ? order.lines[0] : null;\n const itemName = item?.name ?? item?.productName ?? item?.title ?? order.name ?? 'Order';\n const subtotalAmount = Number(\n order.pricing?.subtotal?.amount ?? 0,\n );\n const itemPriceAmount = Number(\n item?.price?.amount ?? 0,\n );\n\n const normalizedSubtotal = {\n amount: Number.isFinite(subtotalAmount) ? subtotalAmount : 0,\n currency: String(totalCurrency),\n };\n\n const normalizedItemPrice = {\n amount: Number.isFinite(itemPriceAmount) ? itemPriceAmount : 0,\n currency: String(totalCurrency),\n };\n\n const normalizedTotal = {\n amount: Number.isFinite(totalAmount) ? totalAmount : 0,\n currency: String(totalCurrency),\n };\n\n const normalizedDiscountAmount = {\n amount: Number.isFinite(discountAmount) ? discountAmount : 0,\n currency: String(totalCurrency),\n };\n\n const firstItem = Array.isArray(order.items) ? order.items[0] : null;\n const isProgramOrder = firstItem?.kind === 'program';\n\n if (isProgramOrder) {\n const programCourses = Array.isArray(firstItem?.courses) ? firstItem.courses : [];\n\n return {\n orderId: String(order.orderId ?? ''),\n orderNumber: String(order.orderNumber ?? ''),\n purchasedAt: String(order.purchasedAt ?? order.placedAt ?? order.createdAt ?? new Date().toISOString()),\n paymentIntentId: String(order.paymentIntentId ?? ''),\n name: String(firstItem?.name ?? itemName),\n subtotalAmount: normalizedSubtotal,\n itemPriceAmount: normalizedItemPrice,\n discountCode,\n total: normalizedTotal,\n discountAmount: normalizedDiscountAmount,\n itemType: 'program',\n items: programCourses.map((entry: any) => ({\n productId: entry.productId,\n courseRunKey: entry.courseRunKey,\n name: entry.name ?? itemName,\n price: entry.price ?? { amount: Number(entry.amount ?? 0), currency: String(totalCurrency) },\n discount: entry.discount ?? { amount: 0, currency: String(totalCurrency) },\n total: entry.total ?? { amount: Number(entry.amount ?? 0), currency: String(totalCurrency) },\n })),\n } as const;\n }\n\n return {\n orderId: String(order.orderId ?? ''),\n orderNumber: String(order.orderNumber ?? ''),\n purchasedAt: String(order.purchasedAt ?? order.placedAt ?? order.createdAt ?? new Date().toISOString()),\n paymentIntentId: String(order.paymentIntentId ?? ''),\n name: String(itemName),\n subtotalAmount: normalizedSubtotal,\n itemPriceAmount: normalizedItemPrice,\n discountCode,\n total: normalizedTotal,\n discountAmount: normalizedDiscountAmount,\n itemType: 'course',\n } as const;\n};\n\ninterface ReceiptRowProps {\n label: string,\n children: ReactNode,\n}\n\nconst ReceiptRow = ({ label, children }: ReceiptRowProps) => (\n <div className=\"d-flex align-items-baseline mb-2\">\n <span className=\"font-weight-bold text-gray-700\">{label}</span>\n <span\n className=\"flex-grow-1 mx-2 text-gray-700\"\n style={{ borderBottom: '1px dotted #B4B1A8' }}\n />\n <span>{children}</span>\n </div>\n);\n\nconst OrderReceipt = ({ order }: { order: OrderDetailsData }) => {\n const { formatMessage } = useIntl();\n const orderDate = formatDate(order.purchasedAt);\n const subtotal = getFormattedCurrency(order.subtotalAmount ?? order.total);\n const itemPrice = getFormattedCurrency(order.itemPriceAmount ?? order.total);\n const total = getFormattedCurrency(order.total);\n const discountAmountValue = order.discountAmount ?? { amount: 0, currency: order.total.currency };\n const discountAmount = getFormattedCurrency({\n amount: -Math.abs(discountAmountValue.amount),\n currency: discountAmountValue.currency,\n });\n const discountCode = normalizeDiscountCode(order.discountCode ?? null) ?? 'None';\n\n const orderSummaryRows = getOrderSummaryRows(order, orderDate, subtotal, total, discountAmount, discountCode);\n\n const orderItemRows = getOrderItemRows(order, itemPrice, total, discountAmount);\n\n const renderRows = (rows: typeof orderSummaryRows | typeof orderItemRows) =>\n rows.map(({ label, value }) => (\n <ReceiptRow key={label.id} label={formatMessage(label)}>\n {value}\n </ReceiptRow>\n ));\n\n return (\n <>\n <div className=\"my-2\">\n <ALCBreadcrumb\n items={[\n { label: 'Order History', href: '/aca-order-history' },\n { label: `Order date: ${orderDate}` },\n ]}\n />\n </div>\n <h1 className=\"h1 mb-4 mt-4 text-primary-500 orderHistoryTitle\">\n {formatMessage(messages.orderDateTitle)}: {orderDate}\n </h1>\n\n <h3 className=\"h3 font-weight-bold mb-3 text-primary-500\">\n {formatMessage(messages.orderSummaryTitle)}\n </h3>\n {renderRows(orderSummaryRows)}\n\n <hr className=\"my-4 divider\" />\n\n <h3 className=\"font-weight-bold mb-3 text-primary-500\">\n {formatMessage(messages.orderItemsTitle)}\n </h3>\n {order.itemType === 'program' ? (\n <>\n <div className=\"mb-2 text-gray-700 mb-1\">\n <span className=\"font-weight-bold\">{formatMessage(messages.receiptNameLabel)}</span>{' '}\n <span>{order.name}</span>\n </div>\n <ProgramItemsTable items={order.items ?? []} currency={order.total.currency} />\n </>\n ) : renderRows(orderItemRows)}\n\n <hr className=\"my-4 divider\" />\n\n <h3 className=\"font-weight-bold mb-3 text-primary-500\">\n {formatMessage(messages.paymentTitle)}\n </h3>\n <ReceiptRow label={formatMessage(messages.receiptAmountLabel)}>\n {total}\n </ReceiptRow>\n </>\n );\n};\n\nconst OrderHistoryDetails = () => {\n const { orderNumber } = useParams<{ orderNumber: string }>();\n const config = getAppConfig(appId);\n const siteConfig = getSiteConfig();\n const lmsBaseUrl = siteConfig.lmsBaseUrl.replace(/\\/$/, '');\n const isDevelopment = siteConfig.environment === 'development';\n const apiUrl = config.VIAX_API_URL as string | undefined;\n const edxSessionUrl = `${isDevelopment ? 'https://courses.stage.edx.org' : lmsBaseUrl}/api/edx-session`;\n\n const client = useMemo(\n () => (apiUrl ? createAlacarteCheckoutClient({ apiUrl }) : null),\n [apiUrl],\n );\n const sessionQuery = useViaxSessionQuery(edxSessionUrl);\n\n useEffect(() => {\n if (sessionQuery.data && client) {\n client.setToken(sessionQuery.data.viaxToken);\n }\n }, [client, sessionQuery.data]);\n\n const orderDetailsQuery = useOrderDetailsQuery(client, orderNumber ?? null, !!sessionQuery.data);\n\n const order = useMemo(\n () => normalizeOrderDetails(orderDetailsQuery.data)\n ?? orders.find(item => item.orderNumber === orderNumber || item.orderId === orderNumber)\n ?? null,\n [orderDetailsQuery.data, orderNumber],\n );\n\n return (\n <Container fluid size=\"xl\" className=\"py-4 orderHistory\">\n {order && <OrderReceipt order={order} />}\n </Container>\n );\n};\n\nexport default OrderHistoryDetails;\n"]}
|
package/dist/components/OrderHistory/OrderHistoryTabDetails/{CoursePayments.js → PaymentHistory.js}
RENAMED
|
@@ -16,8 +16,8 @@ import { usePurchaseHistoryQuery } from '../../../data/hooks/useAlacarteQueries'
|
|
|
16
16
|
import { createAlacarteCheckoutClient } from '../../../utils/alacarteCheckout';
|
|
17
17
|
import messages from './messages';
|
|
18
18
|
import OrdersList from '../OrderList';
|
|
19
|
-
const
|
|
20
|
-
var _a
|
|
19
|
+
const PaymentHistory = ({ onHasOrdersChange }) => {
|
|
20
|
+
var _a;
|
|
21
21
|
const { formatMessage } = useIntl();
|
|
22
22
|
const config = getAppConfig(appId);
|
|
23
23
|
const siteConfig = getSiteConfig();
|
|
@@ -47,8 +47,14 @@ const CoursePayments = () => {
|
|
|
47
47
|
console.error('Unable to load payment receipt.', error);
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
|
-
const orders = (
|
|
51
|
-
|
|
50
|
+
const orders = Array.isArray((_a = purchaseHistoryQuery.data) === null || _a === void 0 ? void 0 : _a.orders)
|
|
51
|
+
? purchaseHistoryQuery.data.orders
|
|
52
|
+
: [];
|
|
53
|
+
const hasOrders = purchaseHistoryQuery.isSuccess && orders.length > 0;
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
onHasOrdersChange(hasOrders);
|
|
56
|
+
}, [hasOrders, onHasOrdersChange]);
|
|
57
|
+
return (_jsxs("section", { className: "pt-4", "aria-labelledby": "payment-history", children: [_jsxs("div", { className: "my-2", children: [_jsx("h2", { id: "payment-history", className: "h5 font-weight-bold text-primary-700 mb-1", children: formatMessage(messages.subscriptionPaymentsTitle) }), _jsx("p", { className: "medium text-gray-700 mb-5", children: formatMessage(messages.subscriptionPaymentsEmptyMessage) }), _jsx("h2", { id: "payment-history", className: "h5 font-weight-bold text-primary-700 mb-1", children: formatMessage(messages.otherPurchasesTitle) }), _jsx("p", { className: "medium text-gray-700 mb-0", children: formatMessage(messages.coursePurchasesEmptyMessage) })] }), _jsx("div", { className: "mt-2", children: _jsx(OrdersList, { orders: orders, onViewReceipt: handleViewReceipt }) })] }));
|
|
52
58
|
};
|
|
53
|
-
export default
|
|
54
|
-
//# sourceMappingURL=
|
|
59
|
+
export default PaymentHistory;
|
|
60
|
+
//# sourceMappingURL=PaymentHistory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PaymentHistory.js","sourceRoot":"","sources":["../../../../src/components/OrderHistory/OrderHistoryTabDetails/PaymentHistory.tsx"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAc,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAE/E,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,UAAU,MAAM,cAAc,CAAC;AAMtC,MAAM,cAAc,GAAkC,CAAC,EAAE,iBAAiB,EAAE,EAAE,EAAE;;IAC9E,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;IACpC,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACnC,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC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'react';\nimport { getAppConfig, getSiteConfig, useIntl } from '@openedx/frontend-base';\nimport { appId } from '../../../constants';\nimport { useViaxSessionQuery } from '../../../data/hooks/useCheckoutQueries';\nimport { usePurchaseHistoryQuery } from '../../../data/hooks/useAlacarteQueries';\nimport { createAlacarteCheckoutClient } from '../../../utils/alacarteCheckout';\nimport type { PurchaseHistoryItem } from '../../../types/orderHistory';\nimport messages from './messages';\nimport OrdersList from '../OrderList';\n\ninterface PaymentHistoryProps {\n onHasOrdersChange: (hasOrders: boolean) => void,\n}\n\nconst PaymentHistory: React.FC<PaymentHistoryProps> = ({ onHasOrdersChange }) => {\n const { formatMessage } = useIntl();\n const config = getAppConfig(appId);\n const siteConfig = getSiteConfig();\n const lmsBaseUrl = siteConfig.lmsBaseUrl.replace(/\\/$/, '');\n const isDevelopment = siteConfig.environment === 'development';\n const apiUrl = config.VIAX_API_URL as string | undefined;\n const edxSessionUrl = `${isDevelopment ? 'https://courses.stage.edx.org' : lmsBaseUrl}/api/edx-session`;\n\n const client = useMemo(\n () => (apiUrl ? createAlacarteCheckoutClient({ apiUrl }) : null),\n [apiUrl],\n );\n const sessionQuery = useViaxSessionQuery(edxSessionUrl);\n\n useEffect(() => {\n if (sessionQuery.data && client) {\n client.setToken(sessionQuery.data.viaxToken);\n }\n }, [client, sessionQuery.data]);\n\n const purchaseHistoryQuery = usePurchaseHistoryQuery(client, !!sessionQuery.data);\n\n const handleViewReceipt = async (order: PurchaseHistoryItem) => {\n if (!client || !order.orderId) {\n return;\n }\n\n try {\n const receiptUrl = await client.getStripePaymentReceipt(order.orderId);\n if (receiptUrl) {\n window.open(receiptUrl, '_blank', 'noopener,noreferrer');\n }\n } catch (error) {\n console.error('Unable to load payment receipt.', error);\n }\n };\n\n const orders = Array.isArray(purchaseHistoryQuery.data?.orders)\n ? purchaseHistoryQuery.data.orders\n : [];\n const hasOrders = purchaseHistoryQuery.isSuccess && orders.length > 0;\n\n useEffect(() => {\n onHasOrdersChange(hasOrders);\n }, [hasOrders, onHasOrdersChange]);\n\n return (\n <section className=\"pt-4\" aria-labelledby=\"payment-history\">\n <div className=\"my-2\">\n <h2 id=\"payment-history\" className=\"h5 font-weight-bold text-primary-700 mb-1\">\n {formatMessage(messages.subscriptionPaymentsTitle)}\n </h2>\n <p className=\"medium text-gray-700 mb-5\">\n {formatMessage(messages.subscriptionPaymentsEmptyMessage)}\n </p>\n <h2 id=\"payment-history\" className=\"h5 font-weight-bold text-primary-700 mb-1\">\n {formatMessage(messages.otherPurchasesTitle)}\n </h2>\n <p className=\"medium text-gray-700 mb-0\">\n {formatMessage(messages.coursePurchasesEmptyMessage)}\n </p>\n </div>\n <div className=\"mt-2\">\n <OrdersList orders={orders} onViewReceipt={handleViewReceipt} />\n </div>\n </section>\n );\n};\n\nexport default PaymentHistory;\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useIntl } from '@openedx/frontend-base';
|
|
3
3
|
import messages from './messages';
|
|
4
|
-
const
|
|
4
|
+
const SubscriptionDetails = () => {
|
|
5
5
|
const { formatMessage } = useIntl();
|
|
6
|
-
return (_jsx("section", { className: "pt-4", children: _jsx("p", { className: "medium text-gray-700 mb-0", children: formatMessage(messages.
|
|
6
|
+
return (_jsx("section", { className: "pt-4", children: _jsx("p", { className: "medium text-gray-700 mb-0", children: formatMessage(messages.subscriptionDetailsEmptyMessage) }) }));
|
|
7
7
|
};
|
|
8
|
-
export default
|
|
9
|
-
//# sourceMappingURL=
|
|
8
|
+
export default SubscriptionDetails;
|
|
9
|
+
//# sourceMappingURL=SubscriptionDetails.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubscriptionDetails.js","sourceRoot":"","sources":["../../../../src/components/OrderHistory/OrderHistoryTabDetails/SubscriptionDetails.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,QAAQ,MAAM,YAAY,CAAC;AAElC,MAAM,mBAAmB,GAAa,GAAG,EAAE;IACzC,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;IAEpC,OAAO,CACL,kBAAS,SAAS,EAAC,MAAM,YACvB,YAAG,SAAS,EAAC,2BAA2B,YACrC,aAAa,CAAC,QAAQ,CAAC,+BAA+B,CAAC,GACtD,GACI,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["import React from 'react';\nimport { useIntl } from '@openedx/frontend-base';\nimport messages from './messages';\n\nconst SubscriptionDetails: React.FC = () => {\n const { formatMessage } = useIntl();\n\n return (\n <section className=\"pt-4\">\n <p className=\"medium text-gray-700 mb-0\">\n {formatMessage(messages.subscriptionDetailsEmptyMessage)}\n </p>\n </section>\n );\n};\n\nexport default SubscriptionDetails;\n"]}
|
|
@@ -9,6 +9,16 @@ declare const messages: {
|
|
|
9
9
|
defaultMessage: string;
|
|
10
10
|
description: string;
|
|
11
11
|
};
|
|
12
|
+
subscriptionDetailsEmptyMessage: {
|
|
13
|
+
id: string;
|
|
14
|
+
defaultMessage: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
subscriptionPaymentsTitle: {
|
|
18
|
+
id: string;
|
|
19
|
+
defaultMessage: string;
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
12
22
|
subscriptionPaymentsEmptyMessage: {
|
|
13
23
|
id: string;
|
|
14
24
|
defaultMessage: string;
|
|
@@ -10,11 +10,21 @@ const messages = defineMessages({
|
|
|
10
10
|
defaultMessage: 'Courses you purchased in the last 180 days will appear here. If possible, please retain receipts for your records.',
|
|
11
11
|
description: 'Message shown when there are no course purchases to display.',
|
|
12
12
|
},
|
|
13
|
+
subscriptionDetailsEmptyMessage: {
|
|
14
|
+
id: 'orderHistory.subscriptionDetails.emptyMessage',
|
|
15
|
+
defaultMessage: 'Subscription details will appear here. If possible, please retain receipts for your records.',
|
|
16
|
+
description: 'Message shown when there are no subscription payments to display.',
|
|
17
|
+
},
|
|
18
|
+
subscriptionPaymentsTitle: {
|
|
19
|
+
id: 'orderHistory.subscriptionPayments.title',
|
|
20
|
+
defaultMessage: 'Subscription payments',
|
|
21
|
+
description: 'Heading above the list of subscription payments.',
|
|
22
|
+
},
|
|
13
23
|
subscriptionPaymentsEmptyMessage: {
|
|
14
24
|
id: 'orderHistory.subscriptionPayments.emptyMessage',
|
|
15
|
-
defaultMessage: '
|
|
25
|
+
defaultMessage: 'Your subscription payments will be logged here.',
|
|
16
26
|
description: 'Message shown when there are no subscription payments to display.',
|
|
17
|
-
}
|
|
27
|
+
}
|
|
18
28
|
});
|
|
19
29
|
export default messages;
|
|
20
30
|
//# sourceMappingURL=messages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../../src/components/OrderHistory/OrderHistoryTabDetails/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,QAAQ,GAAG,cAAc,CAAC;IAC9B,mBAAmB,EAAE;QACnB,EAAE,EAAE,iDAAiD;QACrD,cAAc,EAAE,iBAAiB;QACjC,WAAW,EAAE,mDAAmD;KACjE;IACD,2BAA2B,EAAE;QAC3B,EAAE,EAAE,0CAA0C;QAC9C,cAAc,EAAE,oHAAoH;QACpI,WAAW,EAAE,8DAA8D;KAC5E;IACD,gCAAgC,EAAE;QAChC,EAAE,EAAE,gDAAgD;QACpD,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../../src/components/OrderHistory/OrderHistoryTabDetails/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,QAAQ,GAAG,cAAc,CAAC;IAC9B,mBAAmB,EAAE;QACnB,EAAE,EAAE,iDAAiD;QACrD,cAAc,EAAE,iBAAiB;QACjC,WAAW,EAAE,mDAAmD;KACjE;IACD,2BAA2B,EAAE;QAC3B,EAAE,EAAE,0CAA0C;QAC9C,cAAc,EAAE,oHAAoH;QACpI,WAAW,EAAE,8DAA8D;KAC5E;IACD,+BAA+B,EAAE;QAC/B,EAAE,EAAE,+CAA+C;QACnD,cAAc,EAAE,8FAA8F;QAC9G,WAAW,EAAE,mEAAmE;KACjF;IACD,yBAAyB,EAAE;QACzB,EAAE,EAAE,yCAAyC;QAC7C,cAAc,EAAE,uBAAuB;QACvC,WAAW,EAAE,kDAAkD;KAChE;IACD,gCAAgC,EAAE;QAChC,EAAE,EAAE,gDAAgD;QACpD,cAAc,EAAE,iDAAiD;QACjE,WAAW,EAAE,mEAAmE;KACjF;CACF,CAAC,CAAC;AAEH,eAAe,QAAQ,CAAC","sourcesContent":["import { defineMessages } from '@openedx/frontend-base';\n\nconst messages = defineMessages({\n otherPurchasesTitle: {\n id: 'orderHistory.coursePayments.otherPurchasesTitle',\n defaultMessage: 'Other purchases',\n description: 'Heading above the list of other course purchases.',\n },\n coursePurchasesEmptyMessage: {\n id: 'orderHistory.coursePayments.emptyMessage',\n defaultMessage: 'Courses you purchased in the last 180 days will appear here. If possible, please retain receipts for your records.',\n description: 'Message shown when there are no course purchases to display.',\n },\n subscriptionDetailsEmptyMessage: {\n id: 'orderHistory.subscriptionDetails.emptyMessage',\n defaultMessage: 'Subscription details will appear here. If possible, please retain receipts for your records.',\n description: 'Message shown when there are no subscription payments to display.',\n },\n subscriptionPaymentsTitle: {\n id: 'orderHistory.subscriptionPayments.title',\n defaultMessage: 'Subscription payments',\n description: 'Heading above the list of subscription payments.',\n },\n subscriptionPaymentsEmptyMessage: {\n id: 'orderHistory.subscriptionPayments.emptyMessage',\n defaultMessage: 'Your subscription payments will be logged here.',\n description: 'Message shown when there are no subscription payments to display.',\n }\n});\n\nexport default messages;\n"]}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface OrderHistoryTabsProps {
|
|
3
|
+
onHasOrdersChange: (hasOrders: boolean) => void;
|
|
4
|
+
}
|
|
5
|
+
declare const OrderHistoryTabs: React.FC<OrderHistoryTabsProps>;
|
|
2
6
|
export default OrderHistoryTabs;
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo, useState, useCallback } from 'react';
|
|
3
3
|
import { Tabs, Tab } from '@openedx/paragon';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
const OrderHistoryTabs = () => {
|
|
4
|
+
import SubscriptionDetails from '../OrderHistoryTabDetails/SubscriptionDetails';
|
|
5
|
+
import PaymentHistory from '../OrderHistoryTabDetails/PaymentHistory';
|
|
6
|
+
const OrderHistoryTabs = ({ onHasOrdersChange }) => {
|
|
7
7
|
var _a;
|
|
8
8
|
const orderHistoryTabs = useMemo(() => {
|
|
9
9
|
const tabs = [
|
|
10
10
|
{
|
|
11
|
-
key: '
|
|
12
|
-
title: 'Subscription
|
|
13
|
-
panel: _jsx(
|
|
11
|
+
key: 'Subscription',
|
|
12
|
+
title: 'Subscription',
|
|
13
|
+
panel: _jsx(SubscriptionDetails, {}),
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
|
-
key: '
|
|
17
|
-
title: '
|
|
18
|
-
panel: _jsx(
|
|
16
|
+
key: 'PaymentHistory',
|
|
17
|
+
title: 'Payment history',
|
|
18
|
+
panel: _jsx(PaymentHistory, { onHasOrdersChange: onHasOrdersChange }),
|
|
19
19
|
},
|
|
20
20
|
];
|
|
21
21
|
return tabs;
|
|
22
|
-
}, []);
|
|
22
|
+
}, [onHasOrdersChange]);
|
|
23
23
|
const [activeTab, setActiveTab] = useState(orderHistoryTabs[0].key);
|
|
24
24
|
const handleTabSelect = useCallback((tabKey) => {
|
|
25
25
|
if (tabKey) {
|
|
26
26
|
setActiveTab(tabKey);
|
|
27
27
|
}
|
|
28
28
|
}, []);
|
|
29
|
-
return (_jsx(Tabs, { id: "order-history-tabs", defaultActiveKey: (_a = orderHistoryTabs[0]) === null || _a === void 0 ? void 0 : _a.key, activeKey: activeTab, onSelect: handleTabSelect, className: "mb-4",
|
|
29
|
+
return (_jsx(Tabs, { id: "order-history-tabs", defaultActiveKey: (_a = orderHistoryTabs[0]) === null || _a === void 0 ? void 0 : _a.key, activeKey: activeTab, onSelect: handleTabSelect, className: "mb-4", children: orderHistoryTabs.map(tab => (_jsx(Tab, { eventKey: tab.key, title: tab.title, children: tab.panel }, tab.key))) }));
|
|
30
30
|
};
|
|
31
31
|
export default OrderHistoryTabs;
|
|
32
32
|
//# sourceMappingURL=OrderHistoryTabs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderHistoryTabs.js","sourceRoot":"","sources":["../../../../src/components/OrderHistory/OrderHistoryTabs/OrderHistoryTabs.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,
|
|
1
|
+
{"version":3,"file":"OrderHistoryTabs.js","sourceRoot":"","sources":["../../../../src/components/OrderHistory/OrderHistoryTabs/OrderHistoryTabs.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,mBAAmB,MAAM,+CAA+C,CAAC;AAChF,OAAO,cAAc,MAAM,0CAA0C,CAAC;AAMtE,MAAM,gBAAgB,GAAoC,CAAC,EAAE,iBAAiB,EAAE,EAAE,EAAE;;IAClF,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,EAAE;QACpC,MAAM,IAAI,GAAG;YACX;gBACE,GAAG,EAAE,cAAc;gBACnB,KAAK,EAAE,cAAc;gBACrB,KAAK,EAAE,KAAC,mBAAmB,KAAG;aAC/B;YACD;gBACE,GAAG,EAAE,gBAAgB;gBACrB,KAAK,EAAE,iBAAiB;gBACxB,KAAK,EAAE,KAAC,cAAc,IAAC,iBAAiB,EAAE,iBAAiB,GAAI;aAChE;SACF,CAAC;QAEF,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAExB,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACpE,MAAM,eAAe,GAAG,WAAW,CAAC,CAAC,MAAM,EAAE,EAAE;QAC7C,IAAI,MAAM,EAAE,CAAC;YACX,YAAY,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,KAAC,IAAI,IACH,EAAE,EAAC,oBAAoB,EACvB,gBAAgB,EAAE,MAAA,gBAAgB,CAAC,CAAC,CAAC,0CAAE,GAAG,EAC1C,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,eAAe,EACzB,SAAS,EAAC,MAAM,YAEf,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAC3B,KAAC,GAAG,IAAC,QAAQ,EAAE,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,YACrC,GAAG,CAAC,KAAK,IADmC,GAAG,CAAC,GAAG,CAEhD,CACP,CAAC,GACG,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import React, { useMemo, useState, useCallback } from 'react';\nimport { Tabs, Tab } from '@openedx/paragon';\nimport SubscriptionDetails from '../OrderHistoryTabDetails/SubscriptionDetails';\nimport PaymentHistory from '../OrderHistoryTabDetails/PaymentHistory';\n\ninterface OrderHistoryTabsProps {\n onHasOrdersChange: (hasOrders: boolean) => void,\n}\n\nconst OrderHistoryTabs: React.FC<OrderHistoryTabsProps> = ({ onHasOrdersChange }) => {\n const orderHistoryTabs = useMemo(() => {\n const tabs = [\n {\n key: 'Subscription',\n title: 'Subscription',\n panel: <SubscriptionDetails />,\n },\n {\n key: 'PaymentHistory',\n title: 'Payment history',\n panel: <PaymentHistory onHasOrdersChange={onHasOrdersChange} />,\n },\n ];\n\n return tabs;\n }, [onHasOrdersChange]);\n\n const [activeTab, setActiveTab] = useState(orderHistoryTabs[0].key);\n const handleTabSelect = useCallback((tabKey) => {\n if (tabKey) {\n setActiveTab(tabKey);\n }\n }, []);\n\n return (\n <Tabs\n id=\"order-history-tabs\"\n defaultActiveKey={orderHistoryTabs[0]?.key}\n activeKey={activeTab}\n onSelect={handleTabSelect}\n className=\"mb-4\"\n >\n {orderHistoryTabs.map(tab => (\n <Tab eventKey={tab.key} title={tab.title} key={tab.key}>\n {tab.panel}\n </Tab>\n ))}\n </Tabs>\n );\n};\n\nexport default OrderHistoryTabs;\n"]}
|
|
@@ -6,7 +6,7 @@ const OrdersList = ({ orders, onViewReceipt }) => {
|
|
|
6
6
|
const navigate = useNavigate();
|
|
7
7
|
return (_jsx("div", { children: orders.map((order) => (_jsx("div", { className: "mb-3", children: _jsx(OrderHistoryCard, { title: order.name, purchaseDate: new Date(order.purchasedAt).toLocaleDateString('en-US'), totalCost: getFormattedCurrency(order.total), orderNumber: order.orderNumber,
|
|
8
8
|
// isReceiptDisabled={(order.paymentMethodType ?? '').toLowerCase() !== 'stripe'} // TODO: Uncomment this line when we have paymentMethodType available in the API response. For now, we will always enable the receipt button.
|
|
9
|
-
isReceiptDisabled: false, onViewReceipt: () => onViewReceipt === null || onViewReceipt === void 0 ? void 0 : onViewReceipt(order), onViewOrderDetails: () => navigate(`/aca-order-details/${order.
|
|
9
|
+
isReceiptDisabled: false, onViewReceipt: () => onViewReceipt === null || onViewReceipt === void 0 ? void 0 : onViewReceipt(order), onViewOrderDetails: () => navigate(`/aca-order-details/${encodeURIComponent(order.orderNumber)}`) }) }, order.orderId))) }));
|
|
10
10
|
};
|
|
11
11
|
export default OrdersList;
|
|
12
12
|
//# sourceMappingURL=OrderList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderList.js","sourceRoot":"","sources":["../../../src/components/OrderHistory/OrderList.tsx"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,UAAU,GAAG,CAAC,EAAE,MAAM,EAAE,aAAa,EAAmB,EAAE,EAAE;IAChE,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAE/B,OAAO,CACL,wBACG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACrB,cAAyB,SAAS,EAAC,MAAM,YACvC,KAAC,gBAAgB,IACf,KAAK,EAAE,KAAK,CAAC,IAAI,EACjB,YAAY,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,EACrE,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC,KAAK,CAAC,EAC5C,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,+NAA+N;gBAC/N,iBAAiB,EAAE,KAAK,EACxB,aAAa,EAAE,GAAG,EAAE,CAAC,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,KAAK,CAAC,EAC3C,kBAAkB,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,sBAAsB,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"OrderList.js","sourceRoot":"","sources":["../../../src/components/OrderHistory/OrderList.tsx"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,UAAU,GAAG,CAAC,EAAE,MAAM,EAAE,aAAa,EAAmB,EAAE,EAAE;IAChE,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAE/B,OAAO,CACL,wBACG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACrB,cAAyB,SAAS,EAAC,MAAM,YACvC,KAAC,gBAAgB,IACf,KAAK,EAAE,KAAK,CAAC,IAAI,EACjB,YAAY,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,EACrE,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC,KAAK,CAAC,EAC5C,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,+NAA+N;gBAC/N,iBAAiB,EAAE,KAAK,EACxB,aAAa,EAAE,GAAG,EAAE,CAAC,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,KAAK,CAAC,EAC3C,kBAAkB,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,sBAAsB,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,GACjG,IAVM,KAAK,CAAC,OAAO,CAWjB,CACP,CAAC,GACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import getFormattedCurrency from '@src/utils/orderHistory';\nimport type { OrdersListProps } from '../../types/orderHistory';\nimport OrderHistoryCard from './OrderHistoryCard';\nimport { useNavigate } from 'react-router-dom';\n\nconst OrdersList = ({ orders, onViewReceipt }: OrdersListProps) => {\n const navigate = useNavigate();\n\n return (\n <div>\n {orders.map((order) => (\n <div key={order.orderId} className=\"mb-3\">\n <OrderHistoryCard\n title={order.name}\n purchaseDate={new Date(order.purchasedAt).toLocaleDateString('en-US')}\n totalCost={getFormattedCurrency(order.total)}\n orderNumber={order.orderNumber}\n // isReceiptDisabled={(order.paymentMethodType ?? '').toLowerCase() !== 'stripe'} // TODO: Uncomment this line when we have paymentMethodType available in the API response. For now, we will always enable the receipt button.\n isReceiptDisabled={false}\n onViewReceipt={() => onViewReceipt?.(order)}\n onViewOrderDetails={() => navigate(`/aca-order-details/${encodeURIComponent(order.orderNumber)}`)}\n />\n </div>\n ))}\n </div>\n );\n};\n\nexport default OrdersList;\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { OrderProgramItem } from './data/orderDetailsData';
|
|
2
|
+
export declare const formatAmount: (amount: number, currency: string) => string;
|
|
3
|
+
interface ProgramItemsTableProps {
|
|
4
|
+
items: OrderProgramItem[];
|
|
5
|
+
currency: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const ProgramItemsTable: ({ items, currency }: ProgramItemsTableProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default ProgramItemsTable;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DataTable } from '@openedx/paragon';
|
|
3
|
+
import { useIntl } from '@openedx/frontend-base';
|
|
4
|
+
import messages from './messages';
|
|
5
|
+
export const formatAmount = (amount, currency) => (`${currency === 'USD' ? '$' : ''}${amount === null || amount === void 0 ? void 0 : amount.toFixed(2)} ${currency}`);
|
|
6
|
+
export const ProgramItemsTable = ({ items, currency }) => {
|
|
7
|
+
const { formatMessage } = useIntl();
|
|
8
|
+
const data = items.map((item, index) => {
|
|
9
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
10
|
+
const itemPrice = (_d = (_b = (_a = item.price) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : (_c = item.total) === null || _c === void 0 ? void 0 : _c.amount) !== null && _d !== void 0 ? _d : 0;
|
|
11
|
+
const discountAmount = (_f = (_e = item.discount) === null || _e === void 0 ? void 0 : _e.amount) !== null && _f !== void 0 ? _f : 0;
|
|
12
|
+
const totalAfterDiscount = (_h = (_g = item.total) === null || _g === void 0 ? void 0 : _g.amount) !== null && _h !== void 0 ? _h : itemPrice - discountAmount;
|
|
13
|
+
return {
|
|
14
|
+
id: (_k = (_j = item.productId) !== null && _j !== void 0 ? _j : item.courseRunKey) !== null && _k !== void 0 ? _k : `${item.name}-${index}`,
|
|
15
|
+
name: item.name,
|
|
16
|
+
price: formatAmount(itemPrice, (_m = (_l = item.price) === null || _l === void 0 ? void 0 : _l.currency) !== null && _m !== void 0 ? _m : currency),
|
|
17
|
+
discountAmount: `-${formatAmount(discountAmount, (_p = (_o = item.discount) === null || _o === void 0 ? void 0 : _o.currency) !== null && _p !== void 0 ? _p : currency)}`,
|
|
18
|
+
totalAfterDiscount: formatAmount(totalAfterDiscount, (_t = (_r = (_q = item.total) === null || _q === void 0 ? void 0 : _q.currency) !== null && _r !== void 0 ? _r : (_s = item.price) === null || _s === void 0 ? void 0 : _s.currency) !== null && _t !== void 0 ? _t : currency),
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
const columns = [
|
|
22
|
+
{
|
|
23
|
+
Header: formatMessage(messages.receiptTableCourseHeader),
|
|
24
|
+
accessor: 'name',
|
|
25
|
+
cellClassName: 'text-left',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
Header: formatMessage(messages.receiptTablePriceHeader),
|
|
29
|
+
accessor: 'price',
|
|
30
|
+
headerClassName: 'text-left',
|
|
31
|
+
cellClassName: 'text-left',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
Header: formatMessage(messages.receiptTableDiscountAmountHeader),
|
|
35
|
+
accessor: 'discountAmount',
|
|
36
|
+
headerClassName: 'text-left',
|
|
37
|
+
cellClassName: 'text-left',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
Header: formatMessage(messages.receiptTableTotalAfterDiscountHeader),
|
|
41
|
+
accessor: 'totalAfterDiscount',
|
|
42
|
+
headerClassName: 'text-left',
|
|
43
|
+
cellClassName: 'text-left',
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
return (_jsx("div", { className: "table-responsive mb-2 programItemsTable", children: _jsx(DataTable, { itemCount: data.length, data: data, columns: columns, children: _jsx(DataTable.Table, {}) }) }));
|
|
47
|
+
};
|
|
48
|
+
export default ProgramItemsTable;
|
|
49
|
+
//# sourceMappingURL=ProgramItemsTable.js.map
|