@sazito/checkout 0.4.2 → 0.4.3

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.
@@ -723,14 +723,15 @@ function ResultStep({ continueShoppingUrl }) {
723
723
  pending: t.paymentPending,
724
724
  stock_violated: t.paymentFailed
725
725
  };
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] }));
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.attributes.length ? (jsxRuntime.jsx("small", { children: item.attributes.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.quantity, 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.lineTotal)] })] }, `${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] }));
727
727
  }
728
728
  function formatPublicId(value, locale) {
729
729
  const text = String(value);
730
730
  return locale === 'fa' ? labels.toPersianDigits(text) : text;
731
731
  }
732
732
  function formatAttribute(attribute) {
733
- return `${attribute.name}: ${attribute.value}`;
733
+ const value = typeof attribute.value === 'object' ? attribute.value.value : attribute.value;
734
+ return `${attribute.name}: ${value}`;
734
735
  }
735
736
  function SummaryRow({ label, value, savings = false, total = false }) {
736
737
  return (jsxRuntime.jsxs("div", { className: `${total ? 'szc-result-summary__total' : ''} ${savings ? 'szc-result-summary__savings' : ''}`.trim(), children: [jsxRuntime.jsx("dt", { children: label }), jsxRuntime.jsx("dd", { children: value })] }));