@edx/frontend-app-alacarte-checkout 1.40.0 → 1.41.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/Breadcrumb/ALCBreadcrumb.d.ts +10 -0
- package/dist/components/Breadcrumb/ALCBreadcrumb.js +13 -0
- package/dist/components/Breadcrumb/ALCBreadcrumb.js.map +1 -0
- package/dist/components/OrderHistory/OrderHistoryDetails.js +5 -1
- package/dist/components/OrderHistory/OrderHistoryDetails.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface BreadcrumbItem {
|
|
2
|
+
label: string;
|
|
3
|
+
href?: string;
|
|
4
|
+
onClick?: () => void;
|
|
5
|
+
}
|
|
6
|
+
interface AppBreadcrumbProps {
|
|
7
|
+
items: BreadcrumbItem[];
|
|
8
|
+
}
|
|
9
|
+
declare const ALCBreadcrumb: ({ items }: AppBreadcrumbProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default ALCBreadcrumb;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Breadcrumb } from '@openedx/paragon';
|
|
3
|
+
const ALCBreadcrumb = ({ items }) => {
|
|
4
|
+
var _a;
|
|
5
|
+
const links = items.slice(0, -1).map((item) => ({
|
|
6
|
+
label: item.label,
|
|
7
|
+
href: item.href,
|
|
8
|
+
onClick: item.onClick,
|
|
9
|
+
}));
|
|
10
|
+
return (_jsx(Breadcrumb, { ariaLabel: "breadcrumb", links: links, activeLabel: (_a = items[items.length - 1]) === null || _a === void 0 ? void 0 : _a.label }));
|
|
11
|
+
};
|
|
12
|
+
export default ALCBreadcrumb;
|
|
13
|
+
//# sourceMappingURL=ALCBreadcrumb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ALCBreadcrumb.js","sourceRoot":"","sources":["../../../src/components/Breadcrumb/ALCBreadcrumb.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAY9C,MAAM,aAAa,GAAG,CAAC,EAAE,KAAK,EAAsB,EAAE,EAAE;;IACtD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC9C,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,OAAO,EAAE,IAAI,CAAC,OAAO;KACtB,CAAC,CAAC,CAAC;IAEJ,OAAO,CACL,KAAC,UAAU,IACT,SAAS,EAAC,YAAY,EACtB,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,MAAA,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,KAAK,GAC3C,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { Breadcrumb } from '@openedx/paragon';\n\nexport interface BreadcrumbItem {\n label: string,\n href?: string,\n onClick?: () => void,\n}\n\ninterface AppBreadcrumbProps {\n items: BreadcrumbItem[],\n}\n\nconst ALCBreadcrumb = ({ items }: AppBreadcrumbProps) => {\n const links = items.slice(0, -1).map((item) => ({\n label: item.label,\n href: item.href,\n onClick: item.onClick,\n }));\n\n return (\n <Breadcrumb\n ariaLabel=\"breadcrumb\"\n links={links}\n activeLabel={items[items.length - 1]?.label}\n />\n );\n};\n\nexport default ALCBreadcrumb;\n"]}
|
|
@@ -5,6 +5,7 @@ import { useIntl } from '@openedx/frontend-base';
|
|
|
5
5
|
import orders from './data/orderDetailsData';
|
|
6
6
|
import messages from './messages';
|
|
7
7
|
import { getOrderSummaryRows, getOrderItemRows, } from './data/receiptRows';
|
|
8
|
+
import ALCBreadcrumb from '../Breadcrumb/ALCBreadcrumb';
|
|
8
9
|
const formatAmount = (amount, currency) => (`${currency === 'USD' ? '$' : ''}${amount.toFixed(2)} ${currency}`);
|
|
9
10
|
const formatDate = (isoDate) => (new Date(isoDate).toLocaleDateString('en-US', {
|
|
10
11
|
month: 'short',
|
|
@@ -20,7 +21,10 @@ const OrderReceipt = ({ order }) => {
|
|
|
20
21
|
const orderSummaryRows = getOrderSummaryRows(order, orderDate, total, discountAmount);
|
|
21
22
|
const orderItemRows = getOrderItemRows(order, total, discountAmount);
|
|
22
23
|
const renderRows = (rows) => rows.map(({ label, value }) => (_jsx(ReceiptRow, { label: formatMessage(label), children: value }, label.id)));
|
|
23
|
-
return (_jsxs(_Fragment, { children: [
|
|
24
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: "my-2", children: _jsx(ALCBreadcrumb, { items: [
|
|
25
|
+
{ label: 'Order History', href: '/aca-order-history' },
|
|
26
|
+
{ 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 })] }));
|
|
24
28
|
};
|
|
25
29
|
const OrderHistoryDetails = () => {
|
|
26
30
|
const { orderId } = useParams();
|
|
@@ -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;AAC7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cAAI,SAAS,EAAC,iDAAiD,aAC5D,aAAa,CAAC,QAAQ,CAAC,cAAc,CAAC,QAAI,SAAS,IACjD,EAEL,aAAI,SAAS,EAAC,2CAA2C,YACtD,aAAa,CAAC,QAAQ,CAAC,iBAAiB,CAAC,GACvC,EACJ,UAAU,CAAC,gBAAgB,CAAC,EAE7B,aAAI,SAAS,EAAC,cAAc,GAAG,EAE/B,aAAI,SAAS,EAAC,wCAAwC,YACnD,aAAa,CAAC,QAAQ,CAAC,eAAe,CAAC,GACrC,EACJ,UAAU,CAAC,aAAa,CAAC,EAE1B,aAAI,SAAS,EAAC,cAAc,GAAG,EAE/B,aAAI,SAAS,EAAC,wCAAwC,YACnD,aAAa,CAAC,QAAQ,CAAC,YAAY,CAAC,GAClC,EACL,KAAC,UAAU,IAAC,KAAK,EAAE,aAAa,CAAC,QAAQ,CAAC,kBAAkB,CAAC,YAC1D,KAAK,GACK,IACZ,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,GAAG,EAAE;IAC/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"]}
|