@sazito/checkout 0.4.3 → 0.4.4
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/README.md +1 -1
- package/dist/core/index.d.cts +3 -3
- package/dist/core/index.d.ts +3 -3
- package/dist/next/index.cjs +2 -3
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.d.cts +3 -3
- package/dist/next/index.d.ts +3 -3
- package/dist/next/index.js +2 -3
- package/dist/next/index.js.map +1 -1
- package/dist/react/index.d.cts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/next/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React, { ReactNode, ButtonHTMLAttributes, InputHTMLAttributes } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { CheckoutOrder, Cart, Invoice, ApplicableShippingMethods, InvoiceItem, ShippingRate, PaymentMethod } from '@sazito/client-sdk';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Checkout domain types.
|
|
@@ -154,7 +154,7 @@ interface ShippingGroup {
|
|
|
154
154
|
}
|
|
155
155
|
interface CheckoutResult {
|
|
156
156
|
status: CheckoutResultStatus;
|
|
157
|
-
order?:
|
|
157
|
+
order?: CheckoutOrder;
|
|
158
158
|
message?: string;
|
|
159
159
|
}
|
|
160
160
|
interface CheckoutError {
|
|
@@ -373,7 +373,7 @@ interface RenderResultProps {
|
|
|
373
373
|
/** Normalized result status. Falls back to `pending` while resolving. */
|
|
374
374
|
status: CheckoutResultStatus;
|
|
375
375
|
/** Finalized order returned by Sazito on a successful payment. */
|
|
376
|
-
order?:
|
|
376
|
+
order?: CheckoutOrder;
|
|
377
377
|
/** Configured destination for the continue-shopping action. */
|
|
378
378
|
continueShoppingUrl?: string;
|
|
379
379
|
/** Return to the payment step after a failed or stock-violated result. */
|
package/dist/next/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React, { ReactNode, ButtonHTMLAttributes, InputHTMLAttributes } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { CheckoutOrder, Cart, Invoice, ApplicableShippingMethods, InvoiceItem, ShippingRate, PaymentMethod } from '@sazito/client-sdk';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Checkout domain types.
|
|
@@ -154,7 +154,7 @@ interface ShippingGroup {
|
|
|
154
154
|
}
|
|
155
155
|
interface CheckoutResult {
|
|
156
156
|
status: CheckoutResultStatus;
|
|
157
|
-
order?:
|
|
157
|
+
order?: CheckoutOrder;
|
|
158
158
|
message?: string;
|
|
159
159
|
}
|
|
160
160
|
interface CheckoutError {
|
|
@@ -373,7 +373,7 @@ interface RenderResultProps {
|
|
|
373
373
|
/** Normalized result status. Falls back to `pending` while resolving. */
|
|
374
374
|
status: CheckoutResultStatus;
|
|
375
375
|
/** Finalized order returned by Sazito on a successful payment. */
|
|
376
|
-
order?:
|
|
376
|
+
order?: CheckoutOrder;
|
|
377
377
|
/** Configured destination for the continue-shopping action. */
|
|
378
378
|
continueShoppingUrl?: string;
|
|
379
379
|
/** Return to the payment step after a failed or stock-violated result. */
|
package/dist/next/index.js
CHANGED
|
@@ -722,15 +722,14 @@ function ResultStep({ continueShoppingUrl }) {
|
|
|
722
722
|
pending: t.paymentPending,
|
|
723
723
|
stock_violated: t.paymentFailed
|
|
724
724
|
};
|
|
725
|
-
return (jsxs("section", { className: `szc-result szc-result--${status}`, children: [jsxs("div", { className: "szc-result__hero", role: "status", "aria-live": "polite", children: [jsx("div", { className: "szc-result__icon", children: status === 'success' ? (jsx(CheckCircle, {})) : status === 'pending' ? (jsx(Spinner, {})) : (jsx(CrossCircle, {})) }), jsx("h2", { className: "szc-result__title", children: titleMap[status] }), status === 'pending' ? jsx("p", { className: "szc-muted", children: t.paymentPendingHint }) : null, result?.message ? jsx("p", { className: "szc-muted", children: result.message }) : null, status === 'success' && order ? (jsx("p", { className: "szc-result__hint", children: t.orderConfirmedHint })) : null, order ? (jsxs("dl", { className: "szc-result__reference", children: [jsxs("div", { className: "szc-result__reference-primary", children: [jsx("dt", { children: t.orderNumber }), jsx("dd", { children: formatPublicId(order.orderNumber, state.locale) })] }), jsxs("div", { children: [jsx("dt", { children: t.orderId }), jsx("dd", { children: formatPublicId(order.id, state.locale) })] })] })) : null, jsxs("div", { className: "szc-result__actions", children: [status === 'failed' || status === 'stock_violated' ? (jsx(Button, { onClick: () => actions.goToStep('payment'), children: t.tryAgain })) : null, continueShoppingUrl ? (jsx(Button, { variant: status === 'success' ? 'primary' : 'outline', asChild: true, children: jsx("a", { href: continueShoppingUrl, children: t.continueShopping }) })) : null] })] }), showDetails && order && invoice ? (jsxs("div", { className: "szc-result__details", children: [jsx("h3", { className: "szc-result__details-title", children: t.orderDetails }), invoice.shippingItems.length > 0 ? (jsxs("section", { className: "szc-result__section", "aria-labelledby": "szc-result-shipping-title", children: [jsx("h4", { id: "szc-result-shipping-title", className: "szc-result__section-title", children: t.shippingMethods }), jsx("div", { className: "szc-result-shipping-list", children: invoice.shippingItems.map((shipping) => (jsx("article", { className: "szc-result-group", children: jsxs("header", { className: "szc-result-group__head", children: [jsx("span", { className: "szc-result-group__mark", "aria-hidden": "true", children: shipping.rate.icon ? jsx("img", { src: shipping.rate.icon, alt: "" }) : jsx(DeliveryIcon, {}) }), jsx("span", { className: "szc-result-group__title", children: shipping.rate.name }), jsx("span", { className: "szc-result-group__price", children: price(shipping.rate.price) })] }) }, String(shipping.id)))) })] })) : null, invoice.invoiceItems.length > 0 ? (jsxs("section", { className: "szc-result-group", "aria-labelledby": "szc-result-items-title", children: [jsxs("header", { className: "szc-result-group__head", children: [jsx("span", { className: "szc-result-group__mark", "aria-hidden": "true", children: jsx(OrderItemsIcon, {}) }), jsx("h4", { id: "szc-result-items-title", className: "szc-result-group__title", children: t.orderItems })] }), jsxs("div", { className: "szc-result-items__head", "aria-hidden": "true", children: [jsx("span", { children: t.product }), jsx("span", { children: t.quantity }), jsx("span", { children: t.lineTotal })] }), jsx("ul", { className: "szc-result-items", children: invoice.invoiceItems.map((item, index) => (jsxs("li", { className: "szc-result-item", children: [jsxs("span", { className: "szc-result-item__product", children: [item.image?.url ? (jsx("img", { className: "szc-result-item__thumb", src: item.image.url, alt: "" })) : (jsx(ProductPlaceholder, { className: "szc-result-item__thumb" })), jsxs("span", { children: [jsx("strong", { children: item.name }), item.
|
|
725
|
+
return (jsxs("section", { className: `szc-result szc-result--${status}`, children: [jsxs("div", { className: "szc-result__hero", role: "status", "aria-live": "polite", children: [jsx("div", { className: "szc-result__icon", children: status === 'success' ? (jsx(CheckCircle, {})) : status === 'pending' ? (jsx(Spinner, {})) : (jsx(CrossCircle, {})) }), jsx("h2", { className: "szc-result__title", children: titleMap[status] }), status === 'pending' ? jsx("p", { className: "szc-muted", children: t.paymentPendingHint }) : null, result?.message ? jsx("p", { className: "szc-muted", children: result.message }) : null, status === 'success' && order ? (jsx("p", { className: "szc-result__hint", children: t.orderConfirmedHint })) : null, order ? (jsxs("dl", { className: "szc-result__reference", children: [jsxs("div", { className: "szc-result__reference-primary", children: [jsx("dt", { children: t.orderNumber }), jsx("dd", { children: formatPublicId(order.orderNumber, state.locale) })] }), jsxs("div", { children: [jsx("dt", { children: t.orderId }), jsx("dd", { children: formatPublicId(order.id, state.locale) })] })] })) : null, jsxs("div", { className: "szc-result__actions", children: [status === 'failed' || status === 'stock_violated' ? (jsx(Button, { onClick: () => actions.goToStep('payment'), children: t.tryAgain })) : null, continueShoppingUrl ? (jsx(Button, { variant: status === 'success' ? 'primary' : 'outline', asChild: true, children: jsx("a", { href: continueShoppingUrl, children: t.continueShopping }) })) : null] })] }), showDetails && order && invoice ? (jsxs("div", { className: "szc-result__details", children: [jsx("h3", { className: "szc-result__details-title", children: t.orderDetails }), invoice.shippingItems.length > 0 ? (jsxs("section", { className: "szc-result__section", "aria-labelledby": "szc-result-shipping-title", children: [jsx("h4", { id: "szc-result-shipping-title", className: "szc-result__section-title", children: t.shippingMethods }), jsx("div", { className: "szc-result-shipping-list", children: invoice.shippingItems.map((shipping) => (jsx("article", { className: "szc-result-group", children: jsxs("header", { className: "szc-result-group__head", children: [jsx("span", { className: "szc-result-group__mark", "aria-hidden": "true", children: shipping.rate.icon ? jsx("img", { src: shipping.rate.icon, alt: "" }) : jsx(DeliveryIcon, {}) }), jsx("span", { className: "szc-result-group__title", children: shipping.rate.name }), jsx("span", { className: "szc-result-group__price", children: price(shipping.rate.price) })] }) }, String(shipping.id)))) })] })) : null, invoice.invoiceItems.length > 0 ? (jsxs("section", { className: "szc-result-group", "aria-labelledby": "szc-result-items-title", children: [jsxs("header", { className: "szc-result-group__head", children: [jsx("span", { className: "szc-result-group__mark", "aria-hidden": "true", children: jsx(OrderItemsIcon, {}) }), jsx("h4", { id: "szc-result-items-title", className: "szc-result-group__title", children: t.orderItems })] }), jsxs("div", { className: "szc-result-items__head", "aria-hidden": "true", children: [jsx("span", { children: t.product }), jsx("span", { children: t.quantity }), jsx("span", { children: t.lineTotal })] }), jsx("ul", { className: "szc-result-items", children: invoice.invoiceItems.map((item, index) => (jsxs("li", { className: "szc-result-item", children: [jsxs("span", { className: "szc-result-item__product", children: [item.image?.url ? (jsx("img", { className: "szc-result-item__thumb", src: item.image.url, alt: "" })) : (jsx(ProductPlaceholder, { className: "szc-result-item__thumb" })), jsxs("span", { children: [jsx("strong", { children: item.name }), item.variantAttributes.length ? (jsx("small", { children: item.variantAttributes.map(formatAttribute).join(' · ') })) : null] })] }), jsxs("span", { className: "szc-result-item__quantity", children: [jsx("span", { className: "szc-result-item__mobile-label", children: t.quantity }), formatNumber(item.noOfItems, state.locale)] }), jsxs("span", { className: "szc-result-item__total", children: [jsx("span", { className: "szc-result-item__mobile-label", children: t.lineTotal }), money(item.totalItemsPrice)] })] }, `${String(item.productVariantId)}-${index}`))) })] })) : null, jsxs("dl", { className: "szc-result-summary", children: [jsx(SummaryRow, { label: t.subtotal, value: money(invoice.netTotal) }), invoice.shippingTotal != null ? (jsx(SummaryRow, { label: t.shipping, value: money(invoice.shippingTotal) })) : null, invoice.discountTotal != null && invoice.discountTotal > 0 ? (jsx(SummaryRow, { label: t.discount, value: `−${money(invoice.discountTotal)}` })) : null, invoice.creditTotal != null && invoice.creditTotal > 0 ? (jsx(SummaryRow, { label: t.credit, value: `−${money(invoice.creditTotal)}` })) : null, invoice.vat != null && invoice.vat > 0 ? (jsx(SummaryRow, { label: t.vat, value: money(invoice.vat) })) : null, invoice.customerProfit != null && invoice.customerProfit > 0 ? (jsx(SummaryRow, { label: t.yourSavings, value: money(invoice.customerProfit), savings: true })) : null, jsx(SummaryRow, { label: t.total, value: money(invoice.finalTotal), total: true })] })] })) : null] }));
|
|
726
726
|
}
|
|
727
727
|
function formatPublicId(value, locale) {
|
|
728
728
|
const text = String(value);
|
|
729
729
|
return locale === 'fa' ? toPersianDigits(text) : text;
|
|
730
730
|
}
|
|
731
731
|
function formatAttribute(attribute) {
|
|
732
|
-
|
|
733
|
-
return `${attribute.name}: ${value}`;
|
|
732
|
+
return `${attribute.name}: ${attribute.value}`;
|
|
734
733
|
}
|
|
735
734
|
function SummaryRow({ label, value, savings = false, total = false }) {
|
|
736
735
|
return (jsxs("div", { className: `${total ? 'szc-result-summary__total' : ''} ${savings ? 'szc-result-summary__savings' : ''}`.trim(), children: [jsx("dt", { children: label }), jsx("dd", { children: value })] }));
|