@pelcro/react-pelcro-js 4.0.0-alpha.85 → 4.0.0-alpha.87
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/index.cjs.js +66 -10
- package/dist/index.esm.js +66 -10
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -33053,12 +33053,21 @@ const OrderCreateSummary = ({
|
|
|
33053
33053
|
const [items, setItems] = React.useState([]);
|
|
33054
33054
|
const [orderTotal, setOrderTotal] = React.useState("");
|
|
33055
33055
|
React.useEffect(() => {
|
|
33056
|
-
|
|
33056
|
+
const isQuickPurchase = !Array.isArray(order);
|
|
33057
|
+
|
|
33058
|
+
if (isQuickPurchase) {
|
|
33057
33059
|
var _calcAndFormatItemsTo, _order$;
|
|
33058
33060
|
|
|
33059
|
-
setItems(order);
|
|
33061
|
+
setItems([order]);
|
|
33060
33062
|
setOrderTotal((_calcAndFormatItemsTo = calcAndFormatItemsTotal(order, (_order$ = order[0]) === null || _order$ === void 0 ? void 0 : _order$.currency)) !== null && _calcAndFormatItemsTo !== void 0 ? _calcAndFormatItemsTo : getFormattedPriceByLocal(order === null || order === void 0 ? void 0 : order.price, order === null || order === void 0 ? void 0 : order.currency, getPageOrDefaultLanguage()));
|
|
33061
33063
|
}
|
|
33064
|
+
|
|
33065
|
+
if ((order === null || order === void 0 ? void 0 : order.length) > 0) {
|
|
33066
|
+
var _calcAndFormatItemsTo2, _order$2;
|
|
33067
|
+
|
|
33068
|
+
setItems(order);
|
|
33069
|
+
setOrderTotal((_calcAndFormatItemsTo2 = calcAndFormatItemsTotal(order, (_order$2 = order[0]) === null || _order$2 === void 0 ? void 0 : _order$2.currency)) !== null && _calcAndFormatItemsTo2 !== void 0 ? _calcAndFormatItemsTo2 : getFormattedPriceByLocal(order === null || order === void 0 ? void 0 : order.price, order === null || order === void 0 ? void 0 : order.currency, getPageOrDefaultLanguage()));
|
|
33070
|
+
}
|
|
33062
33071
|
}, []);
|
|
33063
33072
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
33064
33073
|
className: "plc-px-8 md:plc-px-0"
|
|
@@ -33172,7 +33181,8 @@ const OrderCreateModal = ({
|
|
|
33172
33181
|
...otherProps
|
|
33173
33182
|
}) => {
|
|
33174
33183
|
const {
|
|
33175
|
-
switchView
|
|
33184
|
+
switchView,
|
|
33185
|
+
order
|
|
33176
33186
|
} = usePelcro();
|
|
33177
33187
|
const {
|
|
33178
33188
|
t
|
|
@@ -33185,6 +33195,39 @@ const OrderCreateModal = ({
|
|
|
33185
33195
|
return switchView("order-confirm");
|
|
33186
33196
|
};
|
|
33187
33197
|
|
|
33198
|
+
const showBackButton = Boolean(order);
|
|
33199
|
+
|
|
33200
|
+
const userHasPaymentMethod = () => {
|
|
33201
|
+
var _window$Pelcro$user$r, _window$Pelcro$user$r2;
|
|
33202
|
+
|
|
33203
|
+
const sources = (_window$Pelcro$user$r = (_window$Pelcro$user$r2 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r2 === void 0 ? void 0 : _window$Pelcro$user$r2.sources) !== null && _window$Pelcro$user$r !== void 0 ? _window$Pelcro$user$r : [];
|
|
33204
|
+
return sources.length > 0;
|
|
33205
|
+
};
|
|
33206
|
+
|
|
33207
|
+
const userHasAddress = () => {
|
|
33208
|
+
var _window$Pelcro$user$r3, _window$Pelcro$user$r4;
|
|
33209
|
+
|
|
33210
|
+
const addresses = (_window$Pelcro$user$r3 = (_window$Pelcro$user$r4 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r4 === void 0 ? void 0 : _window$Pelcro$user$r4.addresses) !== null && _window$Pelcro$user$r3 !== void 0 ? _window$Pelcro$user$r3 : [];
|
|
33211
|
+
return addresses.length > 0;
|
|
33212
|
+
};
|
|
33213
|
+
|
|
33214
|
+
const isUserHasPaymentMethod = userHasPaymentMethod();
|
|
33215
|
+
const isUserHasAddress = userHasAddress();
|
|
33216
|
+
|
|
33217
|
+
const goBack = () => {
|
|
33218
|
+
if (order && isUserHasPaymentMethod) {
|
|
33219
|
+
return switchView("payment-method-select");
|
|
33220
|
+
}
|
|
33221
|
+
|
|
33222
|
+
if (order && isUserHasAddress) {
|
|
33223
|
+
return switchView("address-select");
|
|
33224
|
+
}
|
|
33225
|
+
|
|
33226
|
+
if (order) {
|
|
33227
|
+
return switchView("cart");
|
|
33228
|
+
}
|
|
33229
|
+
};
|
|
33230
|
+
|
|
33188
33231
|
return /*#__PURE__*/React__default['default'].createElement(Modal, {
|
|
33189
33232
|
id: "pelcro-order-create-modal",
|
|
33190
33233
|
className: "plc-max-w-7xl",
|
|
@@ -33193,8 +33236,12 @@ const OrderCreateModal = ({
|
|
|
33193
33236
|
onCloseModal: onClose
|
|
33194
33237
|
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
33195
33238
|
className: "plc-text-left plc-text-gray-900 pelcro-title-wrapper plc-flex-1 plc-flex plc-flex-col plc-justify-center"
|
|
33196
|
-
}, /*#__PURE__*/React__default['default'].createElement("
|
|
33197
|
-
|
|
33239
|
+
}, showBackButton && /*#__PURE__*/React__default['default'].createElement("button", {
|
|
33240
|
+
type: "button",
|
|
33241
|
+
onClick: goBack,
|
|
33242
|
+
className: "plc-absolute plc-w-6 plc-text-gray-500 focus:plc-text-black plc-z-max plc-top-1/2 plc-left-6 plc-transform plc--translate-y-1/2 plc-border-0 hover:plc-text-black hover:plc-shadow-none plc-bg-transparent hover:plc-bg-transparent focus:plc-bg-transparent"
|
|
33243
|
+
}, /*#__PURE__*/React__default['default'].createElement(SvgArrowLeft, null)), /*#__PURE__*/React__default['default'].createElement("h4", {
|
|
33244
|
+
className: "plc-text-xl plc-font-bold plc-text-center"
|
|
33198
33245
|
}, t("labels.checkout.title")))), /*#__PURE__*/React__default['default'].createElement(ModalBody, null, /*#__PURE__*/React__default['default'].createElement(OrderCreateView, Object.assign({}, otherProps, {
|
|
33199
33246
|
onSuccess: onSuccess
|
|
33200
33247
|
}))), /*#__PURE__*/React__default['default'].createElement(ModalFooter, null));
|
|
@@ -34241,7 +34288,8 @@ const AddressSelectModal = ({
|
|
|
34241
34288
|
resetView,
|
|
34242
34289
|
product,
|
|
34243
34290
|
plan,
|
|
34244
|
-
giftRecipient
|
|
34291
|
+
giftRecipient,
|
|
34292
|
+
order
|
|
34245
34293
|
} = usePelcro();
|
|
34246
34294
|
const {
|
|
34247
34295
|
t
|
|
@@ -34273,11 +34321,15 @@ const AddressSelectModal = ({
|
|
|
34273
34321
|
resetView();
|
|
34274
34322
|
};
|
|
34275
34323
|
|
|
34276
|
-
const showBackButton = Boolean(product && plan && !giftRecipient);
|
|
34324
|
+
const showBackButton = Boolean(product && plan && !giftRecipient || order);
|
|
34277
34325
|
|
|
34278
34326
|
const goBack = () => {
|
|
34279
34327
|
if (product && plan) {
|
|
34280
|
-
switchView("plan-select");
|
|
34328
|
+
return switchView("plan-select");
|
|
34329
|
+
}
|
|
34330
|
+
|
|
34331
|
+
if (order) {
|
|
34332
|
+
return switchView("cart");
|
|
34281
34333
|
}
|
|
34282
34334
|
};
|
|
34283
34335
|
|
|
@@ -34665,7 +34717,7 @@ const PaymentMethodSelectModal = ({
|
|
|
34665
34717
|
switchToCheckoutForm();
|
|
34666
34718
|
};
|
|
34667
34719
|
|
|
34668
|
-
const showBackButton = Boolean(product && plan && !giftRecipient);
|
|
34720
|
+
const showBackButton = Boolean(product && plan && !giftRecipient || order);
|
|
34669
34721
|
|
|
34670
34722
|
const userHasAddress = () => {
|
|
34671
34723
|
var _window$Pelcro$user$r, _window$Pelcro$user$r2;
|
|
@@ -34677,13 +34729,17 @@ const PaymentMethodSelectModal = ({
|
|
|
34677
34729
|
const isUserHasAddress = userHasAddress();
|
|
34678
34730
|
|
|
34679
34731
|
const goBack = () => {
|
|
34680
|
-
if (product && plan && product.address_required && isUserHasAddress) {
|
|
34732
|
+
if ((product && plan && product.address_required || order) && isUserHasAddress) {
|
|
34681
34733
|
return switchView("address-select");
|
|
34682
34734
|
}
|
|
34683
34735
|
|
|
34684
34736
|
if (product && plan) {
|
|
34685
34737
|
return switchView("plan-select");
|
|
34686
34738
|
}
|
|
34739
|
+
|
|
34740
|
+
if (order) {
|
|
34741
|
+
return switchView("cart");
|
|
34742
|
+
}
|
|
34687
34743
|
};
|
|
34688
34744
|
|
|
34689
34745
|
return /*#__PURE__*/React__default['default'].createElement(Modal, {
|
package/dist/index.esm.js
CHANGED
|
@@ -33023,12 +33023,21 @@ const OrderCreateSummary = ({
|
|
|
33023
33023
|
const [items, setItems] = useState([]);
|
|
33024
33024
|
const [orderTotal, setOrderTotal] = useState("");
|
|
33025
33025
|
useEffect(() => {
|
|
33026
|
-
|
|
33026
|
+
const isQuickPurchase = !Array.isArray(order);
|
|
33027
|
+
|
|
33028
|
+
if (isQuickPurchase) {
|
|
33027
33029
|
var _calcAndFormatItemsTo, _order$;
|
|
33028
33030
|
|
|
33029
|
-
setItems(order);
|
|
33031
|
+
setItems([order]);
|
|
33030
33032
|
setOrderTotal((_calcAndFormatItemsTo = calcAndFormatItemsTotal(order, (_order$ = order[0]) === null || _order$ === void 0 ? void 0 : _order$.currency)) !== null && _calcAndFormatItemsTo !== void 0 ? _calcAndFormatItemsTo : getFormattedPriceByLocal(order === null || order === void 0 ? void 0 : order.price, order === null || order === void 0 ? void 0 : order.currency, getPageOrDefaultLanguage()));
|
|
33031
33033
|
}
|
|
33034
|
+
|
|
33035
|
+
if ((order === null || order === void 0 ? void 0 : order.length) > 0) {
|
|
33036
|
+
var _calcAndFormatItemsTo2, _order$2;
|
|
33037
|
+
|
|
33038
|
+
setItems(order);
|
|
33039
|
+
setOrderTotal((_calcAndFormatItemsTo2 = calcAndFormatItemsTotal(order, (_order$2 = order[0]) === null || _order$2 === void 0 ? void 0 : _order$2.currency)) !== null && _calcAndFormatItemsTo2 !== void 0 ? _calcAndFormatItemsTo2 : getFormattedPriceByLocal(order === null || order === void 0 ? void 0 : order.price, order === null || order === void 0 ? void 0 : order.currency, getPageOrDefaultLanguage()));
|
|
33040
|
+
}
|
|
33032
33041
|
}, []);
|
|
33033
33042
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
33034
33043
|
className: "plc-px-8 md:plc-px-0"
|
|
@@ -33142,7 +33151,8 @@ const OrderCreateModal = ({
|
|
|
33142
33151
|
...otherProps
|
|
33143
33152
|
}) => {
|
|
33144
33153
|
const {
|
|
33145
|
-
switchView
|
|
33154
|
+
switchView,
|
|
33155
|
+
order
|
|
33146
33156
|
} = usePelcro();
|
|
33147
33157
|
const {
|
|
33148
33158
|
t
|
|
@@ -33155,6 +33165,39 @@ const OrderCreateModal = ({
|
|
|
33155
33165
|
return switchView("order-confirm");
|
|
33156
33166
|
};
|
|
33157
33167
|
|
|
33168
|
+
const showBackButton = Boolean(order);
|
|
33169
|
+
|
|
33170
|
+
const userHasPaymentMethod = () => {
|
|
33171
|
+
var _window$Pelcro$user$r, _window$Pelcro$user$r2;
|
|
33172
|
+
|
|
33173
|
+
const sources = (_window$Pelcro$user$r = (_window$Pelcro$user$r2 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r2 === void 0 ? void 0 : _window$Pelcro$user$r2.sources) !== null && _window$Pelcro$user$r !== void 0 ? _window$Pelcro$user$r : [];
|
|
33174
|
+
return sources.length > 0;
|
|
33175
|
+
};
|
|
33176
|
+
|
|
33177
|
+
const userHasAddress = () => {
|
|
33178
|
+
var _window$Pelcro$user$r3, _window$Pelcro$user$r4;
|
|
33179
|
+
|
|
33180
|
+
const addresses = (_window$Pelcro$user$r3 = (_window$Pelcro$user$r4 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r4 === void 0 ? void 0 : _window$Pelcro$user$r4.addresses) !== null && _window$Pelcro$user$r3 !== void 0 ? _window$Pelcro$user$r3 : [];
|
|
33181
|
+
return addresses.length > 0;
|
|
33182
|
+
};
|
|
33183
|
+
|
|
33184
|
+
const isUserHasPaymentMethod = userHasPaymentMethod();
|
|
33185
|
+
const isUserHasAddress = userHasAddress();
|
|
33186
|
+
|
|
33187
|
+
const goBack = () => {
|
|
33188
|
+
if (order && isUserHasPaymentMethod) {
|
|
33189
|
+
return switchView("payment-method-select");
|
|
33190
|
+
}
|
|
33191
|
+
|
|
33192
|
+
if (order && isUserHasAddress) {
|
|
33193
|
+
return switchView("address-select");
|
|
33194
|
+
}
|
|
33195
|
+
|
|
33196
|
+
if (order) {
|
|
33197
|
+
return switchView("cart");
|
|
33198
|
+
}
|
|
33199
|
+
};
|
|
33200
|
+
|
|
33158
33201
|
return /*#__PURE__*/React__default.createElement(Modal, {
|
|
33159
33202
|
id: "pelcro-order-create-modal",
|
|
33160
33203
|
className: "plc-max-w-7xl",
|
|
@@ -33163,8 +33206,12 @@ const OrderCreateModal = ({
|
|
|
33163
33206
|
onCloseModal: onClose
|
|
33164
33207
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
33165
33208
|
className: "plc-text-left plc-text-gray-900 pelcro-title-wrapper plc-flex-1 plc-flex plc-flex-col plc-justify-center"
|
|
33166
|
-
}, /*#__PURE__*/React__default.createElement("
|
|
33167
|
-
|
|
33209
|
+
}, showBackButton && /*#__PURE__*/React__default.createElement("button", {
|
|
33210
|
+
type: "button",
|
|
33211
|
+
onClick: goBack,
|
|
33212
|
+
className: "plc-absolute plc-w-6 plc-text-gray-500 focus:plc-text-black plc-z-max plc-top-1/2 plc-left-6 plc-transform plc--translate-y-1/2 plc-border-0 hover:plc-text-black hover:plc-shadow-none plc-bg-transparent hover:plc-bg-transparent focus:plc-bg-transparent"
|
|
33213
|
+
}, /*#__PURE__*/React__default.createElement(SvgArrowLeft, null)), /*#__PURE__*/React__default.createElement("h4", {
|
|
33214
|
+
className: "plc-text-xl plc-font-bold plc-text-center"
|
|
33168
33215
|
}, t("labels.checkout.title")))), /*#__PURE__*/React__default.createElement(ModalBody, null, /*#__PURE__*/React__default.createElement(OrderCreateView, Object.assign({}, otherProps, {
|
|
33169
33216
|
onSuccess: onSuccess
|
|
33170
33217
|
}))), /*#__PURE__*/React__default.createElement(ModalFooter, null));
|
|
@@ -34211,7 +34258,8 @@ const AddressSelectModal = ({
|
|
|
34211
34258
|
resetView,
|
|
34212
34259
|
product,
|
|
34213
34260
|
plan,
|
|
34214
|
-
giftRecipient
|
|
34261
|
+
giftRecipient,
|
|
34262
|
+
order
|
|
34215
34263
|
} = usePelcro();
|
|
34216
34264
|
const {
|
|
34217
34265
|
t
|
|
@@ -34243,11 +34291,15 @@ const AddressSelectModal = ({
|
|
|
34243
34291
|
resetView();
|
|
34244
34292
|
};
|
|
34245
34293
|
|
|
34246
|
-
const showBackButton = Boolean(product && plan && !giftRecipient);
|
|
34294
|
+
const showBackButton = Boolean(product && plan && !giftRecipient || order);
|
|
34247
34295
|
|
|
34248
34296
|
const goBack = () => {
|
|
34249
34297
|
if (product && plan) {
|
|
34250
|
-
switchView("plan-select");
|
|
34298
|
+
return switchView("plan-select");
|
|
34299
|
+
}
|
|
34300
|
+
|
|
34301
|
+
if (order) {
|
|
34302
|
+
return switchView("cart");
|
|
34251
34303
|
}
|
|
34252
34304
|
};
|
|
34253
34305
|
|
|
@@ -34635,7 +34687,7 @@ const PaymentMethodSelectModal = ({
|
|
|
34635
34687
|
switchToCheckoutForm();
|
|
34636
34688
|
};
|
|
34637
34689
|
|
|
34638
|
-
const showBackButton = Boolean(product && plan && !giftRecipient);
|
|
34690
|
+
const showBackButton = Boolean(product && plan && !giftRecipient || order);
|
|
34639
34691
|
|
|
34640
34692
|
const userHasAddress = () => {
|
|
34641
34693
|
var _window$Pelcro$user$r, _window$Pelcro$user$r2;
|
|
@@ -34647,13 +34699,17 @@ const PaymentMethodSelectModal = ({
|
|
|
34647
34699
|
const isUserHasAddress = userHasAddress();
|
|
34648
34700
|
|
|
34649
34701
|
const goBack = () => {
|
|
34650
|
-
if (product && plan && product.address_required && isUserHasAddress) {
|
|
34702
|
+
if ((product && plan && product.address_required || order) && isUserHasAddress) {
|
|
34651
34703
|
return switchView("address-select");
|
|
34652
34704
|
}
|
|
34653
34705
|
|
|
34654
34706
|
if (product && plan) {
|
|
34655
34707
|
return switchView("plan-select");
|
|
34656
34708
|
}
|
|
34709
|
+
|
|
34710
|
+
if (order) {
|
|
34711
|
+
return switchView("cart");
|
|
34712
|
+
}
|
|
34657
34713
|
};
|
|
34658
34714
|
|
|
34659
34715
|
return /*#__PURE__*/React__default.createElement(Modal, {
|