@pelcro/react-pelcro-js 4.0.0-alpha.107 → 4.0.0-alpha.109
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 +67 -18
- package/dist/index.esm.js +67 -18
- package/dist/pelcro.css +16 -0
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -3783,7 +3783,8 @@ var labels$X = {
|
|
|
3783
3783
|
summary: "Order summary",
|
|
3784
3784
|
total: "Total",
|
|
3785
3785
|
subtotal: "Subtotal",
|
|
3786
|
-
shippingRate: "Shipping Rate"
|
|
3786
|
+
shippingRate: "Shipping Rate",
|
|
3787
|
+
tax: "Tax"
|
|
3787
3788
|
};
|
|
3788
3789
|
var shop_en = {
|
|
3789
3790
|
buttons: buttons$h,
|
|
@@ -9552,7 +9553,7 @@ const trackSubscriptionOnGA = () => {
|
|
|
9552
9553
|
couponCode
|
|
9553
9554
|
} = usePelcro.getStore();
|
|
9554
9555
|
|
|
9555
|
-
/*
|
|
9556
|
+
/*
|
|
9556
9557
|
getting the latest subscription id from invoices instead of subscriptions
|
|
9557
9558
|
to handle gifted subs which are not added to subs list
|
|
9558
9559
|
*/
|
|
@@ -9763,6 +9764,10 @@ const refreshUser = () => {
|
|
|
9763
9764
|
}
|
|
9764
9765
|
});
|
|
9765
9766
|
};
|
|
9767
|
+
const isStagingEnvironment = () => {
|
|
9768
|
+
var _window$Pelcro$enviro2;
|
|
9769
|
+
return (_window$Pelcro$enviro2 = window.Pelcro.environment) === null || _window$Pelcro$enviro2 === void 0 ? void 0 : _window$Pelcro$enviro2.domain.includes("staging");
|
|
9770
|
+
};
|
|
9766
9771
|
|
|
9767
9772
|
const resources = {
|
|
9768
9773
|
en: {
|
|
@@ -25978,6 +25983,9 @@ const ImageSelect = ({
|
|
|
25978
25983
|
components: {
|
|
25979
25984
|
Option: customOption,
|
|
25980
25985
|
SingleValue: customSingleValue
|
|
25986
|
+
},
|
|
25987
|
+
classNames: {
|
|
25988
|
+
menuList: () => "menu-list"
|
|
25981
25989
|
}
|
|
25982
25990
|
}, props, {
|
|
25983
25991
|
menuPortalTarget: document.body,
|
|
@@ -38724,28 +38732,56 @@ const OrderCreateSummary = ({
|
|
|
38724
38732
|
} = useTranslation("shop");
|
|
38725
38733
|
const [items, setItems] = React.useState([]);
|
|
38726
38734
|
const [paymentInfo, setPaymentInfo] = React.useState({});
|
|
38735
|
+
const {
|
|
38736
|
+
selectedAddressId
|
|
38737
|
+
} = usePelcro();
|
|
38738
|
+
async function fetchOrderSummary(orderSummaryPaylod) {
|
|
38739
|
+
try {
|
|
38740
|
+
const domain = isStagingEnvironment() ? "https://staging.pelcro.com" : "https://www.pelcro.com";
|
|
38741
|
+
const url = `${domain}/api/v1/sdk/ecommerce/order-summary`;
|
|
38742
|
+
const response = await fetch(url, {
|
|
38743
|
+
method: "POST",
|
|
38744
|
+
headers: {
|
|
38745
|
+
"Content-Type": "application/json",
|
|
38746
|
+
Authorization: `Bearer ${window.Pelcro.user.read().auth_token}`
|
|
38747
|
+
},
|
|
38748
|
+
body: JSON.stringify(orderSummaryPaylod)
|
|
38749
|
+
});
|
|
38750
|
+
if (response.ok) {
|
|
38751
|
+
var _data$data;
|
|
38752
|
+
const data = await response.json();
|
|
38753
|
+
console.log("data", data);
|
|
38754
|
+
setPaymentInfo({
|
|
38755
|
+
total: data === null || data === void 0 ? void 0 : data.data.total,
|
|
38756
|
+
shippingRate: data === null || data === void 0 ? void 0 : data.data.shipping_rate,
|
|
38757
|
+
subtotal: data === null || data === void 0 ? void 0 : data.data.subtotal,
|
|
38758
|
+
taxes: data === null || data === void 0 ? void 0 : (_data$data = data.data) === null || _data$data === void 0 ? void 0 : _data$data.tax_rate
|
|
38759
|
+
});
|
|
38760
|
+
}
|
|
38761
|
+
} catch (error) {
|
|
38762
|
+
console.error(error);
|
|
38763
|
+
}
|
|
38764
|
+
}
|
|
38727
38765
|
React.useEffect(() => {
|
|
38766
|
+
var _window$Pelcro$site$r;
|
|
38728
38767
|
if (!(order !== null && order !== void 0 && order.length) || paymentInfo !== null && paymentInfo !== void 0 && paymentInfo.total) {
|
|
38729
38768
|
return;
|
|
38730
38769
|
}
|
|
38731
|
-
|
|
38770
|
+
const orderSummaryPaylod = {
|
|
38732
38771
|
items: order.map(item => {
|
|
38733
38772
|
return {
|
|
38734
38773
|
sku_id: item.id,
|
|
38735
38774
|
quantity: item.quantity
|
|
38736
38775
|
};
|
|
38737
38776
|
})
|
|
38738
|
-
}
|
|
38739
|
-
|
|
38740
|
-
|
|
38741
|
-
|
|
38742
|
-
|
|
38743
|
-
|
|
38744
|
-
|
|
38745
|
-
|
|
38746
|
-
});
|
|
38747
|
-
});
|
|
38748
|
-
}, [order, paymentInfo === null || paymentInfo === void 0 ? void 0 : paymentInfo.total]);
|
|
38777
|
+
};
|
|
38778
|
+
if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.taxes_enabled) {
|
|
38779
|
+
orderSummaryPaylod.address_id = selectedAddressId;
|
|
38780
|
+
}
|
|
38781
|
+
orderSummaryPaylod.site_id = window.Pelcro.siteid;
|
|
38782
|
+
console.log("orderSummaryPaylod", orderSummaryPaylod);
|
|
38783
|
+
fetchOrderSummary(orderSummaryPaylod);
|
|
38784
|
+
}, [order, paymentInfo === null || paymentInfo === void 0 ? void 0 : paymentInfo.total, selectedAddressId]);
|
|
38749
38785
|
React.useEffect(() => {
|
|
38750
38786
|
const isQuickPurchase = !Array.isArray(order);
|
|
38751
38787
|
if (isQuickPurchase) {
|
|
@@ -38763,9 +38799,16 @@ const OrderCreateSummary = ({
|
|
|
38763
38799
|
var _order$2;
|
|
38764
38800
|
return getFormattedPriceByLocal((paymentInfo === null || paymentInfo === void 0 ? void 0 : paymentInfo.shippingRate) || 0, order === null || order === void 0 ? void 0 : (_order$2 = order[0]) === null || _order$2 === void 0 ? void 0 : _order$2.currency, getPageOrDefaultLanguage());
|
|
38765
38801
|
}, [paymentInfo === null || paymentInfo === void 0 ? void 0 : paymentInfo.shippingRate, order]);
|
|
38766
|
-
const
|
|
38802
|
+
const taxRate = React.useMemo(() => {
|
|
38767
38803
|
var _order$3;
|
|
38768
|
-
|
|
38804
|
+
if (!(paymentInfo !== null && paymentInfo !== void 0 && paymentInfo.taxes)) {
|
|
38805
|
+
return "0";
|
|
38806
|
+
}
|
|
38807
|
+
return getFormattedPriceByLocal((paymentInfo === null || paymentInfo === void 0 ? void 0 : paymentInfo.taxes) || 0, order === null || order === void 0 ? void 0 : (_order$3 = order[0]) === null || _order$3 === void 0 ? void 0 : _order$3.currency, getPageOrDefaultLanguage());
|
|
38808
|
+
}, [paymentInfo === null || paymentInfo === void 0 ? void 0 : paymentInfo.taxes, order]);
|
|
38809
|
+
const total = React.useMemo(() => {
|
|
38810
|
+
var _order$4;
|
|
38811
|
+
return getFormattedPriceByLocal((paymentInfo === null || paymentInfo === void 0 ? void 0 : paymentInfo.total) || 0, order === null || order === void 0 ? void 0 : (_order$4 = order[0]) === null || _order$4 === void 0 ? void 0 : _order$4.currency, getPageOrDefaultLanguage());
|
|
38769
38812
|
}, [paymentInfo === null || paymentInfo === void 0 ? void 0 : paymentInfo.total, order]);
|
|
38770
38813
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
38771
38814
|
className: "plc-px-8 md:plc-px-0"
|
|
@@ -38815,7 +38858,13 @@ const OrderCreateSummary = ({
|
|
|
38815
38858
|
className: "plc-text-base"
|
|
38816
38859
|
}, t("labels.shippingRate")), /*#__PURE__*/React__default['default'].createElement("dd", {
|
|
38817
38860
|
className: "plc-text-base"
|
|
38818
|
-
}, shippingRate)), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
38861
|
+
}, shippingRate)), taxRate !== "0" && /*#__PURE__*/React__default['default'].createElement("div", {
|
|
38862
|
+
className: "plc-flex plc-justify-between plc-text-gray-900"
|
|
38863
|
+
}, /*#__PURE__*/React__default['default'].createElement("dt", {
|
|
38864
|
+
className: "plc-text-base"
|
|
38865
|
+
}, t("labels.tax")), /*#__PURE__*/React__default['default'].createElement("dd", {
|
|
38866
|
+
className: "plc-text-base"
|
|
38867
|
+
}, taxRate)), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
38819
38868
|
className: "plc-flex plc-justify-between plc-border-t plc-border-gray-200 plc-pt-6 plc-text-gray-900"
|
|
38820
38869
|
}, /*#__PURE__*/React__default['default'].createElement("dt", {
|
|
38821
38870
|
className: "plc-text-base"
|
|
@@ -40098,7 +40147,7 @@ BillingAddressSelectModal.viewId = "billing-address-select";
|
|
|
40098
40147
|
const moveDefaultPaymentMethodToStart = paymentMethods => {
|
|
40099
40148
|
const defaultPaymentMethod = getDefaultPaymentMethod(paymentMethods);
|
|
40100
40149
|
const paymentMethodsWithoutDefault = paymentMethods.filter(paymentMethod => paymentMethod.id !== defaultPaymentMethod.id);
|
|
40101
|
-
if (defaultPaymentMethod.status !== "chargeable") {
|
|
40150
|
+
if ((defaultPaymentMethod === null || defaultPaymentMethod === void 0 ? void 0 : defaultPaymentMethod.status) !== "chargeable") {
|
|
40102
40151
|
return paymentMethodsWithoutDefault;
|
|
40103
40152
|
}
|
|
40104
40153
|
return [defaultPaymentMethod, ...paymentMethodsWithoutDefault];
|
package/dist/index.esm.js
CHANGED
|
@@ -3753,7 +3753,8 @@ var labels$X = {
|
|
|
3753
3753
|
summary: "Order summary",
|
|
3754
3754
|
total: "Total",
|
|
3755
3755
|
subtotal: "Subtotal",
|
|
3756
|
-
shippingRate: "Shipping Rate"
|
|
3756
|
+
shippingRate: "Shipping Rate",
|
|
3757
|
+
tax: "Tax"
|
|
3757
3758
|
};
|
|
3758
3759
|
var shop_en = {
|
|
3759
3760
|
buttons: buttons$h,
|
|
@@ -9522,7 +9523,7 @@ const trackSubscriptionOnGA = () => {
|
|
|
9522
9523
|
couponCode
|
|
9523
9524
|
} = usePelcro.getStore();
|
|
9524
9525
|
|
|
9525
|
-
/*
|
|
9526
|
+
/*
|
|
9526
9527
|
getting the latest subscription id from invoices instead of subscriptions
|
|
9527
9528
|
to handle gifted subs which are not added to subs list
|
|
9528
9529
|
*/
|
|
@@ -9733,6 +9734,10 @@ const refreshUser = () => {
|
|
|
9733
9734
|
}
|
|
9734
9735
|
});
|
|
9735
9736
|
};
|
|
9737
|
+
const isStagingEnvironment = () => {
|
|
9738
|
+
var _window$Pelcro$enviro2;
|
|
9739
|
+
return (_window$Pelcro$enviro2 = window.Pelcro.environment) === null || _window$Pelcro$enviro2 === void 0 ? void 0 : _window$Pelcro$enviro2.domain.includes("staging");
|
|
9740
|
+
};
|
|
9736
9741
|
|
|
9737
9742
|
const resources = {
|
|
9738
9743
|
en: {
|
|
@@ -25948,6 +25953,9 @@ const ImageSelect = ({
|
|
|
25948
25953
|
components: {
|
|
25949
25954
|
Option: customOption,
|
|
25950
25955
|
SingleValue: customSingleValue
|
|
25956
|
+
},
|
|
25957
|
+
classNames: {
|
|
25958
|
+
menuList: () => "menu-list"
|
|
25951
25959
|
}
|
|
25952
25960
|
}, props, {
|
|
25953
25961
|
menuPortalTarget: document.body,
|
|
@@ -38694,28 +38702,56 @@ const OrderCreateSummary = ({
|
|
|
38694
38702
|
} = useTranslation("shop");
|
|
38695
38703
|
const [items, setItems] = useState([]);
|
|
38696
38704
|
const [paymentInfo, setPaymentInfo] = useState({});
|
|
38705
|
+
const {
|
|
38706
|
+
selectedAddressId
|
|
38707
|
+
} = usePelcro();
|
|
38708
|
+
async function fetchOrderSummary(orderSummaryPaylod) {
|
|
38709
|
+
try {
|
|
38710
|
+
const domain = isStagingEnvironment() ? "https://staging.pelcro.com" : "https://www.pelcro.com";
|
|
38711
|
+
const url = `${domain}/api/v1/sdk/ecommerce/order-summary`;
|
|
38712
|
+
const response = await fetch(url, {
|
|
38713
|
+
method: "POST",
|
|
38714
|
+
headers: {
|
|
38715
|
+
"Content-Type": "application/json",
|
|
38716
|
+
Authorization: `Bearer ${window.Pelcro.user.read().auth_token}`
|
|
38717
|
+
},
|
|
38718
|
+
body: JSON.stringify(orderSummaryPaylod)
|
|
38719
|
+
});
|
|
38720
|
+
if (response.ok) {
|
|
38721
|
+
var _data$data;
|
|
38722
|
+
const data = await response.json();
|
|
38723
|
+
console.log("data", data);
|
|
38724
|
+
setPaymentInfo({
|
|
38725
|
+
total: data === null || data === void 0 ? void 0 : data.data.total,
|
|
38726
|
+
shippingRate: data === null || data === void 0 ? void 0 : data.data.shipping_rate,
|
|
38727
|
+
subtotal: data === null || data === void 0 ? void 0 : data.data.subtotal,
|
|
38728
|
+
taxes: data === null || data === void 0 ? void 0 : (_data$data = data.data) === null || _data$data === void 0 ? void 0 : _data$data.tax_rate
|
|
38729
|
+
});
|
|
38730
|
+
}
|
|
38731
|
+
} catch (error) {
|
|
38732
|
+
console.error(error);
|
|
38733
|
+
}
|
|
38734
|
+
}
|
|
38697
38735
|
useEffect(() => {
|
|
38736
|
+
var _window$Pelcro$site$r;
|
|
38698
38737
|
if (!(order !== null && order !== void 0 && order.length) || paymentInfo !== null && paymentInfo !== void 0 && paymentInfo.total) {
|
|
38699
38738
|
return;
|
|
38700
38739
|
}
|
|
38701
|
-
|
|
38740
|
+
const orderSummaryPaylod = {
|
|
38702
38741
|
items: order.map(item => {
|
|
38703
38742
|
return {
|
|
38704
38743
|
sku_id: item.id,
|
|
38705
38744
|
quantity: item.quantity
|
|
38706
38745
|
};
|
|
38707
38746
|
})
|
|
38708
|
-
}
|
|
38709
|
-
|
|
38710
|
-
|
|
38711
|
-
|
|
38712
|
-
|
|
38713
|
-
|
|
38714
|
-
|
|
38715
|
-
|
|
38716
|
-
});
|
|
38717
|
-
});
|
|
38718
|
-
}, [order, paymentInfo === null || paymentInfo === void 0 ? void 0 : paymentInfo.total]);
|
|
38747
|
+
};
|
|
38748
|
+
if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.taxes_enabled) {
|
|
38749
|
+
orderSummaryPaylod.address_id = selectedAddressId;
|
|
38750
|
+
}
|
|
38751
|
+
orderSummaryPaylod.site_id = window.Pelcro.siteid;
|
|
38752
|
+
console.log("orderSummaryPaylod", orderSummaryPaylod);
|
|
38753
|
+
fetchOrderSummary(orderSummaryPaylod);
|
|
38754
|
+
}, [order, paymentInfo === null || paymentInfo === void 0 ? void 0 : paymentInfo.total, selectedAddressId]);
|
|
38719
38755
|
useEffect(() => {
|
|
38720
38756
|
const isQuickPurchase = !Array.isArray(order);
|
|
38721
38757
|
if (isQuickPurchase) {
|
|
@@ -38733,9 +38769,16 @@ const OrderCreateSummary = ({
|
|
|
38733
38769
|
var _order$2;
|
|
38734
38770
|
return getFormattedPriceByLocal((paymentInfo === null || paymentInfo === void 0 ? void 0 : paymentInfo.shippingRate) || 0, order === null || order === void 0 ? void 0 : (_order$2 = order[0]) === null || _order$2 === void 0 ? void 0 : _order$2.currency, getPageOrDefaultLanguage());
|
|
38735
38771
|
}, [paymentInfo === null || paymentInfo === void 0 ? void 0 : paymentInfo.shippingRate, order]);
|
|
38736
|
-
const
|
|
38772
|
+
const taxRate = useMemo(() => {
|
|
38737
38773
|
var _order$3;
|
|
38738
|
-
|
|
38774
|
+
if (!(paymentInfo !== null && paymentInfo !== void 0 && paymentInfo.taxes)) {
|
|
38775
|
+
return "0";
|
|
38776
|
+
}
|
|
38777
|
+
return getFormattedPriceByLocal((paymentInfo === null || paymentInfo === void 0 ? void 0 : paymentInfo.taxes) || 0, order === null || order === void 0 ? void 0 : (_order$3 = order[0]) === null || _order$3 === void 0 ? void 0 : _order$3.currency, getPageOrDefaultLanguage());
|
|
38778
|
+
}, [paymentInfo === null || paymentInfo === void 0 ? void 0 : paymentInfo.taxes, order]);
|
|
38779
|
+
const total = useMemo(() => {
|
|
38780
|
+
var _order$4;
|
|
38781
|
+
return getFormattedPriceByLocal((paymentInfo === null || paymentInfo === void 0 ? void 0 : paymentInfo.total) || 0, order === null || order === void 0 ? void 0 : (_order$4 = order[0]) === null || _order$4 === void 0 ? void 0 : _order$4.currency, getPageOrDefaultLanguage());
|
|
38739
38782
|
}, [paymentInfo === null || paymentInfo === void 0 ? void 0 : paymentInfo.total, order]);
|
|
38740
38783
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
38741
38784
|
className: "plc-px-8 md:plc-px-0"
|
|
@@ -38785,7 +38828,13 @@ const OrderCreateSummary = ({
|
|
|
38785
38828
|
className: "plc-text-base"
|
|
38786
38829
|
}, t("labels.shippingRate")), /*#__PURE__*/React__default.createElement("dd", {
|
|
38787
38830
|
className: "plc-text-base"
|
|
38788
|
-
}, shippingRate)), /*#__PURE__*/React__default.createElement("div", {
|
|
38831
|
+
}, shippingRate)), taxRate !== "0" && /*#__PURE__*/React__default.createElement("div", {
|
|
38832
|
+
className: "plc-flex plc-justify-between plc-text-gray-900"
|
|
38833
|
+
}, /*#__PURE__*/React__default.createElement("dt", {
|
|
38834
|
+
className: "plc-text-base"
|
|
38835
|
+
}, t("labels.tax")), /*#__PURE__*/React__default.createElement("dd", {
|
|
38836
|
+
className: "plc-text-base"
|
|
38837
|
+
}, taxRate)), /*#__PURE__*/React__default.createElement("div", {
|
|
38789
38838
|
className: "plc-flex plc-justify-between plc-border-t plc-border-gray-200 plc-pt-6 plc-text-gray-900"
|
|
38790
38839
|
}, /*#__PURE__*/React__default.createElement("dt", {
|
|
38791
38840
|
className: "plc-text-base"
|
|
@@ -40068,7 +40117,7 @@ BillingAddressSelectModal.viewId = "billing-address-select";
|
|
|
40068
40117
|
const moveDefaultPaymentMethodToStart = paymentMethods => {
|
|
40069
40118
|
const defaultPaymentMethod = getDefaultPaymentMethod(paymentMethods);
|
|
40070
40119
|
const paymentMethodsWithoutDefault = paymentMethods.filter(paymentMethod => paymentMethod.id !== defaultPaymentMethod.id);
|
|
40071
|
-
if (defaultPaymentMethod.status !== "chargeable") {
|
|
40120
|
+
if ((defaultPaymentMethod === null || defaultPaymentMethod === void 0 ? void 0 : defaultPaymentMethod.status) !== "chargeable") {
|
|
40072
40121
|
return paymentMethodsWithoutDefault;
|
|
40073
40122
|
}
|
|
40074
40123
|
return [defaultPaymentMethod, ...paymentMethodsWithoutDefault];
|
package/dist/pelcro.css
CHANGED
|
@@ -1959,6 +1959,14 @@ Add the correct display in Chrome and Safari.
|
|
|
1959
1959
|
align-items: center;
|
|
1960
1960
|
}
|
|
1961
1961
|
|
|
1962
|
+
.menu-list {
|
|
1963
|
+
font-family: "Lato", system-ui, -apple-system,
|
|
1964
|
+
/* Firefox supports this but not yet `system-ui` */
|
|
1965
|
+
"Segoe UI",
|
|
1966
|
+
Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji",
|
|
1967
|
+
"Segoe UI Emoji";
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1962
1970
|
/*
|
|
1963
1971
|
styling is copied from react-easy-crop/react-easy-crop.css
|
|
1964
1972
|
in order to scope selectors under pelcro-root
|
|
@@ -4138,6 +4146,14 @@ apple-pay-button {
|
|
|
4138
4146
|
align-items: center;
|
|
4139
4147
|
}
|
|
4140
4148
|
|
|
4149
|
+
.menu-list {
|
|
4150
|
+
font-family: "Lato", system-ui, -apple-system,
|
|
4151
|
+
/* Firefox supports this but not yet `system-ui` */
|
|
4152
|
+
"Segoe UI",
|
|
4153
|
+
Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji",
|
|
4154
|
+
"Segoe UI Emoji";
|
|
4155
|
+
}
|
|
4156
|
+
|
|
4141
4157
|
/* purgecss end ignore */
|
|
4142
4158
|
|
|
4143
4159
|
/* purgecss start ignore */
|