@salesgenterp/ui-components 0.4.336 → 0.4.338
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.js +146 -7
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +146 -7
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10891,6 +10891,124 @@ var InfoItem = function InfoItem(_ref3) {
|
|
|
10891
10891
|
};
|
|
10892
10892
|
var InfoItemContainer = styled__default.div(_templateObject2$y || (_templateObject2$y = _taggedTemplateLiteralLoose(["\n background: #00000010;\n padding: 0.5rem;\n"])));
|
|
10893
10893
|
|
|
10894
|
+
var PaypalComponent = function PaypalComponent(_ref) {
|
|
10895
|
+
var apiEndPoint = _ref.apiEndPoint,
|
|
10896
|
+
token = _ref.token,
|
|
10897
|
+
paymentWithPaypal = _ref.paymentWithPaypal,
|
|
10898
|
+
paymentInfo = _ref.paymentInfo,
|
|
10899
|
+
onSubmit = _ref.onSubmit,
|
|
10900
|
+
orderTotal = _ref.orderTotal;
|
|
10901
|
+
var isScriptInitialized;
|
|
10902
|
+
var paypalInterval;
|
|
10903
|
+
var renderPaypalScripts = function renderPaypalScripts(paypalClientId) {
|
|
10904
|
+
try {
|
|
10905
|
+
return Promise.resolve(new Promise(function (resolve, reject) {
|
|
10906
|
+
if (!isScriptInitialized && !window.paypal) {
|
|
10907
|
+
isScriptInitialized = true;
|
|
10908
|
+
var PAYPAL_SCRIPT = "https://www.paypal.com/sdk/js?client-id=" + paypalClientId;
|
|
10909
|
+
var script = document.createElement('script');
|
|
10910
|
+
script.setAttribute('src', PAYPAL_SCRIPT);
|
|
10911
|
+
document.body.appendChild(script);
|
|
10912
|
+
}
|
|
10913
|
+
if (window.paypal) {
|
|
10914
|
+
return resolve();
|
|
10915
|
+
}
|
|
10916
|
+
paypalInterval = setInterval(function () {
|
|
10917
|
+
if (window.paypal) {
|
|
10918
|
+
resolve();
|
|
10919
|
+
clearInterval(paypalInterval);
|
|
10920
|
+
}
|
|
10921
|
+
}, 1000);
|
|
10922
|
+
}));
|
|
10923
|
+
} catch (e) {
|
|
10924
|
+
return Promise.reject(e);
|
|
10925
|
+
}
|
|
10926
|
+
};
|
|
10927
|
+
var viewPaypalContainer = function viewPaypalContainer(isLoading) {
|
|
10928
|
+
var paypalLoading = document.querySelector('.paypal-loading');
|
|
10929
|
+
var paypalContainer = document.querySelector('.paypal-container');
|
|
10930
|
+
if (paypalLoading && paypalContainer) {
|
|
10931
|
+
if (isLoading) {
|
|
10932
|
+
paypalLoading.style.display = "block";
|
|
10933
|
+
paypalContainer.style.display = "none";
|
|
10934
|
+
} else {
|
|
10935
|
+
paypalLoading.style.display = "none";
|
|
10936
|
+
paypalContainer.style.display = "block";
|
|
10937
|
+
}
|
|
10938
|
+
}
|
|
10939
|
+
};
|
|
10940
|
+
React.useEffect(function () {
|
|
10941
|
+
(function () {
|
|
10942
|
+
try {
|
|
10943
|
+
var _temp2 = function () {
|
|
10944
|
+
if (paymentWithPaypal) {
|
|
10945
|
+
return Promise.resolve(API$1({
|
|
10946
|
+
apiEndPoint: apiEndPoint,
|
|
10947
|
+
token: token,
|
|
10948
|
+
url: "/payment/paypal/config"
|
|
10949
|
+
})).then(function (paypalObject) {
|
|
10950
|
+
var _temp = function () {
|
|
10951
|
+
if (paypalObject.customerId) {
|
|
10952
|
+
return Promise.resolve(renderPaypalScripts(paypalObject.customerId)).then(function () {
|
|
10953
|
+
window.paypal.Buttons({
|
|
10954
|
+
createOrder: function createOrder(data, actions) {
|
|
10955
|
+
if (erLocalStorage.getItem('checkoutIsTermsAccepted') !== 'true') {
|
|
10956
|
+
throw {
|
|
10957
|
+
message: 'Please accept terms and conditions.'
|
|
10958
|
+
};
|
|
10959
|
+
}
|
|
10960
|
+
return actions.order.create({
|
|
10961
|
+
purchase_units: [{
|
|
10962
|
+
amount: {
|
|
10963
|
+
value: (orderTotal === null || orderTotal === void 0 ? void 0 : orderTotal.totalAmount) || 0
|
|
10964
|
+
}
|
|
10965
|
+
}]
|
|
10966
|
+
});
|
|
10967
|
+
},
|
|
10968
|
+
onApprove: function (data, actions) {
|
|
10969
|
+
try {
|
|
10970
|
+
return Promise.resolve(actions.order.capture().then(function (details) {
|
|
10971
|
+
onSubmit(details.id);
|
|
10972
|
+
}));
|
|
10973
|
+
} catch (e) {
|
|
10974
|
+
return Promise.reject(e);
|
|
10975
|
+
}
|
|
10976
|
+
},
|
|
10977
|
+
onCancel: function onCancel(data) {
|
|
10978
|
+
alert('PayPal payment cancelled');
|
|
10979
|
+
},
|
|
10980
|
+
onError: function onError(err) {
|
|
10981
|
+
alert((err === null || err === void 0 ? void 0 : err.message) || 'Payment cannot be performed');
|
|
10982
|
+
}
|
|
10983
|
+
}).render('#paypal-button-container');
|
|
10984
|
+
viewPaypalContainer(false);
|
|
10985
|
+
});
|
|
10986
|
+
}
|
|
10987
|
+
}();
|
|
10988
|
+
if (_temp && _temp.then) return _temp.then(function () {});
|
|
10989
|
+
});
|
|
10990
|
+
}
|
|
10991
|
+
}();
|
|
10992
|
+
return _temp2 && _temp2.then ? _temp2.then(function () {}) : void 0;
|
|
10993
|
+
} catch (e) {
|
|
10994
|
+
Promise.reject(e);
|
|
10995
|
+
}
|
|
10996
|
+
})();
|
|
10997
|
+
}, []);
|
|
10998
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
|
|
10999
|
+
css: {
|
|
11000
|
+
display: paymentInfo && paymentInfo.name === 'PayPal' ? 'block' : 'none'
|
|
11001
|
+
}
|
|
11002
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
11003
|
+
className: "paypal-loading"
|
|
11004
|
+
}, /*#__PURE__*/React__default.createElement(Loader, {
|
|
11005
|
+
height: 100
|
|
11006
|
+
})), /*#__PURE__*/React__default.createElement("div", {
|
|
11007
|
+
className: "paypal-container",
|
|
11008
|
+
id: "paypal-button-container"
|
|
11009
|
+
})));
|
|
11010
|
+
};
|
|
11011
|
+
|
|
10894
11012
|
var Step4 = function Step4(_ref) {
|
|
10895
11013
|
var _cartData$cartLineIte;
|
|
10896
11014
|
var apiEndPoint = _ref.apiEndPoint,
|
|
@@ -10909,7 +11027,9 @@ var Step4 = function Step4(_ref) {
|
|
|
10909
11027
|
customer = _ref.customer,
|
|
10910
11028
|
shippingInformation = _ref.shippingInformation,
|
|
10911
11029
|
taxExempt = _ref.taxExempt,
|
|
10912
|
-
orderTotal = _ref.orderTotal
|
|
11030
|
+
orderTotal = _ref.orderTotal,
|
|
11031
|
+
paymentWithPaypal = _ref.paymentWithPaypal,
|
|
11032
|
+
selectedPaymentMethod = _ref.selectedPaymentMethod;
|
|
10913
11033
|
var _React$useState = React__default.useState(false),
|
|
10914
11034
|
checked = _React$useState[0],
|
|
10915
11035
|
setChecked = _React$useState[1];
|
|
@@ -10924,6 +11044,13 @@ var Step4 = function Step4(_ref) {
|
|
|
10924
11044
|
discountTotal = discountTotal + element.amount;
|
|
10925
11045
|
});
|
|
10926
11046
|
var storeCr = storeCredits > (orderTotal === null || orderTotal === void 0 ? void 0 : orderTotal.totalAmount) ? orderTotal === null || orderTotal === void 0 ? void 0 : orderTotal.totalAmount : storeCredits;
|
|
11047
|
+
var onSubmitPaypal = function onSubmitPaypal(transactionId) {
|
|
11048
|
+
try {
|
|
11049
|
+
return Promise.resolve(placeOrder(comments, transactionId)).then(function () {});
|
|
11050
|
+
} catch (e) {
|
|
11051
|
+
return Promise.reject(e);
|
|
11052
|
+
}
|
|
11053
|
+
};
|
|
10927
11054
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, openConsentForm && /*#__PURE__*/React__default.createElement(ConsentForm, {
|
|
10928
11055
|
apiEndPoint: apiEndPoint,
|
|
10929
11056
|
token: token,
|
|
@@ -11148,9 +11275,10 @@ var Step4 = function Step4(_ref) {
|
|
|
11148
11275
|
size: "small",
|
|
11149
11276
|
value: checked,
|
|
11150
11277
|
onChange: function onChange() {
|
|
11151
|
-
|
|
11278
|
+
setChecked(function (checked) {
|
|
11152
11279
|
return !checked;
|
|
11153
11280
|
});
|
|
11281
|
+
erLocalStorage.setItem('checkoutIsTermsAccepted', !checked);
|
|
11154
11282
|
},
|
|
11155
11283
|
required: true
|
|
11156
11284
|
}), /*#__PURE__*/React__default.createElement("p", null, "I Accept the \xA0", /*#__PURE__*/React__default.createElement("span", {
|
|
@@ -11180,7 +11308,7 @@ var Step4 = function Step4(_ref) {
|
|
|
11180
11308
|
onClick: function onClick() {
|
|
11181
11309
|
return handleBack();
|
|
11182
11310
|
}
|
|
11183
|
-
}, "back"), /*#__PURE__*/React__default.createElement("button", {
|
|
11311
|
+
}, "back"), !(paymentWithPaypal && (selectedPaymentMethod === null || selectedPaymentMethod === void 0 ? void 0 : selectedPaymentMethod.name) === 'PayPal') && /*#__PURE__*/React__default.createElement("button", {
|
|
11184
11312
|
onClick: function onClick(e) {
|
|
11185
11313
|
try {
|
|
11186
11314
|
e.preventDefault();
|
|
@@ -11212,7 +11340,14 @@ var Step4 = function Step4(_ref) {
|
|
|
11212
11340
|
style: {
|
|
11213
11341
|
margin: '0 2.8em'
|
|
11214
11342
|
}
|
|
11215
|
-
}) : 'place order')))
|
|
11343
|
+
}) : 'place order')), paymentWithPaypal && (selectedPaymentMethod === null || selectedPaymentMethod === void 0 ? void 0 : selectedPaymentMethod.name) === 'PayPal' && /*#__PURE__*/React__default.createElement(PaypalComponent, {
|
|
11344
|
+
apiEndPoint: apiEndPoint,
|
|
11345
|
+
token: token,
|
|
11346
|
+
paymentWithPaypal: paymentWithPaypal,
|
|
11347
|
+
paymentInfo: selectedPaymentMethod,
|
|
11348
|
+
onSubmit: onSubmitPaypal,
|
|
11349
|
+
orderTotal: orderTotal
|
|
11350
|
+
})))))));
|
|
11216
11351
|
};
|
|
11217
11352
|
|
|
11218
11353
|
var steps = [{
|
|
@@ -11246,6 +11381,7 @@ var CheckoutPageComponent = function CheckoutPageComponent(_ref) {
|
|
|
11246
11381
|
var apiEndPoint = _ref.apiEndPoint,
|
|
11247
11382
|
token = _ref.token,
|
|
11248
11383
|
authoriseDotNet = _ref.authoriseDotNet,
|
|
11384
|
+
paymentWithPaypal = _ref.paymentWithPaypal,
|
|
11249
11385
|
ccProcessingFees = _ref.ccProcessingFees,
|
|
11250
11386
|
styles = _ref.styles,
|
|
11251
11387
|
cartData = _ref.cartData,
|
|
@@ -11526,7 +11662,7 @@ var CheckoutPageComponent = function CheckoutPageComponent(_ref) {
|
|
|
11526
11662
|
setSelectedPaymentMethod(paymentMethod);
|
|
11527
11663
|
}
|
|
11528
11664
|
};
|
|
11529
|
-
var onPlaceOrder = function onPlaceOrder(note) {
|
|
11665
|
+
var onPlaceOrder = function onPlaceOrder(note, transactionId) {
|
|
11530
11666
|
try {
|
|
11531
11667
|
var _temp15 = function _temp15() {
|
|
11532
11668
|
setOrdering(false);
|
|
@@ -11602,7 +11738,8 @@ var CheckoutPageComponent = function CheckoutPageComponent(_ref) {
|
|
|
11602
11738
|
orderPaymentList = [_extends({
|
|
11603
11739
|
amount: parseFloat((_ref7 = (orderTotal === null || orderTotal === void 0 ? void 0 : orderTotal.totalAmount) - discountTotal) === null || _ref7 === void 0 ? void 0 : _ref7.toFixed(2)),
|
|
11604
11740
|
paymentModeId: selectedPaymentMethod === null || selectedPaymentMethod === void 0 ? void 0 : selectedPaymentMethod.id,
|
|
11605
|
-
customerOrderCard: ecommerceCustomPaymentDto
|
|
11741
|
+
customerOrderCard: ecommerceCustomPaymentDto,
|
|
11742
|
+
transactionId: transactionId
|
|
11606
11743
|
}, authorizeCustomerCardData)];
|
|
11607
11744
|
}
|
|
11608
11745
|
var paymentDtoList = orderPaymentList;
|
|
@@ -11799,7 +11936,9 @@ var CheckoutPageComponent = function CheckoutPageComponent(_ref) {
|
|
|
11799
11936
|
return (item === null || item === void 0 ? void 0 : item.id) === shippingAddressId;
|
|
11800
11937
|
}),
|
|
11801
11938
|
taxExempt: taxExempt,
|
|
11802
|
-
orderTotal: orderTotal
|
|
11939
|
+
orderTotal: orderTotal,
|
|
11940
|
+
paymentWithPaypal: paymentWithPaypal,
|
|
11941
|
+
selectedPaymentMethod: selectedPaymentMethod
|
|
11803
11942
|
})));
|
|
11804
11943
|
}))))), /*#__PURE__*/React__default.createElement(CheckoutSummary, {
|
|
11805
11944
|
billingInformation: customer === null || customer === void 0 ? void 0 : (_customer$customerDto12 = customer.customerDto) === null || _customer$customerDto12 === void 0 ? void 0 : (_customer$customerDto13 = _customer$customerDto12.customerStoreAddressList) === null || _customer$customerDto13 === void 0 ? void 0 : _customer$customerDto13.find(function (item) {
|