@sazito/checkout 0.4.4 → 0.4.5

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.
@@ -3,8 +3,8 @@
3
3
 
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
5
  var react = require('react');
6
- var useCheckout = require('../chunks/use-checkout-BPcxdj0A.cjs');
7
- var labels = require('../chunks/labels-DlZCs2z3.cjs');
6
+ var useCheckout = require('../chunks/use-checkout-Bv1EWwHX.cjs');
7
+ var labels = require('../chunks/labels-DCruUx_W.cjs');
8
8
  var next_paymentReturn = require('./payment-return.cjs');
9
9
  require('@sazito/client-sdk');
10
10
 
@@ -717,13 +717,15 @@ function ResultStep({ continueShoppingUrl }) {
717
717
  const order = result?.order;
718
718
  const invoice = order?.invoice;
719
719
  const showDetails = Boolean(order && (status === 'success' || status === 'pending'));
720
+ const showSummary = invoice?.netTotal != null || invoice?.finalTotal != null;
721
+ const isFailure = status === 'failed' || status === 'stock_violated';
720
722
  const titleMap = {
721
723
  success: t.paymentSuccess,
722
724
  failed: t.paymentFailed,
723
725
  pending: t.paymentPending,
724
726
  stock_violated: t.paymentFailed
725
727
  };
726
- return (jsxRuntime.jsxs("section", { className: `szc-result szc-result--${status}`, children: [jsxRuntime.jsxs("div", { className: "szc-result__hero", role: "status", "aria-live": "polite", children: [jsxRuntime.jsx("div", { className: "szc-result__icon", children: status === 'success' ? (jsxRuntime.jsx(CheckCircle, {})) : status === 'pending' ? (jsxRuntime.jsx(Spinner, {})) : (jsxRuntime.jsx(CrossCircle, {})) }), jsxRuntime.jsx("h2", { className: "szc-result__title", children: titleMap[status] }), status === 'pending' ? jsxRuntime.jsx("p", { className: "szc-muted", children: t.paymentPendingHint }) : null, result?.message ? jsxRuntime.jsx("p", { className: "szc-muted", children: result.message }) : null, status === 'success' && order ? (jsxRuntime.jsx("p", { className: "szc-result__hint", children: t.orderConfirmedHint })) : null, order ? (jsxRuntime.jsxs("dl", { className: "szc-result__reference", children: [jsxRuntime.jsxs("div", { className: "szc-result__reference-primary", children: [jsxRuntime.jsx("dt", { children: t.orderNumber }), jsxRuntime.jsx("dd", { children: formatPublicId(order.orderNumber, state.locale) })] }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("dt", { children: t.orderId }), jsxRuntime.jsx("dd", { children: formatPublicId(order.id, state.locale) })] })] })) : null, jsxRuntime.jsxs("div", { className: "szc-result__actions", children: [status === 'failed' || status === 'stock_violated' ? (jsxRuntime.jsx(Button, { onClick: () => actions.goToStep('payment'), children: t.tryAgain })) : null, continueShoppingUrl ? (jsxRuntime.jsx(Button, { variant: status === 'success' ? 'primary' : 'outline', asChild: true, children: jsxRuntime.jsx("a", { href: continueShoppingUrl, children: t.continueShopping }) })) : null] })] }), showDetails && order && invoice ? (jsxRuntime.jsxs("div", { className: "szc-result__details", children: [jsxRuntime.jsx("h3", { className: "szc-result__details-title", children: t.orderDetails }), invoice.shippingItems.length > 0 ? (jsxRuntime.jsxs("section", { className: "szc-result__section", "aria-labelledby": "szc-result-shipping-title", children: [jsxRuntime.jsx("h4", { id: "szc-result-shipping-title", className: "szc-result__section-title", children: t.shippingMethods }), jsxRuntime.jsx("div", { className: "szc-result-shipping-list", children: invoice.shippingItems.map((shipping) => (jsxRuntime.jsx("article", { className: "szc-result-group", children: jsxRuntime.jsxs("header", { className: "szc-result-group__head", children: [jsxRuntime.jsx("span", { className: "szc-result-group__mark", "aria-hidden": "true", children: shipping.rate.icon ? jsxRuntime.jsx("img", { src: shipping.rate.icon, alt: "" }) : jsxRuntime.jsx(DeliveryIcon, {}) }), jsxRuntime.jsx("span", { className: "szc-result-group__title", children: shipping.rate.name }), jsxRuntime.jsx("span", { className: "szc-result-group__price", children: price(shipping.rate.price) })] }) }, String(shipping.id)))) })] })) : null, invoice.invoiceItems.length > 0 ? (jsxRuntime.jsxs("section", { className: "szc-result-group", "aria-labelledby": "szc-result-items-title", children: [jsxRuntime.jsxs("header", { className: "szc-result-group__head", children: [jsxRuntime.jsx("span", { className: "szc-result-group__mark", "aria-hidden": "true", children: jsxRuntime.jsx(OrderItemsIcon, {}) }), jsxRuntime.jsx("h4", { id: "szc-result-items-title", className: "szc-result-group__title", children: t.orderItems })] }), jsxRuntime.jsxs("div", { className: "szc-result-items__head", "aria-hidden": "true", children: [jsxRuntime.jsx("span", { children: t.product }), jsxRuntime.jsx("span", { children: t.quantity }), jsxRuntime.jsx("span", { children: t.lineTotal })] }), jsxRuntime.jsx("ul", { className: "szc-result-items", children: invoice.invoiceItems.map((item, index) => (jsxRuntime.jsxs("li", { className: "szc-result-item", children: [jsxRuntime.jsxs("span", { className: "szc-result-item__product", children: [item.image?.url ? (jsxRuntime.jsx("img", { className: "szc-result-item__thumb", src: item.image.url, alt: "" })) : (jsxRuntime.jsx(ProductPlaceholder, { className: "szc-result-item__thumb" })), jsxRuntime.jsxs("span", { children: [jsxRuntime.jsx("strong", { children: item.name }), item.variantAttributes.length ? (jsxRuntime.jsx("small", { children: item.variantAttributes.map(formatAttribute).join(' · ') })) : null] })] }), jsxRuntime.jsxs("span", { className: "szc-result-item__quantity", children: [jsxRuntime.jsx("span", { className: "szc-result-item__mobile-label", children: t.quantity }), labels.formatNumber(item.noOfItems, state.locale)] }), jsxRuntime.jsxs("span", { className: "szc-result-item__total", children: [jsxRuntime.jsx("span", { className: "szc-result-item__mobile-label", children: t.lineTotal }), money(item.totalItemsPrice)] })] }, `${String(item.productVariantId)}-${index}`))) })] })) : null, jsxRuntime.jsxs("dl", { className: "szc-result-summary", children: [jsxRuntime.jsx(SummaryRow, { label: t.subtotal, value: money(invoice.netTotal) }), invoice.shippingTotal != null ? (jsxRuntime.jsx(SummaryRow, { label: t.shipping, value: money(invoice.shippingTotal) })) : null, invoice.discountTotal != null && invoice.discountTotal > 0 ? (jsxRuntime.jsx(SummaryRow, { label: t.discount, value: `−${money(invoice.discountTotal)}` })) : null, invoice.creditTotal != null && invoice.creditTotal > 0 ? (jsxRuntime.jsx(SummaryRow, { label: t.credit, value: `−${money(invoice.creditTotal)}` })) : null, invoice.vat != null && invoice.vat > 0 ? (jsxRuntime.jsx(SummaryRow, { label: t.vat, value: money(invoice.vat) })) : null, invoice.customerProfit != null && invoice.customerProfit > 0 ? (jsxRuntime.jsx(SummaryRow, { label: t.yourSavings, value: money(invoice.customerProfit), savings: true })) : null, jsxRuntime.jsx(SummaryRow, { label: t.total, value: money(invoice.finalTotal), total: true })] })] })) : null] }));
728
+ return (jsxRuntime.jsxs("section", { className: `szc-result szc-result--${status}${showDetails ? '' : ' szc-result--compact'}`, children: [jsxRuntime.jsxs("div", { className: "szc-result__hero", role: isFailure ? 'alert' : 'status', "aria-live": isFailure ? 'assertive' : 'polite', children: [jsxRuntime.jsx("div", { className: "szc-result__icon", children: jsxRuntime.jsx("span", { className: "szc-result__icon-mark", children: status === 'success' ? (jsxRuntime.jsx(CheckCircle, {})) : status === 'pending' ? (jsxRuntime.jsx(Spinner, {})) : (jsxRuntime.jsx(CrossCircle, {})) }) }), jsxRuntime.jsxs("div", { className: "szc-result__copy", children: [jsxRuntime.jsx("h2", { className: "szc-result__title", children: titleMap[status] }), status === 'pending' ? jsxRuntime.jsx("p", { className: "szc-result__hint", children: t.paymentPendingHint }) : null, result?.message ? (jsxRuntime.jsx("p", { className: "szc-result__message", dir: "auto", children: result.message })) : null, status === 'success' && order ? (jsxRuntime.jsx("p", { className: "szc-result__hint", children: t.orderConfirmedHint })) : null] }), order ? (jsxRuntime.jsxs("dl", { className: "szc-result__reference", children: [jsxRuntime.jsxs("div", { className: "szc-result__reference-primary", children: [jsxRuntime.jsx("dt", { children: t.orderNumber }), jsxRuntime.jsx("dd", { children: formatPublicId(order.orderNumber, state.locale) })] }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("dt", { children: t.orderId }), jsxRuntime.jsx("dd", { children: formatPublicId(order.id, state.locale) })] })] })) : null, jsxRuntime.jsxs("div", { className: "szc-result__actions", children: [status === 'failed' || status === 'stock_violated' ? (jsxRuntime.jsx(Button, { onClick: () => actions.goToStep('payment'), children: t.tryAgain })) : null, continueShoppingUrl ? (jsxRuntime.jsx(Button, { variant: status === 'success' ? 'primary' : 'outline', asChild: true, children: jsxRuntime.jsx("a", { href: continueShoppingUrl, children: t.continueShopping }) })) : null] })] }), showDetails && order && invoice ? (jsxRuntime.jsxs("div", { className: "szc-result__details", children: [jsxRuntime.jsx("h3", { className: "szc-result__details-title", children: t.orderDetails }), invoice.shippingItems.length > 0 ? (jsxRuntime.jsxs("section", { className: "szc-result__section", "aria-labelledby": "szc-result-shipping-title", children: [jsxRuntime.jsx("h4", { id: "szc-result-shipping-title", className: "szc-result__section-title", children: t.shippingMethods }), jsxRuntime.jsx("div", { className: "szc-result-shipping-list", children: invoice.shippingItems.map((shipping) => (jsxRuntime.jsx("article", { className: "szc-result-group", children: jsxRuntime.jsxs("header", { className: "szc-result-group__head", children: [jsxRuntime.jsx("span", { className: "szc-result-group__mark", "aria-hidden": "true", children: shipping.rate.icon ? jsxRuntime.jsx("img", { src: shipping.rate.icon, alt: "" }) : jsxRuntime.jsx(DeliveryIcon, {}) }), jsxRuntime.jsx("span", { className: "szc-result-group__title", children: shipping.rate.name }), jsxRuntime.jsx("span", { className: "szc-result-group__price", children: price(shipping.rate.price) })] }) }, String(shipping.id)))) })] })) : null, invoice.invoiceItems.length > 0 ? (jsxRuntime.jsxs("section", { className: "szc-result-group", "aria-labelledby": "szc-result-items-title", children: [jsxRuntime.jsxs("header", { className: "szc-result-group__head", children: [jsxRuntime.jsx("span", { className: "szc-result-group__mark", "aria-hidden": "true", children: jsxRuntime.jsx(OrderItemsIcon, {}) }), jsxRuntime.jsx("h4", { id: "szc-result-items-title", className: "szc-result-group__title", children: t.orderItems })] }), jsxRuntime.jsxs("div", { className: "szc-result-items__head", "aria-hidden": "true", children: [jsxRuntime.jsx("span", { children: t.product }), jsxRuntime.jsx("span", { children: t.quantity }), jsxRuntime.jsx("span", { children: t.lineTotal })] }), jsxRuntime.jsx("ul", { className: "szc-result-items", children: invoice.invoiceItems.map((item, index) => (jsxRuntime.jsxs("li", { className: "szc-result-item", children: [jsxRuntime.jsxs("span", { className: "szc-result-item__product", children: [item.image?.url ? (jsxRuntime.jsx("img", { className: "szc-result-item__thumb", src: item.image.url, alt: "" })) : (jsxRuntime.jsx(ProductPlaceholder, { className: "szc-result-item__thumb" })), jsxRuntime.jsxs("span", { children: [jsxRuntime.jsx("strong", { children: item.name }), item.variantAttributes.length ? (jsxRuntime.jsx("small", { children: item.variantAttributes.map(formatAttribute).join(' · ') })) : null] })] }), jsxRuntime.jsxs("span", { className: "szc-result-item__quantity", children: [jsxRuntime.jsx("span", { className: "szc-result-item__mobile-label", children: t.quantity }), labels.formatNumber(item.noOfItems, state.locale)] }), jsxRuntime.jsxs("span", { className: "szc-result-item__total", children: [jsxRuntime.jsx("span", { className: "szc-result-item__mobile-label", children: t.lineTotal }), money(item.totalItemsPrice)] })] }, `${String(item.productVariantId)}-${index}`))) })] })) : null, showSummary ? jsxRuntime.jsxs("dl", { className: "szc-result-summary", children: [invoice.netTotal != null ? (jsxRuntime.jsx(SummaryRow, { label: t.subtotal, value: money(invoice.netTotal) })) : null, invoice.shippingTotal != null ? (jsxRuntime.jsx(SummaryRow, { label: t.shipping, value: money(invoice.shippingTotal) })) : null, invoice.discountTotal != null && invoice.discountTotal > 0 ? (jsxRuntime.jsx(SummaryRow, { label: t.discount, value: `−${money(invoice.discountTotal)}` })) : null, invoice.creditTotal != null && invoice.creditTotal > 0 ? (jsxRuntime.jsx(SummaryRow, { label: t.credit, value: `−${money(invoice.creditTotal)}` })) : null, invoice.vat != null && invoice.vat > 0 ? (jsxRuntime.jsx(SummaryRow, { label: t.vat, value: money(invoice.vat) })) : null, invoice.customerProfit != null && invoice.customerProfit > 0 ? (jsxRuntime.jsx(SummaryRow, { label: t.yourSavings, value: money(invoice.customerProfit), savings: true })) : null, invoice.finalTotal != null ? (jsxRuntime.jsx(SummaryRow, { label: t.total, value: money(invoice.finalTotal), total: true })) : null] }) : null] })) : null] }));
727
729
  }
728
730
  function formatPublicId(value, locale) {
729
731
  const text = String(value);