@cimplify/sdk 0.8.13 → 0.8.14
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/react.d.mts +3 -1
- package/dist/react.d.ts +3 -1
- package/dist/react.js +21 -5
- package/dist/react.mjs +21 -5
- package/package.json +1 -1
package/dist/react.d.mts
CHANGED
|
@@ -57,6 +57,8 @@ interface CimplifyCheckoutProps {
|
|
|
57
57
|
locationId?: string;
|
|
58
58
|
linkUrl?: string;
|
|
59
59
|
orderTypes?: CheckoutOrderType[];
|
|
60
|
+
defaultOrderType?: CheckoutOrderType;
|
|
61
|
+
submitLabel?: string;
|
|
60
62
|
enrollInLink?: boolean;
|
|
61
63
|
onComplete: (result: ProcessCheckoutResult) => void;
|
|
62
64
|
onError?: (error: {
|
|
@@ -75,7 +77,7 @@ interface CimplifyCheckoutProps {
|
|
|
75
77
|
demoMode?: boolean;
|
|
76
78
|
className?: string;
|
|
77
79
|
}
|
|
78
|
-
declare function CimplifyCheckout({ client, businessId, cartId, locationId, linkUrl, orderTypes, enrollInLink, onComplete, onError, onStatusChange, appearance, demoMode, className, }: CimplifyCheckoutProps): React.ReactElement;
|
|
80
|
+
declare function CimplifyCheckout({ client, businessId, cartId, locationId, linkUrl, orderTypes, defaultOrderType, submitLabel, enrollInLink, onComplete, onError, onStatusChange, appearance, demoMode, className, }: CimplifyCheckoutProps): React.ReactElement;
|
|
79
81
|
|
|
80
82
|
interface PriceProps {
|
|
81
83
|
/** The amount in base (business) currency. */
|
package/dist/react.d.ts
CHANGED
|
@@ -57,6 +57,8 @@ interface CimplifyCheckoutProps {
|
|
|
57
57
|
locationId?: string;
|
|
58
58
|
linkUrl?: string;
|
|
59
59
|
orderTypes?: CheckoutOrderType[];
|
|
60
|
+
defaultOrderType?: CheckoutOrderType;
|
|
61
|
+
submitLabel?: string;
|
|
60
62
|
enrollInLink?: boolean;
|
|
61
63
|
onComplete: (result: ProcessCheckoutResult) => void;
|
|
62
64
|
onError?: (error: {
|
|
@@ -75,7 +77,7 @@ interface CimplifyCheckoutProps {
|
|
|
75
77
|
demoMode?: boolean;
|
|
76
78
|
className?: string;
|
|
77
79
|
}
|
|
78
|
-
declare function CimplifyCheckout({ client, businessId, cartId, locationId, linkUrl, orderTypes, enrollInLink, onComplete, onError, onStatusChange, appearance, demoMode, className, }: CimplifyCheckoutProps): React.ReactElement;
|
|
80
|
+
declare function CimplifyCheckout({ client, businessId, cartId, locationId, linkUrl, orderTypes, defaultOrderType, submitLabel, enrollInLink, onComplete, onError, onStatusChange, appearance, demoMode, className, }: CimplifyCheckoutProps): React.ReactElement;
|
|
79
81
|
|
|
80
82
|
interface PriceProps {
|
|
81
83
|
/** The amount in base (business) currency. */
|
package/dist/react.js
CHANGED
|
@@ -4416,6 +4416,8 @@ function CimplifyCheckout({
|
|
|
4416
4416
|
locationId,
|
|
4417
4417
|
linkUrl,
|
|
4418
4418
|
orderTypes,
|
|
4419
|
+
defaultOrderType,
|
|
4420
|
+
submitLabel,
|
|
4419
4421
|
enrollInLink = true,
|
|
4420
4422
|
onComplete,
|
|
4421
4423
|
onError,
|
|
@@ -4428,7 +4430,13 @@ function CimplifyCheckout({
|
|
|
4428
4430
|
() => orderTypes && orderTypes.length > 0 ? orderTypes : ["pickup", "delivery"],
|
|
4429
4431
|
[orderTypes]
|
|
4430
4432
|
);
|
|
4431
|
-
const
|
|
4433
|
+
const resolvedDefaultOrderType = React3.useMemo(() => {
|
|
4434
|
+
if (defaultOrderType && resolvedOrderTypes.includes(defaultOrderType)) {
|
|
4435
|
+
return defaultOrderType;
|
|
4436
|
+
}
|
|
4437
|
+
return resolvedOrderTypes[0] || "pickup";
|
|
4438
|
+
}, [defaultOrderType, resolvedOrderTypes]);
|
|
4439
|
+
const [orderType, setOrderType] = React3.useState(resolvedDefaultOrderType);
|
|
4432
4440
|
const [status, setStatus] = React3.useState(null);
|
|
4433
4441
|
const [statusText, setStatusText] = React3.useState("");
|
|
4434
4442
|
const [isSubmitting, setIsSubmitting] = React3.useState(false);
|
|
@@ -4475,9 +4483,9 @@ function CimplifyCheckout({
|
|
|
4475
4483
|
);
|
|
4476
4484
|
React3.useEffect(() => {
|
|
4477
4485
|
if (!resolvedOrderTypes.includes(orderType)) {
|
|
4478
|
-
setOrderType(
|
|
4486
|
+
setOrderType(resolvedDefaultOrderType);
|
|
4479
4487
|
}
|
|
4480
|
-
}, [resolvedOrderTypes, orderType]);
|
|
4488
|
+
}, [resolvedOrderTypes, resolvedDefaultOrderType, orderType]);
|
|
4481
4489
|
React3.useEffect(() => {
|
|
4482
4490
|
if (appearance && appearance !== initialAppearanceRef.current && !hasWarnedInlineAppearanceRef.current) {
|
|
4483
4491
|
hasWarnedInlineAppearanceRef.current = true;
|
|
@@ -4667,7 +4675,8 @@ function CimplifyCheckout({
|
|
|
4667
4675
|
elementsRef.current = elements;
|
|
4668
4676
|
const checkout = elements.create("checkout", {
|
|
4669
4677
|
orderTypes: resolvedOrderTypes,
|
|
4670
|
-
defaultOrderType:
|
|
4678
|
+
defaultOrderType: resolvedDefaultOrderType,
|
|
4679
|
+
submitLabel
|
|
4671
4680
|
});
|
|
4672
4681
|
if (checkoutMountRef.current) {
|
|
4673
4682
|
checkout.mount(checkoutMountRef.current);
|
|
@@ -4693,7 +4702,14 @@ function CimplifyCheckout({
|
|
|
4693
4702
|
elements.destroy();
|
|
4694
4703
|
elementsRef.current = null;
|
|
4695
4704
|
};
|
|
4696
|
-
}, [
|
|
4705
|
+
}, [
|
|
4706
|
+
client,
|
|
4707
|
+
resolvedBusinessId,
|
|
4708
|
+
isDemoCheckout,
|
|
4709
|
+
resolvedOrderTypes,
|
|
4710
|
+
resolvedDefaultOrderType,
|
|
4711
|
+
submitLabel
|
|
4712
|
+
]);
|
|
4697
4713
|
React3.useEffect(() => {
|
|
4698
4714
|
if (!resolvedCart || !elementsRef.current) return;
|
|
4699
4715
|
const checkoutElement = elementsRef.current.getElement("checkout");
|
package/dist/react.mjs
CHANGED
|
@@ -4410,6 +4410,8 @@ function CimplifyCheckout({
|
|
|
4410
4410
|
locationId,
|
|
4411
4411
|
linkUrl,
|
|
4412
4412
|
orderTypes,
|
|
4413
|
+
defaultOrderType,
|
|
4414
|
+
submitLabel,
|
|
4413
4415
|
enrollInLink = true,
|
|
4414
4416
|
onComplete,
|
|
4415
4417
|
onError,
|
|
@@ -4422,7 +4424,13 @@ function CimplifyCheckout({
|
|
|
4422
4424
|
() => orderTypes && orderTypes.length > 0 ? orderTypes : ["pickup", "delivery"],
|
|
4423
4425
|
[orderTypes]
|
|
4424
4426
|
);
|
|
4425
|
-
const
|
|
4427
|
+
const resolvedDefaultOrderType = useMemo(() => {
|
|
4428
|
+
if (defaultOrderType && resolvedOrderTypes.includes(defaultOrderType)) {
|
|
4429
|
+
return defaultOrderType;
|
|
4430
|
+
}
|
|
4431
|
+
return resolvedOrderTypes[0] || "pickup";
|
|
4432
|
+
}, [defaultOrderType, resolvedOrderTypes]);
|
|
4433
|
+
const [orderType, setOrderType] = useState(resolvedDefaultOrderType);
|
|
4426
4434
|
const [status, setStatus] = useState(null);
|
|
4427
4435
|
const [statusText, setStatusText] = useState("");
|
|
4428
4436
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
@@ -4469,9 +4477,9 @@ function CimplifyCheckout({
|
|
|
4469
4477
|
);
|
|
4470
4478
|
useEffect(() => {
|
|
4471
4479
|
if (!resolvedOrderTypes.includes(orderType)) {
|
|
4472
|
-
setOrderType(
|
|
4480
|
+
setOrderType(resolvedDefaultOrderType);
|
|
4473
4481
|
}
|
|
4474
|
-
}, [resolvedOrderTypes, orderType]);
|
|
4482
|
+
}, [resolvedOrderTypes, resolvedDefaultOrderType, orderType]);
|
|
4475
4483
|
useEffect(() => {
|
|
4476
4484
|
if (appearance && appearance !== initialAppearanceRef.current && !hasWarnedInlineAppearanceRef.current) {
|
|
4477
4485
|
hasWarnedInlineAppearanceRef.current = true;
|
|
@@ -4661,7 +4669,8 @@ function CimplifyCheckout({
|
|
|
4661
4669
|
elementsRef.current = elements;
|
|
4662
4670
|
const checkout = elements.create("checkout", {
|
|
4663
4671
|
orderTypes: resolvedOrderTypes,
|
|
4664
|
-
defaultOrderType:
|
|
4672
|
+
defaultOrderType: resolvedDefaultOrderType,
|
|
4673
|
+
submitLabel
|
|
4665
4674
|
});
|
|
4666
4675
|
if (checkoutMountRef.current) {
|
|
4667
4676
|
checkout.mount(checkoutMountRef.current);
|
|
@@ -4687,7 +4696,14 @@ function CimplifyCheckout({
|
|
|
4687
4696
|
elements.destroy();
|
|
4688
4697
|
elementsRef.current = null;
|
|
4689
4698
|
};
|
|
4690
|
-
}, [
|
|
4699
|
+
}, [
|
|
4700
|
+
client,
|
|
4701
|
+
resolvedBusinessId,
|
|
4702
|
+
isDemoCheckout,
|
|
4703
|
+
resolvedOrderTypes,
|
|
4704
|
+
resolvedDefaultOrderType,
|
|
4705
|
+
submitLabel
|
|
4706
|
+
]);
|
|
4691
4707
|
useEffect(() => {
|
|
4692
4708
|
if (!resolvedCart || !elementsRef.current) return;
|
|
4693
4709
|
const checkoutElement = elementsRef.current.getElement("checkout");
|