@edx/frontend-app-subscription-manage 1.21.0 → 1.23.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/OrderHistory/OrderHistoryCard.js +8 -1
- package/dist/components/OrderHistory/OrderHistoryCard.js.map +1 -1
- package/dist/components/OrderHistory/OrderHistoryDetails.js +3 -3
- package/dist/components/OrderHistory/OrderHistoryDetails.js.map +1 -1
- package/dist/components/OrderHistory/OrderList.js +1 -3
- package/dist/components/OrderHistory/OrderList.js.map +1 -1
- package/dist/components/OrderHistory/OrderPurchases.js +28 -5
- package/dist/components/OrderHistory/OrderPurchases.js.map +1 -1
- package/dist/components/OrderHistory/messages.d.ts +25 -0
- package/dist/components/OrderHistory/messages.js +25 -0
- package/dist/components/OrderHistory/messages.js.map +1 -1
- package/dist/types.d.ts +6 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Card, Button, Icon } from '@openedx/paragon';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
3
4
|
import { Launch } from '@openedx/paragon/icons';
|
|
4
|
-
|
|
5
|
+
import messages from './messages';
|
|
6
|
+
const OrderHistoryCard = ({ title, purchaseDate, totalCost, orderNumber, isReceiptDisabled = false, onViewReceipt, onViewOrderDetails, }) => {
|
|
7
|
+
const { formatMessage } = useIntl();
|
|
8
|
+
const receiptDescriptionId = `receipt-description-${orderNumber.replace(/\s+/g, '-').toLowerCase()}`;
|
|
9
|
+
const detailsDescriptionId = `details-description-${orderNumber.replace(/\s+/g, '-').toLowerCase()}`;
|
|
10
|
+
return (_jsx(Card, { className: "order-card", "aria-label": `${title} order details`, children: _jsx(Card.Body, { className: "p-3", children: _jsxs("div", { className: "d-flex justify-content-between align-items-start flex-wrap", children: [_jsxs("div", { children: [_jsx("h6", { className: "mb-2", children: title }), _jsxs("div", { className: "d-flex gap-1", children: [_jsxs("div", { className: "x-small", children: [_jsxs("p", { className: "text-muted orderHistoryCard__details mr1-1 mb-0", children: [formatMessage(messages.dateOfPurchaseLabel), ":"] }), _jsxs("p", { className: "text-muted mr-1 orderHistoryCard__details mb-0", children: [formatMessage(messages.totalCostLabel), ":"] }), _jsxs("p", { className: "text-muted mr-1 orderHistoryCard__details mb-0", children: [formatMessage(messages.orderNumberLabel), ":"] })] }), _jsxs("div", { className: "x-small", children: [_jsx("p", { className: "mb-0", children: purchaseDate }), _jsx("p", { className: "mb-0", children: totalCost }), _jsx("p", { className: "mb-0", children: orderNumber })] })] })] }), _jsxs("div", { className: "d-flex align-items-center gap-3 mt-2 mt-md-auto", children: [_jsxs(Button, { variant: "link", size: "sm", onClick: isReceiptDisabled ? undefined : onViewReceipt, disabled: isReceiptDisabled, className: "d-flex gap-1 p-0 orderHistoryCard__link", "aria-describedby": receiptDescriptionId, children: [formatMessage(messages.viewReceiptButton), " ", _jsx("span", { children: _jsx(Icon, { size: "xs", src: Launch, "aria-hidden": true }) }), _jsxs("span", { id: receiptDescriptionId, className: "sr-only", children: [' ', "for ", title] })] }), _jsxs(Button, { variant: "link", size: "sm", onClick: onViewOrderDetails, className: "p-0 orderHistoryCard__link", "aria-describedby": detailsDescriptionId, children: [formatMessage(messages.viewOrderDetailsButton), _jsxs("span", { id: detailsDescriptionId, className: "sr-only", children: [' ', "for ", title] })] })] })] }) }) }));
|
|
11
|
+
};
|
|
5
12
|
export default OrderHistoryCard;
|
|
6
13
|
//# sourceMappingURL=OrderHistoryCard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderHistoryCard.js","sourceRoot":"","sources":["../../../src/components/OrderHistory/OrderHistoryCard.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC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,aAAa,CAAC,QAAQ,CAAC,gBAAgB,CAAC,SAAM,IACzG,EAEN,eAAK,SAAS,EAAC,SAAS,aACtB,YAAG,SAAS,EAAC,MAAM,YAAE,YAAY,GAAK,EACtC,YAAG,SAAS,EAAC,MAAM,YAAE,SAAS,GAAK,EACnC,YAAG,SAAS,EAAC,MAAM,YAAE,WAAW,GAAK,IACjC,IACF,IACF,EAEN,eAAK,SAAS,EAAC,iDAAiD,aAC9D,MAAC,MAAM,IACL,OAAO,EAAC,MAAM,EACd,IAAI,EAAC,IAAI,EACT,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,EACtD,QAAQ,EAAE,iBAAiB,EAC3B,SAAS,EAAC,yCAAyC,sBACjC,oBAAoB,aAErC,aAAa,CAAC,QAAQ,CAAC,iBAAiB,CAAC,OAAE,yBAAM,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,GAAG,EAAE,MAAM,wBAAgB,GAAO,EACpG,gBAAM,EAAE,EAAE,oBAAoB,EAAE,SAAS,EAAC,SAAS,aAChD,GAAG,UAAM,KAAK,IACV,IACA,EAET,MAAC,MAAM,IACL,OAAO,EAAC,MAAM,EACd,IAAI,EAAC,IAAI,EACT,OAAO,EAAE,kBAAkB,EAC3B,SAAS,EAAC,4BAA4B,sBACpB,oBAAoB,aAErC,aAAa,CAAC,QAAQ,CAAC,sBAAsB,CAAC,EAC/C,gBAAM,EAAE,EAAE,oBAAoB,EAAE,SAAS,EAAC,SAAS,aAChD,GAAG,UAAM,KAAK,IACV,IACA,IACL,IACF,GACI,GACP,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import { Card, Button, Icon } from '@openedx/paragon';\nimport { useIntl } from 'react-intl';\nimport { Launch } from '@openedx/paragon/icons';\nimport messages from './messages';\n\ninterface OrderCardProps {\n title: string,\n purchaseDate: string,\n totalCost: string,\n orderNumber: string,\n isReceiptDisabled?: boolean,\n onViewReceipt: () => void,\n onViewOrderDetails: () => void,\n}\n\nconst OrderHistoryCard = ({\n title,\n purchaseDate,\n totalCost,\n orderNumber,\n isReceiptDisabled = false,\n onViewReceipt,\n onViewOrderDetails,\n}: OrderCardProps) => {\n const { formatMessage } = useIntl();\n const receiptDescriptionId = `receipt-description-${orderNumber.replace(/\\s+/g, '-').toLowerCase()}`;\n const detailsDescriptionId = `details-description-${orderNumber.replace(/\\s+/g, '-').toLowerCase()}`;\n\n return (\n <Card className=\"order-card\" aria-label={`${title} order details`}>\n <Card.Body className=\"p-3\">\n <div className=\"d-flex justify-content-between align-items-start flex-wrap\">\n <div>\n <h6 className=\"mb-2\">{title}</h6>\n\n <div className=\"d-flex gap-1\">\n <div className=\"x-small\">\n <p className=\"text-muted orderHistoryCard__details mr1-1 mb-0\">{formatMessage(messages.dateOfPurchaseLabel)}:</p>\n <p className=\"text-muted mr-1 orderHistoryCard__details mb-0\">{formatMessage(messages.totalCostLabel)}:</p>\n <p className=\"text-muted mr-1 orderHistoryCard__details mb-0\">{formatMessage(messages.orderNumberLabel)}:</p>\n </div>\n\n <div className=\"x-small\">\n <p className=\"mb-0\">{purchaseDate}</p>\n <p className=\"mb-0\">{totalCost}</p>\n <p className=\"mb-0\">{orderNumber}</p>\n </div>\n </div>\n </div>\n\n <div className=\"d-flex align-items-center gap-3 mt-2 mt-md-auto\">\n <Button\n variant=\"link\"\n size=\"sm\"\n onClick={isReceiptDisabled ? undefined : onViewReceipt}\n disabled={isReceiptDisabled}\n className=\"d-flex gap-1 p-0 orderHistoryCard__link\"\n aria-describedby={receiptDescriptionId}\n >\n {formatMessage(messages.viewReceiptButton)} <span><Icon size=\"xs\" src={Launch} aria-hidden /></span>\n <span id={receiptDescriptionId} className=\"sr-only\">\n {' '}for {title}\n </span>\n </Button>\n\n <Button\n variant=\"link\"\n size=\"sm\"\n onClick={onViewOrderDetails}\n className=\"p-0 orderHistoryCard__link\"\n aria-describedby={detailsDescriptionId}\n >\n {formatMessage(messages.viewOrderDetailsButton)}\n <span id={detailsDescriptionId} className=\"sr-only\">\n {' '}for {title}\n </span>\n </Button>\n </div>\n </div>\n </Card.Body>\n </Card>\n );\n};\n\nexport default OrderHistoryCard;\n"]}
|
|
@@ -15,7 +15,7 @@ const formatDate = (isoDate) => (new Date(isoDate).toLocaleDateString('en-US', {
|
|
|
15
15
|
day: 'numeric',
|
|
16
16
|
year: 'numeric',
|
|
17
17
|
}));
|
|
18
|
-
const ReceiptRow = ({ label, children }) => (_jsxs("div", { className: "d-flex align-items-baseline mb-2", children: [_jsx("
|
|
18
|
+
const ReceiptRow = ({ label, children }) => (_jsxs("div", { className: "d-flex align-items-baseline mb-2", role: "listitem", children: [_jsx("dt", { 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' }, "aria-hidden": "true" }), _jsx("dd", { className: "mb-0", children: children })] }));
|
|
19
19
|
const normalizeDiscountCode = (value) => {
|
|
20
20
|
var _a;
|
|
21
21
|
if (!value) {
|
|
@@ -92,8 +92,8 @@ const OrderReceipt = ({ order }) => {
|
|
|
92
92
|
});
|
|
93
93
|
const orderSummaryRows = getOrderSummaryRows(order, orderDate, subtotal, total, discountAmount, (_d = order.discountCode) !== null && _d !== void 0 ? _d : '');
|
|
94
94
|
const orderItemRows = getOrderItemRows(order, itemPrice, total, discountAmount);
|
|
95
|
-
const renderRows = (rows) => rows.map(({ label, value }) => (_jsx(ReceiptRow, { label: formatMessage(label), children: value }, label.id)));
|
|
96
|
-
return (_jsxs(
|
|
95
|
+
const renderRows = (rows, listLabel) => (_jsx("dl", { className: "mb-0", role: "list", "aria-label": listLabel, children: rows.map(({ label, value }) => (_jsx(ReceiptRow, { label: formatMessage(label), children: value }, label.id))) }));
|
|
96
|
+
return (_jsxs("article", { "aria-labelledby": "order-receipt-title", children: [_jsx("div", { className: "my-2", children: _jsx(Breadcrumb, { ariaLabel: "breadcrumb", links: [{ label: formatMessage(messages.orderHistoryTitle), href: `${ORDER_HISTORY_PATH}?tab=payment-history` }], activeLabel: `${formatMessage(messages.orderDateTitle)}: ${orderDate}` }) }), _jsxs("h1", { id: "order-receipt-title", className: "h1 mb-4 mt-4 text-primary-500 orderHistoryTitle", children: [formatMessage(messages.orderDateTitle), ": ", orderDate] }), _jsxs("section", { "aria-labelledby": "order-summary-title", children: [_jsx("h3", { id: "order-summary-title", className: "h3 font-weight-bold mb-3 text-primary-500", children: formatMessage(messages.orderSummaryTitle) }), renderRows(orderSummaryRows, 'Order summary details')] }), _jsx("hr", { className: "my-4 divider" }), _jsxs("section", { "aria-labelledby": "order-items-title", children: [_jsx("h3", { id: "order-items-title", 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: (_e = order.items) !== null && _e !== void 0 ? _e : [], currency: order.total.currency })] })) : renderRows(orderItemRows, 'Order item details')] }), _jsx("hr", { className: "my-4 divider" }), _jsxs("section", { "aria-labelledby": "payment-title", children: [_jsx("h3", { id: "payment-title", className: "font-weight-bold mb-3 text-primary-500", children: formatMessage(messages.paymentTitle) }), _jsx("dl", { className: "mb-0", role: "list", "aria-label": "Payment details", children: _jsx(ReceiptRow, { label: formatMessage(messages.receiptAmountLabel), children: total }) })] })] }));
|
|
97
97
|
};
|
|
98
98
|
const OrderHistoryDetails = () => {
|
|
99
99
|
const { formatMessage } = useIntl();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderHistoryDetails.js","sourceRoot":"","sources":["../../../src/components/OrderHistory/OrderHistoryDetails.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,S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OAAO,EAAE,CAAC;QAC9B,OAAO,GAAG,KAAC,KAAK,IAAC,OAAO,EAAC,QAAQ,YAAE,aAAa,CAAC,QAAQ,CAAC,oBAAoB,CAAC,GAAS,CAAC;IAC3F,CAAC;SAAM,IAAI,CAAC,iBAAiB,CAAC,SAAS,EAAE,CAAC;QACxC,OAAO,GAAG,CACR,cAAK,SAAS,EAAC,oCAAoC,YACjD,KAAC,OAAO,IAAC,SAAS,EAAC,QAAQ,EAAC,gBAAgB,EAAE,aAAa,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAI,GACnF,CACP,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,KAAK;YACb,CAAC,CAAC,KAAC,YAAY,IAAC,KAAK,EAAE,KAAK,GAAI;YAChC,CAAC,CAAC,KAAC,KAAK,IAAC,OAAO,EAAC,SAAS,YAAE,aAAa,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAS,CAAC;IAC/E,CAAC;IAED,OAAO,CACL,KAAC,SAAS,IAAC,KAAK,QAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,mBAAmB,YACrD,OAAO,GACE,CACb,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["import type { ReactNode } from 'react';\nimport { useMemo } from 'react';\nimport { useParams } from 'react-router-dom';\nimport { Alert, Breadcrumb, Container, Spinner } from '@openedx/paragon';\nimport { useIntl } from '@openedx/frontend-base';\n\nimport type { MoneyAmount, OrderDetailsData } from '../../types';\nimport { ORDER_HISTORY_PATH } from '../../constants';\nimport getFormattedCurrency from '../../utils/currency';\nimport { useViaxClient, useViaxSession } from '../../data/hooks/useManageQueries';\nimport { useOrderDetailsQuery } from '../../data/hooks/useOrderHistoryQueries';\nimport messages from './messages';\nimport { getOrderSummaryRows, getOrderItemRows } from './data/receiptRows';\nimport { ProgramItemsTable } from './ProgramItemsTable';\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 #B4B1A8' }}\n />\n <span>{children}</span>\n </div>\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 const currency = String(order.pricing?.total?.currency ?? totals.currency ?? 'USD');\n const money = (amount: unknown): MoneyAmount => ({\n amount: Number.isFinite(Number(amount)) ? Number(amount) : 0,\n currency,\n });\n\n const discounts: any[] | null = Array.isArray(order.pricing?.discounts) ? order.pricing.discounts : null;\n const discountTotal = discounts\n ? discounts.reduce((sum, item) => sum + Number(item?.amount ?? 0), 0)\n : Number(order.totals?.discount ?? order.discount ?? 0);\n const firstDiscount = discounts?.[0];\n const discountCode = normalizeDiscountCode(\n firstDiscount?.code ?? firstDiscount?.offerId ?? order.discountCode ?? null,\n );\n\n const firstItem = Array.isArray(order.items) ? order.items[0] : null;\n const item = firstItem ?? (Array.isArray(order.lines) ? order.lines[0] : null);\n const itemName = String(item?.name ?? item?.productName ?? item?.title ?? order.name ?? 'Order');\n\n const base = {\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 subtotalAmount: money(order.pricing?.subtotal?.amount),\n itemPriceAmount: money(item?.price?.amount),\n discountCode,\n total: money(order.pricing?.total?.amount ?? totals.paid),\n discountAmount: money(discountTotal),\n };\n\n if (firstItem?.kind === 'program') {\n const programCourses: any[] = Array.isArray(firstItem.courses) ? firstItem.courses : [];\n\n return {\n ...base,\n name: String(firstItem.name ?? itemName),\n itemType: 'program',\n items: programCourses.map((entry) => ({\n productId: entry.productId,\n courseRunKey: entry.courseRunKey,\n name: entry.name ?? itemName,\n price: entry.price ?? money(entry.amount),\n discount: entry.discount ?? money(0),\n total: entry.total ?? money(entry.amount),\n })),\n };\n }\n\n return { ...base, name: itemName, itemType: 'course' };\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 discountValue = order.discountAmount ?? { amount: 0, currency: order.total.currency };\n const discountAmount = getFormattedCurrency({\n amount: -Math.abs(discountValue.amount) || 0,\n currency: discountValue.currency,\n });\n\n const orderSummaryRows = getOrderSummaryRows(\n order,\n orderDate,\n subtotal,\n total,\n discountAmount,\n order.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 <Breadcrumb\n ariaLabel=\"breadcrumb\"\n links={[{ label: formatMessage(messages.orderHistoryTitle), href: `${ORDER_HISTORY_PATH}?tab=payment-history` }]}\n activeLabel={`${formatMessage(messages.orderDateTitle)}: ${orderDate}`}\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 { formatMessage } = useIntl();\n const { orderNumber } = useParams<{ orderNumber: string }>();\n const client = useViaxClient();\n const { sessionReady } = useViaxSession(client);\n const orderDetailsQuery = useOrderDetailsQuery(client, orderNumber ?? null, sessionReady);\n const order = useMemo(() => normalizeOrderDetails(orderDetailsQuery.data), [orderDetailsQuery.data]);\n\n let content: ReactNode;\n if (orderDetailsQuery.isError) {\n content = <Alert variant=\"danger\">{formatMessage(messages.purchaseHistoryError)}</Alert>;\n } else if (!orderDetailsQuery.isSuccess) {\n content = (\n <div className=\"d-flex justify-content-center py-4\">\n <Spinner animation=\"border\" screenReaderText={formatMessage(messages.loadingOrders)} />\n </div>\n );\n } else {\n content = order\n ? <OrderReceipt order={order} />\n : <Alert variant=\"warning\">{formatMessage(messages.orderNotFound)}</Alert>;\n }\n\n return (\n <Container fluid size=\"xl\" className=\"py-4 orderHistory\">\n {content}\n </Container>\n );\n};\n\nexport default OrderHistoryDetails;\n"]}
|
|
1
|
+
{"version":3,"file":"OrderHistoryDet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K,QAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,mBAAmB,YACrD,OAAO,GACE,CACb,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["import type { ReactNode } from 'react';\nimport { useMemo } from 'react';\nimport { useParams } from 'react-router-dom';\nimport { Alert, Breadcrumb, Container, Spinner } from '@openedx/paragon';\nimport { useIntl } from '@openedx/frontend-base';\n\nimport type { MoneyAmount, OrderDetailsData } from '../../types';\nimport { ORDER_HISTORY_PATH } from '../../constants';\nimport getFormattedCurrency from '../../utils/currency';\nimport { useViaxClient, useViaxSession } from '../../data/hooks/useManageQueries';\nimport { useOrderDetailsQuery } from '../../data/hooks/useOrderHistoryQueries';\nimport messages from './messages';\nimport { getOrderSummaryRows, getOrderItemRows } from './data/receiptRows';\nimport { ProgramItemsTable } from './ProgramItemsTable';\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\" role=\"listitem\">\n <dt className=\"font-weight-bold text-gray-700\">{label}</dt>\n <span\n className=\"flex-grow-1 mx-2 text-gray-700\"\n style={{ borderBottom: '1px dotted #B4B1A8' }}\n aria-hidden=\"true\"\n />\n <dd className=\"mb-0\">{children}</dd>\n </div>\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 const currency = String(order.pricing?.total?.currency ?? totals.currency ?? 'USD');\n const money = (amount: unknown): MoneyAmount => ({\n amount: Number.isFinite(Number(amount)) ? Number(amount) : 0,\n currency,\n });\n\n const discounts: any[] | null = Array.isArray(order.pricing?.discounts) ? order.pricing.discounts : null;\n const discountTotal = discounts\n ? discounts.reduce((sum, item) => sum + Number(item?.amount ?? 0), 0)\n : Number(order.totals?.discount ?? order.discount ?? 0);\n const firstDiscount = discounts?.[0];\n const discountCode = normalizeDiscountCode(\n firstDiscount?.code ?? firstDiscount?.offerId ?? order.discountCode ?? null,\n );\n\n const firstItem = Array.isArray(order.items) ? order.items[0] : null;\n const item = firstItem ?? (Array.isArray(order.lines) ? order.lines[0] : null);\n const itemName = String(item?.name ?? item?.productName ?? item?.title ?? order.name ?? 'Order');\n\n const base = {\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 subtotalAmount: money(order.pricing?.subtotal?.amount),\n itemPriceAmount: money(item?.price?.amount),\n discountCode,\n total: money(order.pricing?.total?.amount ?? totals.paid),\n discountAmount: money(discountTotal),\n };\n\n if (firstItem?.kind === 'program') {\n const programCourses: any[] = Array.isArray(firstItem.courses) ? firstItem.courses : [];\n\n return {\n ...base,\n name: String(firstItem.name ?? itemName),\n itemType: 'program',\n items: programCourses.map((entry) => ({\n productId: entry.productId,\n courseRunKey: entry.courseRunKey,\n name: entry.name ?? itemName,\n price: entry.price ?? money(entry.amount),\n discount: entry.discount ?? money(0),\n total: entry.total ?? money(entry.amount),\n })),\n };\n }\n\n return { ...base, name: itemName, itemType: 'course' };\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 discountValue = order.discountAmount ?? { amount: 0, currency: order.total.currency };\n const discountAmount = getFormattedCurrency({\n amount: -Math.abs(discountValue.amount) || 0,\n currency: discountValue.currency,\n });\n\n const orderSummaryRows = getOrderSummaryRows(\n order,\n orderDate,\n subtotal,\n total,\n discountAmount,\n order.discountCode ?? '',\n );\n const orderItemRows = getOrderItemRows(order, itemPrice, total, discountAmount);\n\n const renderRows = (\n rows: typeof orderSummaryRows | typeof orderItemRows,\n listLabel: string,\n ) => (\n <dl className=\"mb-0\" role=\"list\" aria-label={listLabel}>\n {rows.map(({ label, value }) => (\n <ReceiptRow key={label.id} label={formatMessage(label)}>\n {value}\n </ReceiptRow>\n ))}\n </dl>\n );\n\n return (\n <article aria-labelledby=\"order-receipt-title\">\n <div className=\"my-2\">\n <Breadcrumb\n ariaLabel=\"breadcrumb\"\n links={[{ label: formatMessage(messages.orderHistoryTitle), href: `${ORDER_HISTORY_PATH}?tab=payment-history` }]}\n activeLabel={`${formatMessage(messages.orderDateTitle)}: ${orderDate}`}\n />\n </div>\n <h1 id=\"order-receipt-title\" className=\"h1 mb-4 mt-4 text-primary-500 orderHistoryTitle\">\n {formatMessage(messages.orderDateTitle)}: {orderDate}\n </h1>\n\n <section aria-labelledby=\"order-summary-title\">\n <h3 id=\"order-summary-title\" className=\"h3 font-weight-bold mb-3 text-primary-500\">\n {formatMessage(messages.orderSummaryTitle)}\n </h3>\n {renderRows(orderSummaryRows, 'Order summary details')}\n </section>\n\n <hr className=\"my-4 divider\" />\n\n <section aria-labelledby=\"order-items-title\">\n <h3 id=\"order-items-title\" 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, 'Order item details')}\n </section>\n\n <hr className=\"my-4 divider\" />\n\n <section aria-labelledby=\"payment-title\">\n <h3 id=\"payment-title\" className=\"font-weight-bold mb-3 text-primary-500\">\n {formatMessage(messages.paymentTitle)}\n </h3>\n <dl className=\"mb-0\" role=\"list\" aria-label=\"Payment details\">\n <ReceiptRow label={formatMessage(messages.receiptAmountLabel)}>\n {total}\n </ReceiptRow>\n </dl>\n </section>\n </article>\n );\n};\n\nconst OrderHistoryDetails = () => {\n const { formatMessage } = useIntl();\n const { orderNumber } = useParams<{ orderNumber: string }>();\n const client = useViaxClient();\n const { sessionReady } = useViaxSession(client);\n const orderDetailsQuery = useOrderDetailsQuery(client, orderNumber ?? null, sessionReady);\n const order = useMemo(() => normalizeOrderDetails(orderDetailsQuery.data), [orderDetailsQuery.data]);\n\n let content: ReactNode;\n if (orderDetailsQuery.isError) {\n content = <Alert variant=\"danger\">{formatMessage(messages.purchaseHistoryError)}</Alert>;\n } else if (!orderDetailsQuery.isSuccess) {\n content = (\n <div className=\"d-flex justify-content-center py-4\">\n <Spinner animation=\"border\" screenReaderText={formatMessage(messages.loadingOrders)} />\n </div>\n );\n } else {\n content = order\n ? <OrderReceipt order={order} />\n : <Alert variant=\"warning\">{formatMessage(messages.orderNotFound)}</Alert>;\n }\n\n return (\n <Container fluid size=\"xl\" className=\"py-4 orderHistory\">\n {content}\n </Container>\n );\n};\n\nexport default OrderHistoryDetails;\n"]}
|
|
@@ -5,9 +5,7 @@ import { ORDER_DETAILS_PATH } from '../../constants';
|
|
|
5
5
|
import OrderHistoryCard from './OrderHistoryCard';
|
|
6
6
|
const OrdersList = ({ orders, onViewReceipt }) => {
|
|
7
7
|
const navigate = useNavigate();
|
|
8
|
-
return (_jsx("
|
|
9
|
-
// TODO: Enable when paymentMethodType is in the API response.
|
|
10
|
-
isReceiptDisabled: false, onViewReceipt: () => onViewReceipt === null || onViewReceipt === void 0 ? void 0 : onViewReceipt(order), onViewOrderDetails: () => navigate(`${ORDER_DETAILS_PATH}/${encodeURIComponent(order.orderNumber)}`) }) }, order.orderId))) }));
|
|
8
|
+
return (_jsx("ul", { className: "list-unstyled mb-0", role: "list", children: orders.map((order) => (_jsx("li", { className: "mb-3", role: "listitem", children: _jsx(OrderHistoryCard, { title: order.name, purchaseDate: new Date(order.purchasedAt).toLocaleDateString('en-US'), totalCost: getFormattedCurrency(order.total), orderNumber: order.orderNumber, isReceiptDisabled: false, onViewReceipt: () => onViewReceipt === null || onViewReceipt === void 0 ? void 0 : onViewReceipt(order), onViewOrderDetails: () => navigate(`${ORDER_DETAILS_PATH}/${encodeURIComponent(order.orderNumber)}`) }) }, order.orderId))) }));
|
|
11
9
|
};
|
|
12
10
|
export default OrdersList;
|
|
13
11
|
//# sourceMappingURL=OrderList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderList.js","sourceRoot":"","sources":["../../../src/components/OrderHistory/OrderList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,oBAAoB,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAElD,MAAM,UAAU,GAAG,CAAC,EAAE,MAAM,EAAE,aAAa,EAAmB,EAAE,EAAE;IAChE,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAE/B,OAAO,CACL,
|
|
1
|
+
{"version":3,"file":"OrderList.js","sourceRoot":"","sources":["../../../src/components/OrderHistory/OrderList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,oBAAoB,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAElD,MAAM,UAAU,GAAG,CAAC,EAAE,MAAM,EAAE,aAAa,EAAmB,EAAE,EAAE;IAChE,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAE/B,OAAO,CACL,aAAI,SAAS,EAAC,oBAAoB,EAAC,IAAI,EAAC,MAAM,YAC3C,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACrB,aAAwB,SAAS,EAAC,MAAM,EAAC,IAAI,EAAC,UAAU,YACtD,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,EAC9B,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,GAAG,kBAAkB,IAAI,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,GACpG,IATK,KAAK,CAAC,OAAO,CAUjB,CACN,CAAC,GACC,CACN,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { useNavigate } from 'react-router-dom';\n\nimport getFormattedCurrency from '../../utils/currency';\nimport type { OrdersListProps } from '../../types';\nimport { ORDER_DETAILS_PATH } from '../../constants';\nimport OrderHistoryCard from './OrderHistoryCard';\n\nconst OrdersList = ({ orders, onViewReceipt }: OrdersListProps) => {\n const navigate = useNavigate();\n\n return (\n <ul className=\"list-unstyled mb-0\" role=\"list\">\n {orders.map((order) => (\n <li key={order.orderId} className=\"mb-3\" role=\"listitem\">\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={false}\n onViewReceipt={() => onViewReceipt?.(order)}\n onViewOrderDetails={() => navigate(`${ORDER_DETAILS_PATH}/${encodeURIComponent(order.orderNumber)}`)}\n />\n </li>\n ))}\n </ul>\n );\n};\n\nexport default OrdersList;\n"]}
|
|
@@ -9,13 +9,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { Alert, Spinner } from '@openedx/paragon';
|
|
12
|
-
import { useIntl } from '@openedx/frontend-base';
|
|
12
|
+
import { getAppConfig, useIntl } from '@openedx/frontend-base';
|
|
13
|
+
import { appId } from '../../constants';
|
|
13
14
|
import { getStripePaymentReceipt } from '../../data/services/orderHistory/orderHistory';
|
|
14
15
|
import { usePurchaseHistoryQuery } from '../../data/hooks/useOrderHistoryQueries';
|
|
15
16
|
import { useViaxClient, useViaxSession } from '../../data/hooks/useManageQueries';
|
|
16
17
|
import OrdersList from './OrderList';
|
|
17
18
|
import RefundNotice from '../RefundNotice/RefundNotice';
|
|
18
19
|
import messages from './messages';
|
|
20
|
+
const getPaypalReceiptUrl = () => {
|
|
21
|
+
const config = getAppConfig(appId);
|
|
22
|
+
const paypalReceiptUrl = config.PAYPAL_RECEIPT_URL;
|
|
23
|
+
if (typeof paypalReceiptUrl !== 'string') {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return paypalReceiptUrl.trim() || null;
|
|
27
|
+
};
|
|
19
28
|
/** One-off course and program purchases, shown in the payment history tab. */
|
|
20
29
|
const OrderPurchases = () => {
|
|
21
30
|
var _a;
|
|
@@ -25,20 +34,34 @@ const OrderPurchases = () => {
|
|
|
25
34
|
const purchaseHistoryQuery = usePurchaseHistoryQuery(client, sessionReady);
|
|
26
35
|
const orders = (_a = purchaseHistoryQuery.data) !== null && _a !== void 0 ? _a : [];
|
|
27
36
|
const handleViewReceipt = (order) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
var _a, _b, _c;
|
|
28
38
|
if (!client || !order.orderId) {
|
|
29
39
|
return;
|
|
30
40
|
}
|
|
31
41
|
try {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
const paymentMethodType = ((_b = (_a = order.paymentMethod) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : '').toLowerCase();
|
|
43
|
+
const isNotAppleOrGooglePay = !((_c = order.paymentMethod) === null || _c === void 0 ? void 0 : _c.wallet);
|
|
44
|
+
if (paymentMethodType === 'paypal') {
|
|
45
|
+
const paypalReceiptUrl = getPaypalReceiptUrl();
|
|
46
|
+
if (!paypalReceiptUrl) {
|
|
47
|
+
console.error('PayPal receipt URL is not configured.');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
window.open(paypalReceiptUrl, '_blank', 'noopener,noreferrer');
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
else if (paymentMethodType === 'card' && isNotAppleOrGooglePay) {
|
|
54
|
+
const receiptUrl = yield getStripePaymentReceipt(client.gql, order.orderId);
|
|
55
|
+
if (receiptUrl) {
|
|
56
|
+
window.open(receiptUrl, '_blank', 'noopener,noreferrer');
|
|
57
|
+
}
|
|
35
58
|
}
|
|
36
59
|
}
|
|
37
60
|
catch (error) {
|
|
38
61
|
console.error('Unable to load payment receipt.', error);
|
|
39
62
|
}
|
|
40
63
|
});
|
|
41
|
-
return (_jsxs("section", { className: "manage-section mt-5", "aria-labelledby": "order-purchases-title", children: [_jsx("h2", { id: "order-purchases-title", className: "manage-section__title h3 font-weight-bold text-primary-500 mb-1", children: formatMessage(messages.otherPurchasesTitle) }), purchaseHistoryQuery.isError && (_jsx(Alert, { variant: "danger", children: formatMessage(messages.purchaseHistoryError) })), !purchaseHistoryQuery.isError && !purchaseHistoryQuery.isSuccess && (_jsx("div", { className: "d-flex justify-content-center py-4", children: _jsx(Spinner, { animation: "border", screenReaderText: formatMessage(messages.loadingOrders) }) })), purchaseHistoryQuery.isSuccess && orders.length === 0 && (_jsx("p", { className: "manage-section__subtitle text-gray-700 mb-3", children: formatMessage(messages.coursePurchasesEmptyMessage) })), purchaseHistoryQuery.isSuccess && orders.length > 0 && (_jsxs(_Fragment, { children: [_jsx(OrdersList, { orders: orders, onViewReceipt: handleViewReceipt }), _jsx(RefundNotice, {})] }))] }));
|
|
64
|
+
return (_jsxs("section", { className: "manage-section mt-5", "aria-labelledby": "order-purchases-title", "aria-live": "polite", "aria-busy": purchaseHistoryQuery.isLoading || purchaseHistoryQuery.isFetching, children: [_jsx("h2", { id: "order-purchases-title", className: "manage-section__title h3 font-weight-bold text-primary-500 mb-1", children: formatMessage(messages.otherPurchasesTitle) }), purchaseHistoryQuery.isError && (_jsx(Alert, { variant: "danger", children: formatMessage(messages.purchaseHistoryError) })), !purchaseHistoryQuery.isError && !purchaseHistoryQuery.isSuccess && (_jsx("div", { className: "d-flex justify-content-center py-4", children: _jsx(Spinner, { animation: "border", screenReaderText: formatMessage(messages.loadingOrders) }) })), purchaseHistoryQuery.isSuccess && orders.length === 0 && (_jsx("p", { className: "manage-section__subtitle text-gray-700 mb-3", children: formatMessage(messages.coursePurchasesEmptyMessage) })), purchaseHistoryQuery.isSuccess && orders.length > 0 && (_jsxs(_Fragment, { children: [_jsx(OrdersList, { orders: orders, onViewReceipt: handleViewReceipt }), _jsx(RefundNotice, {})] }))] }));
|
|
42
65
|
};
|
|
43
66
|
export default OrderPurchases;
|
|
44
67
|
//# sourceMappingURL=OrderPurchases.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderPurchases.js","sourceRoot":"","sources":["../../../src/components/OrderHistory/OrderPurchases.tsx"],"names":[],"mappings":";;;;;;;;;;AACA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClD,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AQ,eACP,oBAAoB,CAAC,SAAS,IAAI,oBAAoB,CAAC,UAAU,aAE5E,aAAI,EAAE,EAAC,uBAAuB,EAAC,SAAS,EAAC,iEAAiE,YACvG,aAAa,CAAC,QAAQ,CAAC,mBAAmB,CAAC,GACzC,EAEJ,oBAAoB,CAAC,OAAO,IAAI,CAC/B,KAAC,KAAK,IAAC,OAAO,EAAC,QAAQ,YAAE,aAAa,CAAC,QAAQ,CAAC,oBAAoB,CAAC,GAAS,CAC/E,EAEA,CAAC,oBAAoB,CAAC,OAAO,IAAI,CAAC,oBAAoB,CAAC,SAAS,IAAI,CACnE,cAAK,SAAS,EAAC,oCAAoC,YACjD,KAAC,OAAO,IAAC,SAAS,EAAC,QAAQ,EAAC,gBAAgB,EAAE,aAAa,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAI,GACnF,CACP,EAEA,oBAAoB,CAAC,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,CACxD,YAAG,SAAS,EAAC,6CAA6C,YACvD,aAAa,CAAC,QAAQ,CAAC,2BAA2B,CAAC,GAClD,CACL,EAEA,oBAAoB,CAAC,SAAS,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,CACtD,8BACE,KAAC,UAAU,IAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,iBAAiB,GAAI,EAChE,KAAC,YAAY,KAAG,IACf,CACJ,IACO,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import React from 'react';\nimport { Alert, Spinner } from '@openedx/paragon';\nimport { getAppConfig, useIntl } from '@openedx/frontend-base';\n\nimport type { PurchaseHistoryItem } from '../../types';\nimport { appId } from '../../constants';\nimport { getStripePaymentReceipt } from '../../data/services/orderHistory/orderHistory';\nimport { usePurchaseHistoryQuery } from '../../data/hooks/useOrderHistoryQueries';\nimport { useViaxClient, useViaxSession } from '../../data/hooks/useManageQueries';\nimport OrdersList from './OrderList';\nimport RefundNotice from '../RefundNotice/RefundNotice';\nimport messages from './messages';\n\nconst getPaypalReceiptUrl = (): string | null => {\n const config = getAppConfig(appId) as { PAYPAL_RECEIPT_URL?: string };\n const paypalReceiptUrl = config.PAYPAL_RECEIPT_URL;\n\n if (typeof paypalReceiptUrl !== 'string') {\n return null;\n }\n\n return paypalReceiptUrl.trim() || null;\n};\n\n/** One-off course and program purchases, shown in the payment history tab. */\nconst OrderPurchases: React.FC = () => {\n const { formatMessage } = useIntl();\n const client = useViaxClient();\n const { sessionReady } = useViaxSession(client);\n const purchaseHistoryQuery = usePurchaseHistoryQuery(client, sessionReady);\n const orders = purchaseHistoryQuery.data ?? [];\n\n const handleViewReceipt = async (order: PurchaseHistoryItem) => {\n if (!client || !order.orderId) {\n return;\n }\n\n try {\n const paymentMethodType = (order.paymentMethod?.type ?? '').toLowerCase();\n const isNotAppleOrGooglePay = !order.paymentMethod?.wallet;\n\n if (paymentMethodType === 'paypal') {\n const paypalReceiptUrl = getPaypalReceiptUrl();\n if (!paypalReceiptUrl) {\n console.error('PayPal receipt URL is not configured.');\n return;\n }\n\n window.open(paypalReceiptUrl, '_blank', 'noopener,noreferrer');\n return;\n } else if (paymentMethodType === 'card' && isNotAppleOrGooglePay) {\n const receiptUrl = await getStripePaymentReceipt(client.gql, order.orderId);\n if (receiptUrl) {\n window.open(receiptUrl, '_blank', 'noopener,noreferrer');\n }\n }\n } catch (error) {\n console.error('Unable to load payment receipt.', error);\n }\n };\n\n return (\n <section\n className=\"manage-section mt-5\"\n aria-labelledby=\"order-purchases-title\"\n aria-live=\"polite\"\n aria-busy={purchaseHistoryQuery.isLoading || purchaseHistoryQuery.isFetching}\n >\n <h2 id=\"order-purchases-title\" className=\"manage-section__title h3 font-weight-bold text-primary-500 mb-1\">\n {formatMessage(messages.otherPurchasesTitle)}\n </h2>\n\n {purchaseHistoryQuery.isError && (\n <Alert variant=\"danger\">{formatMessage(messages.purchaseHistoryError)}</Alert>\n )}\n\n {!purchaseHistoryQuery.isError && !purchaseHistoryQuery.isSuccess && (\n <div className=\"d-flex justify-content-center py-4\">\n <Spinner animation=\"border\" screenReaderText={formatMessage(messages.loadingOrders)} />\n </div>\n )}\n\n {purchaseHistoryQuery.isSuccess && orders.length === 0 && (\n <p className=\"manage-section__subtitle text-gray-700 mb-3\">\n {formatMessage(messages.coursePurchasesEmptyMessage)}\n </p>\n )}\n\n {purchaseHistoryQuery.isSuccess && orders.length > 0 && (\n <>\n <OrdersList orders={orders} onViewReceipt={handleViewReceipt} />\n <RefundNotice />\n </>\n )}\n </section>\n );\n};\n\nexport default OrderPurchases;\n"]}
|
|
@@ -114,5 +114,30 @@ declare const messages: {
|
|
|
114
114
|
defaultMessage: string;
|
|
115
115
|
description: string;
|
|
116
116
|
};
|
|
117
|
+
viewReceiptButton: {
|
|
118
|
+
id: string;
|
|
119
|
+
defaultMessage: string;
|
|
120
|
+
description: string;
|
|
121
|
+
};
|
|
122
|
+
viewOrderDetailsButton: {
|
|
123
|
+
id: string;
|
|
124
|
+
defaultMessage: string;
|
|
125
|
+
description: string;
|
|
126
|
+
};
|
|
127
|
+
dateOfPurchaseLabel: {
|
|
128
|
+
id: string;
|
|
129
|
+
defaultMessage: string;
|
|
130
|
+
description: string;
|
|
131
|
+
};
|
|
132
|
+
totalCostLabel: {
|
|
133
|
+
id: string;
|
|
134
|
+
defaultMessage: string;
|
|
135
|
+
description: string;
|
|
136
|
+
};
|
|
137
|
+
orderNumberLabel: {
|
|
138
|
+
id: string;
|
|
139
|
+
defaultMessage: string;
|
|
140
|
+
description: string;
|
|
141
|
+
};
|
|
117
142
|
};
|
|
118
143
|
export default messages;
|
|
@@ -115,6 +115,31 @@ const messages = defineMessages({
|
|
|
115
115
|
defaultMessage: 'Total after discount',
|
|
116
116
|
description: 'Program order items table header for the total after discount column',
|
|
117
117
|
},
|
|
118
|
+
viewReceiptButton: {
|
|
119
|
+
id: 'viewReceiptButton',
|
|
120
|
+
defaultMessage: 'View receipt',
|
|
121
|
+
description: 'Button text for viewing a payment receipt',
|
|
122
|
+
},
|
|
123
|
+
viewOrderDetailsButton: {
|
|
124
|
+
id: 'viewOrderDetailsButton',
|
|
125
|
+
defaultMessage: 'View order details',
|
|
126
|
+
description: 'Button text for viewing order details',
|
|
127
|
+
},
|
|
128
|
+
dateOfPurchaseLabel: {
|
|
129
|
+
id: 'dateOfPurchaseLabel',
|
|
130
|
+
defaultMessage: 'Date of purchase',
|
|
131
|
+
description: 'Label for the date of purchase in the order history card',
|
|
132
|
+
},
|
|
133
|
+
totalCostLabel: {
|
|
134
|
+
id: 'totalCostLabel',
|
|
135
|
+
defaultMessage: 'Total cost',
|
|
136
|
+
description: 'Label for the total cost in the order history card',
|
|
137
|
+
},
|
|
138
|
+
orderNumberLabel: {
|
|
139
|
+
id: 'orderNumberLabel',
|
|
140
|
+
defaultMessage: 'Order number',
|
|
141
|
+
description: 'Label for the order number in the order history card',
|
|
142
|
+
},
|
|
118
143
|
});
|
|
119
144
|
export default messages;
|
|
120
145
|
//# sourceMappingURL=messages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/components/OrderHistory/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,QAAQ,GAAG,cAAc,CAAC;IAC9B,iBAAiB,EAAE;QACjB,EAAE,EAAE,mBAAmB;QACvB,cAAc,EAAE,eAAe;QAC/B,WAAW,EAAE,2BAA2B;KACzC;IACD,mBAAmB,EAAE;QACnB,EAAE,EAAE,iDAAiD;QACrD,cAAc,EAAE,iBAAiB;QACjC,WAAW,EAAE,yDAAyD;KACvE;IACD,2BAA2B,EAAE;QAC3B,EAAE,EAAE,0CAA0C;QAC9C,cAAc,EAAE,oHAAoH;QACpI,WAAW,EAAE,8DAA8D;KAC5E;IACD,aAAa,EAAE;QACb,EAAE,EAAE,4BAA4B;QAChC,cAAc,EAAE,iBAAiB;QACjC,WAAW,EAAE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WAAW,EAAE,4CAA4C;KAC1D;IACD,gBAAgB,EAAE;QAChB,EAAE,EAAE,kBAAkB;QACtB,cAAc,EAAE,OAAO;QACvB,WAAW,EAAE,iCAAiC;KAC/C;IACD,iBAAiB,EAAE;QACjB,EAAE,EAAE,mBAAmB;QACvB,cAAc,EAAE,QAAQ;QACxB,WAAW,EAAE,kCAAkC;KAChD;IACD,kBAAkB,EAAE;QAClB,EAAE,EAAE,oBAAoB;QACxB,cAAc,EAAE,SAAS;QACzB,WAAW,EAAE,sCAAsC;KACpD;IACD,wBAAwB,EAAE;QACxB,EAAE,EAAE,0BAA0B;QAC9B,cAAc,EAAE,QAAQ;QACxB,WAAW,EAAE,6DAA6D;KAC3E;IACD,uBAAuB,EAAE;QACvB,EAAE,EAAE,yBAAyB;QAC7B,cAAc,EAAE,OAAO;QACvB,WAAW,EAAE,8DAA8D;KAC5E;IACD,gCAAgC,EAAE;QAChC,EAAE,EAAE,kCAAkC;QACtC,cAAc,EAAE,iBAAiB;QACjC,WAAW,EAAE,iEAAiE;KAC/E;IACD,oCAAoC,EAAE;QACpC,EAAE,EAAE,sCAAsC;QAC1C,cAAc,EAAE,sBAAsB;QACtC,WAAW,EAAE,sEAAsE;KACpF;CACF,CAAC,CAAC;AAEH,eAAe,QAAQ,CAAC","sourcesContent":["import { defineMessages } from '@openedx/frontend-base';\n\nconst messages = defineMessages({\n orderHistoryTitle: {\n id: 'orderHistoryTitle',\n defaultMessage: 'Order History',\n description: 'Heading for order history',\n },\n otherPurchasesTitle: {\n id: 'orderHistory.coursePayments.otherPurchasesTitle',\n defaultMessage: 'Other purchases',\n description: 'Heading above the list of course and program 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 loadingOrders: {\n id: 'orderHistory.loadingOrders',\n defaultMessage: 'Loading orders…',\n description: 'Loading state while the order history is fetched',\n },\n purchaseHistoryError: {\n id: 'orderHistory.purchaseHistoryError',\n defaultMessage: 'We could not load your orders. Please try again later.',\n description: 'Error alert when the order history fails to load',\n },\n orderNotFound: {\n id: 'orderHistory.orderNotFound',\n defaultMessage: 'We could not find this order.',\n description: 'Shown on the order details page when no matching order exists',\n },\n orderDateTitle: {\n id: 'orderDateTitle',\n defaultMessage: 'Order date',\n description: 'Label for order date',\n },\n orderSummaryTitle: {\n id: 'orderSummaryTitle',\n defaultMessage: 'Order summary',\n description: 'Heading for order summary section',\n },\n orderItemsTitle: {\n id: 'orderItemsTitle',\n defaultMessage: 'Order items',\n description: 'Heading for order items section',\n },\n paymentTitle: {\n id: 'paymentTitle',\n defaultMessage: 'Payment',\n description: 'Heading for payment section',\n },\n receiptOrderNumberLabel: {\n id: 'receiptOrderNumberLabel',\n defaultMessage: 'Order number:',\n description: 'Receipt label for the order number',\n },\n receiptOrderDateLabel: {\n id: 'receiptOrderDateLabel',\n defaultMessage: 'Order date:',\n description: 'Receipt label for the order date',\n },\n receiptSubtotalLabel: {\n id: 'receiptSubtotalLabel',\n defaultMessage: 'Subtotal:',\n description: 'Receipt label for the subtotal amount',\n },\n receiptDiscountCodeLabel: {\n id: 'receiptDiscountCodeLabel',\n defaultMessage: 'Discount code:',\n description: 'Receipt label for the discount code',\n },\n receiptDiscountAmountLabel: {\n id: 'receiptDiscountAmountLabel',\n defaultMessage: 'Discount amount:',\n description: 'Receipt label for the discount amount',\n },\n receiptTotalAfterDiscountLabel: {\n id: 'receiptTotalAfterDiscountLabel',\n defaultMessage: 'Total after discount:',\n description: 'Receipt label for the total after discount',\n },\n receiptNameLabel: {\n id: 'receiptNameLabel',\n defaultMessage: 'Name:',\n description: 'Receipt label for the item name',\n },\n receiptPriceLabel: {\n id: 'receiptPriceLabel',\n defaultMessage: 'Price:',\n description: 'Receipt label for the item price',\n },\n receiptAmountLabel: {\n id: 'receiptAmountLabel',\n defaultMessage: 'Amount:',\n description: 'Receipt label for the payment amount',\n },\n receiptTableCourseHeader: {\n id: 'receiptTableCourseHeader',\n defaultMessage: 'Course',\n description: 'Program order items table header for the course name column',\n },\n receiptTablePriceHeader: {\n id: 'receiptTablePriceHeader',\n defaultMessage: 'Price',\n description: 'Program order items table header for the course price column',\n },\n receiptTableDiscountAmountHeader: {\n id: 'receiptTableDiscountAmountHeader',\n defaultMessage: 'Discount amount',\n description: 'Program order items table header for the discount amount column',\n },\n receiptTableTotalAfterDiscountHeader: {\n id: 'receiptTableTotalAfterDiscountHeader',\n defaultMessage: 'Total after discount',\n description: 'Program order items table header for the total after discount column',\n },\n});\n\nexport default messages;\n"]}
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/components/OrderHistory/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,QAAQ,GAAG,cAAc,CAAC;IAC9B,iBAAiB,EAAE;QACjB,EAAE,EAAE,mBAAmB;QACvB,cAAc,EAAE,eAAe;QAC/B,WAAW,EAAE,2BAA2B;KACzC;IACD,mBAAmB,EAAE;QACnB,EAAE,EAAE,iDAAiD;QACrD,cAAc,EAAE,iBAAiB;QACjC,WAAW,EAAE,yDAAyD;KACvE;IACD,2BAA2B,EAAE;QAC3B,EAAE,EAAE,0CAA0C;QAC9C,cAAc,EAAE,oHAAoH;QACpI,WAAW,EAAE,8DAA8D;KAC5E;IACD,aAAa,EAAE;QACb,EAAE,EAAE,4BAA4B;QAChC,cAAc,EAAE,iBAAiB;QACjC,WAAW,EAAE,kDAAkD;KAChE;IACD,oBAAoB,EAAE;QACpB,EAAE,EAAE,mCAAmC;QACvC,cAAc,EAAE,wDAAwD;QACxE,WAAW,EAAE,kDAAkD;KAChE;IACD,aAAa,EAAE;QACb,EAAE,EAAE,4BAA4B;QAChC,cAAc,EAAE,+BAA+B;QAC/C,WAAW,EAAE,+DAA+D;KAC7E;IACD,cAAc,EAAE;QACd,EAAE,EAA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AClB,EAAE,EAAE,oBAAoB;QACxB,cAAc,EAAE,SAAS;QACzB,WAAW,EAAE,sCAAsC;KACpD;IACD,wBAAwB,EAAE;QACxB,EAAE,EAAE,0BAA0B;QAC9B,cAAc,EAAE,QAAQ;QACxB,WAAW,EAAE,6DAA6D;KAC3E;IACD,uBAAuB,EAAE;QACvB,EAAE,EAAE,yBAAyB;QAC7B,cAAc,EAAE,OAAO;QACvB,WAAW,EAAE,8DAA8D;KAC5E;IACD,gCAAgC,EAAE;QAChC,EAAE,EAAE,kCAAkC;QACtC,cAAc,EAAE,iBAAiB;QACjC,WAAW,EAAE,iEAAiE;KAC/E;IACD,oCAAoC,EAAE;QACpC,EAAE,EAAE,sCAAsC;QAC1C,cAAc,EAAE,sBAAsB;QACtC,WAAW,EAAE,sEAAsE;KACpF;IACD,iBAAiB,EAAE;QACjB,EAAE,EAAE,mBAAmB;QACvB,cAAc,EAAE,cAAc;QAC9B,WAAW,EAAE,2CAA2C;KACzD;IACD,sBAAsB,EAAE;QACtB,EAAE,EAAE,wBAAwB;QAC5B,cAAc,EAAE,oBAAoB;QACpC,WAAW,EAAE,uCAAuC;KACrD;IACD,mBAAmB,EAAE;QACnB,EAAE,EAAE,qBAAqB;QACzB,cAAc,EAAE,kBAAkB;QAClC,WAAW,EAAE,0DAA0D;KACxE;IACD,cAAc,EAAE;QACd,EAAE,EAAE,gBAAgB;QACpB,cAAc,EAAE,YAAY;QAC5B,WAAW,EAAE,oDAAoD;KAClE;IACD,gBAAgB,EAAE;QAChB,EAAE,EAAE,kBAAkB;QACtB,cAAc,EAAE,cAAc;QAC9B,WAAW,EAAE,sDAAsD;KACpE;CACF,CAAC,CAAC;AAEH,eAAe,QAAQ,CAAC","sourcesContent":["import { defineMessages } from '@openedx/frontend-base';\n\nconst messages = defineMessages({\n orderHistoryTitle: {\n id: 'orderHistoryTitle',\n defaultMessage: 'Order History',\n description: 'Heading for order history',\n },\n otherPurchasesTitle: {\n id: 'orderHistory.coursePayments.otherPurchasesTitle',\n defaultMessage: 'Other purchases',\n description: 'Heading above the list of course and program 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 loadingOrders: {\n id: 'orderHistory.loadingOrders',\n defaultMessage: 'Loading orders…',\n description: 'Loading state while the order history is fetched',\n },\n purchaseHistoryError: {\n id: 'orderHistory.purchaseHistoryError',\n defaultMessage: 'We could not load your orders. Please try again later.',\n description: 'Error alert when the order history fails to load',\n },\n orderNotFound: {\n id: 'orderHistory.orderNotFound',\n defaultMessage: 'We could not find this order.',\n description: 'Shown on the order details page when no matching order exists',\n },\n orderDateTitle: {\n id: 'orderDateTitle',\n defaultMessage: 'Order date',\n description: 'Label for order date',\n },\n orderSummaryTitle: {\n id: 'orderSummaryTitle',\n defaultMessage: 'Order summary',\n description: 'Heading for order summary section',\n },\n orderItemsTitle: {\n id: 'orderItemsTitle',\n defaultMessage: 'Order items',\n description: 'Heading for order items section',\n },\n paymentTitle: {\n id: 'paymentTitle',\n defaultMessage: 'Payment',\n description: 'Heading for payment section',\n },\n receiptOrderNumberLabel: {\n id: 'receiptOrderNumberLabel',\n defaultMessage: 'Order number:',\n description: 'Receipt label for the order number',\n },\n receiptOrderDateLabel: {\n id: 'receiptOrderDateLabel',\n defaultMessage: 'Order date:',\n description: 'Receipt label for the order date',\n },\n receiptSubtotalLabel: {\n id: 'receiptSubtotalLabel',\n defaultMessage: 'Subtotal:',\n description: 'Receipt label for the subtotal amount',\n },\n receiptDiscountCodeLabel: {\n id: 'receiptDiscountCodeLabel',\n defaultMessage: 'Discount code:',\n description: 'Receipt label for the discount code',\n },\n receiptDiscountAmountLabel: {\n id: 'receiptDiscountAmountLabel',\n defaultMessage: 'Discount amount:',\n description: 'Receipt label for the discount amount',\n },\n receiptTotalAfterDiscountLabel: {\n id: 'receiptTotalAfterDiscountLabel',\n defaultMessage: 'Total after discount:',\n description: 'Receipt label for the total after discount',\n },\n receiptNameLabel: {\n id: 'receiptNameLabel',\n defaultMessage: 'Name:',\n description: 'Receipt label for the item name',\n },\n receiptPriceLabel: {\n id: 'receiptPriceLabel',\n defaultMessage: 'Price:',\n description: 'Receipt label for the item price',\n },\n receiptAmountLabel: {\n id: 'receiptAmountLabel',\n defaultMessage: 'Amount:',\n description: 'Receipt label for the payment amount',\n },\n receiptTableCourseHeader: {\n id: 'receiptTableCourseHeader',\n defaultMessage: 'Course',\n description: 'Program order items table header for the course name column',\n },\n receiptTablePriceHeader: {\n id: 'receiptTablePriceHeader',\n defaultMessage: 'Price',\n description: 'Program order items table header for the course price column',\n },\n receiptTableDiscountAmountHeader: {\n id: 'receiptTableDiscountAmountHeader',\n defaultMessage: 'Discount amount',\n description: 'Program order items table header for the discount amount column',\n },\n receiptTableTotalAfterDiscountHeader: {\n id: 'receiptTableTotalAfterDiscountHeader',\n defaultMessage: 'Total after discount',\n description: 'Program order items table header for the total after discount column',\n },\n viewReceiptButton: {\n id: 'viewReceiptButton',\n defaultMessage: 'View receipt',\n description: 'Button text for viewing a payment receipt',\n },\n viewOrderDetailsButton: {\n id: 'viewOrderDetailsButton',\n defaultMessage: 'View order details',\n description: 'Button text for viewing order details',\n },\n dateOfPurchaseLabel: {\n id: 'dateOfPurchaseLabel',\n defaultMessage: 'Date of purchase',\n description: 'Label for the date of purchase in the order history card',\n },\n totalCostLabel: {\n id: 'totalCostLabel',\n defaultMessage: 'Total cost',\n description: 'Label for the total cost in the order history card',\n },\n orderNumberLabel: {\n id: 'orderNumberLabel',\n defaultMessage: 'Order number',\n description: 'Label for the order number in the order history card',\n },\n});\n\nexport default messages;\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -115,7 +115,12 @@ export interface PurchaseHistoryItem {
|
|
|
115
115
|
orderNumber: string;
|
|
116
116
|
purchasedAt: string;
|
|
117
117
|
paymentIntentId?: string;
|
|
118
|
-
|
|
118
|
+
paymentMethod?: {
|
|
119
|
+
type?: string;
|
|
120
|
+
brand?: string;
|
|
121
|
+
last4?: string;
|
|
122
|
+
wallet?: string;
|
|
123
|
+
} | null;
|
|
119
124
|
name: string;
|
|
120
125
|
total: {
|
|
121
126
|
amount: number;
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG","sourcesContent":["/**\n * Manage Subscription — domain types for Viax subscriber + enrollment data.\n */\n\n/** GraphQL runner used by VIAX fetchers. */\nexport type GqlRunner = (\n query: string,\n variables?: Record<string, unknown>,\n) => Promise<any>;\n\n/** Result of `tIsCurrentUserSubscriber` (JSON scalar). */\nexport interface CurrentUserSubscriberResult {\n /** Has/expects access — drive manage vs upsell messaging. */\n isSubscriber: boolean,\n /** Enrollable right now (ACTIVE / TRIAL_ACTIVE). */\n canEnroll: boolean,\n subscriptionBiId: string | null,\n /**\n * Every subscription the learner has held (all statuses, newest first),\n * e.g. a cancelled Stripe one plus a newer PayPal one. Payment history\n * lists invoices across all of them. Empty until the API returns it.\n */\n subscriptionBiIds?: string[],\n status: string | null,\n currentPeriodEnd: string | null,\n subscriptionStartDate: string | null,\n subscriptionEndDate: string | null,\n /**\n * Billing cycle / plan label used by UI (from `billingFrequency`,\n * `renewalType`, or `planName` on the API payload).\n */\n renewalType?: string | null,\n /** Optional cancel timestamp when present. */\n canceledAt?: string | null,\n /** Optional price display amount when present. */\n amount?: string | null,\n currency?: string | null,\n /**\n * Billing-plan fallback fields used when `renewalType` is missing\n * (e.g. PayPal payloads). See `resolvePlanLabel`.\n */\n billingPlanUid?: string | null,\n interval?: string | null,\n billingInterval?: string | null,\n bipOwnershipModel?: { uid?: string, omName?: string } | null,\n}\n\n/** Normalized enrollment for the cancel confirmation course list. */\nexport interface SubscriptionEnrollment {\n biId: string,\n courseMaId: string | null,\n courseName: string | null,\n courseSlug: string | null,\n /** Course card / thumbnail image. */\n imageUrl: string | null,\n orgName: string | null,\n orgLogoUrl: string | null,\n courseRunKey: string | null,\n /** TwouEnrollment bpStatus.code (ACTIVE, COMPLETED, …). */\n status: string | null,\n /** True when the enrollment has a certificate id and/or URL. */\n hasCertificate: boolean,\n /** Absolute certificate link (`COURSES_BASE_URL` + `tCertificateUrl`). */\n certificateUrl: string | null,\n}\n\nexport type PaymentProcessor = 'stripe' | 'paypal';\n\n/** Normalized invoice row for the Payment history tab. */\nexport interface PaymentHistoryItem {\n biId: string,\n /** Display order number, e.g. EDX-BI3X25N5SY30OSIK */\n orderNumber: string,\n stripeInvoiceId: string | null,\n /** PayPal sale id, or `trial:<PayPal subscription id>` for a $0 trial row. */\n paypalInvoiceId: string | null,\n /** Which processor billed this invoice; null when neither id is set. */\n paymentProcessor: PaymentProcessor | null,\n status: string | null,\n billDate: string | null,\n periodStart: string | null,\n periodEnd: string | null,\n /** Charged amount in major currency units (e.g. 59.00). */\n amount: number,\n currency: string,\n isTrial: boolean,\n}\n\n/** UI view derived from subscriber status. */\nexport type SubscriptionView =\n | 'none'\n | 'active'\n | 'canceled_access'\n | 'canceled_expired';\n\nexport type ManageTab = 'subscription' | 'payment-history';\n\nexport type BillingCycle = 'monthly' | 'annual';\n\nexport interface BillingPlanOwnershipModel {\n uid: string,\n omName: string,\n}\n\n/** Normalized row from `filterCustomerBillingPlan`. */\nexport interface BillingPlan {\n uid: string,\n stripePriceId: string,\n /** Price amount e.g. \"39.99\" */\n amount: string,\n /** Currency code e.g. \"USD\" */\n currency: string,\n isTemplate: boolean,\n ownershipModel: BillingPlanOwnershipModel,\n}\n\nexport interface BillingPlansResult {\n plans: BillingPlan[],\n}\n\n/** One course line on a program purchase receipt. */\nexport interface PurchaseHistoryCourse {\n courseId: string,\n name: string,\n price: number,\n discountAmount: number,\n}\n\n/** One-off course or program purchase from `tOrderHistory.orders`. */\nexport interface PurchaseHistoryItem {\n orderId: string,\n orderNumber: string,\n purchasedAt: string,\n paymentIntentId?: string,\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG","sourcesContent":["/**\n * Manage Subscription — domain types for Viax subscriber + enrollment data.\n */\n\n/** GraphQL runner used by VIAX fetchers. */\nexport type GqlRunner = (\n query: string,\n variables?: Record<string, unknown>,\n) => Promise<any>;\n\n/** Result of `tIsCurrentUserSubscriber` (JSON scalar). */\nexport interface CurrentUserSubscriberResult {\n /** Has/expects access — drive manage vs upsell messaging. */\n isSubscriber: boolean,\n /** Enrollable right now (ACTIVE / TRIAL_ACTIVE). */\n canEnroll: boolean,\n subscriptionBiId: string | null,\n /**\n * Every subscription the learner has held (all statuses, newest first),\n * e.g. a cancelled Stripe one plus a newer PayPal one. Payment history\n * lists invoices across all of them. Empty until the API returns it.\n */\n subscriptionBiIds?: string[],\n status: string | null,\n currentPeriodEnd: string | null,\n subscriptionStartDate: string | null,\n subscriptionEndDate: string | null,\n /**\n * Billing cycle / plan label used by UI (from `billingFrequency`,\n * `renewalType`, or `planName` on the API payload).\n */\n renewalType?: string | null,\n /** Optional cancel timestamp when present. */\n canceledAt?: string | null,\n /** Optional price display amount when present. */\n amount?: string | null,\n currency?: string | null,\n /**\n * Billing-plan fallback fields used when `renewalType` is missing\n * (e.g. PayPal payloads). See `resolvePlanLabel`.\n */\n billingPlanUid?: string | null,\n interval?: string | null,\n billingInterval?: string | null,\n bipOwnershipModel?: { uid?: string, omName?: string } | null,\n}\n\n/** Normalized enrollment for the cancel confirmation course list. */\nexport interface SubscriptionEnrollment {\n biId: string,\n courseMaId: string | null,\n courseName: string | null,\n courseSlug: string | null,\n /** Course card / thumbnail image. */\n imageUrl: string | null,\n orgName: string | null,\n orgLogoUrl: string | null,\n courseRunKey: string | null,\n /** TwouEnrollment bpStatus.code (ACTIVE, COMPLETED, …). */\n status: string | null,\n /** True when the enrollment has a certificate id and/or URL. */\n hasCertificate: boolean,\n /** Absolute certificate link (`COURSES_BASE_URL` + `tCertificateUrl`). */\n certificateUrl: string | null,\n}\n\nexport type PaymentProcessor = 'stripe' | 'paypal';\n\n/** Normalized invoice row for the Payment history tab. */\nexport interface PaymentHistoryItem {\n biId: string,\n /** Display order number, e.g. EDX-BI3X25N5SY30OSIK */\n orderNumber: string,\n stripeInvoiceId: string | null,\n /** PayPal sale id, or `trial:<PayPal subscription id>` for a $0 trial row. */\n paypalInvoiceId: string | null,\n /** Which processor billed this invoice; null when neither id is set. */\n paymentProcessor: PaymentProcessor | null,\n status: string | null,\n billDate: string | null,\n periodStart: string | null,\n periodEnd: string | null,\n /** Charged amount in major currency units (e.g. 59.00). */\n amount: number,\n currency: string,\n isTrial: boolean,\n}\n\n/** UI view derived from subscriber status. */\nexport type SubscriptionView =\n | 'none'\n | 'active'\n | 'canceled_access'\n | 'canceled_expired';\n\nexport type ManageTab = 'subscription' | 'payment-history';\n\nexport type BillingCycle = 'monthly' | 'annual';\n\nexport interface BillingPlanOwnershipModel {\n uid: string,\n omName: string,\n}\n\n/** Normalized row from `filterCustomerBillingPlan`. */\nexport interface BillingPlan {\n uid: string,\n stripePriceId: string,\n /** Price amount e.g. \"39.99\" */\n amount: string,\n /** Currency code e.g. \"USD\" */\n currency: string,\n isTemplate: boolean,\n ownershipModel: BillingPlanOwnershipModel,\n}\n\nexport interface BillingPlansResult {\n plans: BillingPlan[],\n}\n\n/** One course line on a program purchase receipt. */\nexport interface PurchaseHistoryCourse {\n courseId: string,\n name: string,\n price: number,\n discountAmount: number,\n}\n\n/** One-off course or program purchase from `tOrderHistory.orders`. */\nexport interface PurchaseHistoryItem {\n orderId: string,\n orderNumber: string,\n purchasedAt: string,\n paymentIntentId?: string,\n paymentMethod?: {\n type?: string,\n brand?: string,\n last4?: string,\n wallet?: string,\n } | null,\n name: string,\n total: {\n amount: number,\n currency: string,\n },\n /** Set when the payload reports a program purchase. */\n itemType?: 'course' | 'program',\n courses?: PurchaseHistoryCourse[],\n}\n\nexport interface OrdersListProps {\n orders: PurchaseHistoryItem[],\n onViewReceipt?: (order: PurchaseHistoryItem) => void,\n}\n\nexport interface MoneyAmount {\n amount: number,\n currency: string,\n}\n\n/** One line on a program order details payload. */\nexport interface OrderProgramItem {\n productId?: string,\n courseRunKey?: string,\n name: string,\n price?: MoneyAmount,\n discount?: MoneyAmount,\n total?: MoneyAmount,\n}\n\n/** Normalized `tOrderDetails` payload for the order details page. */\nexport interface OrderDetailsData {\n orderId: string,\n orderNumber: string,\n purchasedAt: string,\n paymentIntentId: string,\n name: string,\n subtotalAmount?: MoneyAmount,\n itemPriceAmount?: MoneyAmount,\n discountCode?: string | null,\n total: MoneyAmount,\n discountAmount?: MoneyAmount,\n itemType: 'course' | 'program',\n items?: OrderProgramItem[],\n}\n"]}
|