@salesgenterp/ui-components 0.4.335 → 0.4.337

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 CHANGED
@@ -4812,7 +4812,8 @@ var LandingCarousel = function LandingCarousel(_ref) {
4812
4812
  var _brandData2;
4813
4813
  var brandList = _ref.brandList,
4814
4814
  noImgUrl = _ref.noImgUrl,
4815
- isSlider = _ref.isSlider;
4815
+ isSlider = _ref.isSlider,
4816
+ filterNoUrlData = _ref.filterNoUrlData;
4816
4817
  var brandListData = (brandList === null || brandList === void 0 ? void 0 : brandList.content) || [];
4817
4818
  var spaceBetweenCol = 4;
4818
4819
  var brandData = function brandData() {
@@ -4859,10 +4860,14 @@ var LandingCarousel = function LandingCarousel(_ref) {
4859
4860
  var _brandData;
4860
4861
  return /*#__PURE__*/React__default.createElement(Root$6, null, /*#__PURE__*/React__default.createElement(material.Grid, {
4861
4862
  container: true,
4862
- spacing: 1
4863
+ spacing: 1,
4864
+ justifyContent: 'center'
4863
4865
  }, (_brandData = brandData()) === null || _brandData === void 0 ? void 0 : _brandData.map(function (item, i) {
4864
- var _item$brandAttachment, _item$brandAttachment2;
4866
+ var _item$brandAttachment, _item$brandAttachment2, _item$brandAttachment3, _item$brandAttachment4;
4865
4867
  var brand = item === null || item === void 0 ? void 0 : (_item$brandAttachment = item.brandAttachmentMap) === null || _item$brandAttachment === void 0 ? void 0 : (_item$brandAttachment2 = _item$brandAttachment['Brand Logo']) === null || _item$brandAttachment2 === void 0 ? void 0 : _item$brandAttachment2[0];
4868
+ if (filterNoUrlData && !(item !== null && item !== void 0 && (_item$brandAttachment3 = item.brandAttachmentMap) !== null && _item$brandAttachment3 !== void 0 && (_item$brandAttachment4 = _item$brandAttachment3['Brand Logo']) !== null && _item$brandAttachment4 !== void 0 && _item$brandAttachment4[0])) {
4869
+ return;
4870
+ }
4866
4871
  return /*#__PURE__*/React__default.createElement(material.Grid, {
4867
4872
  item: true,
4868
4873
  key: i
@@ -4892,8 +4897,8 @@ var LandingCarousel = function LandingCarousel(_ref) {
4892
4897
  }), /*#__PURE__*/React__default.createElement(ReactSlick, _extends({}, settings(), {
4893
4898
  spaceBetweenCol: spaceBetweenCol
4894
4899
  }), (_brandData2 = brandData()) === null || _brandData2 === void 0 ? void 0 : _brandData2.map(function (item, i) {
4895
- var _item$brandAttachment3, _item$brandAttachment4;
4896
- var brand = item === null || item === void 0 ? void 0 : (_item$brandAttachment3 = item.brandAttachmentMap) === null || _item$brandAttachment3 === void 0 ? void 0 : (_item$brandAttachment4 = _item$brandAttachment3['Brand Logo']) === null || _item$brandAttachment4 === void 0 ? void 0 : _item$brandAttachment4[0];
4900
+ var _item$brandAttachment5, _item$brandAttachment6;
4901
+ var brand = item === null || item === void 0 ? void 0 : (_item$brandAttachment5 = item.brandAttachmentMap) === null || _item$brandAttachment5 === void 0 ? void 0 : (_item$brandAttachment6 = _item$brandAttachment5['Brand Logo']) === null || _item$brandAttachment6 === void 0 ? void 0 : _item$brandAttachment6[0];
4897
4902
  return /*#__PURE__*/React__default.createElement(SliderItem, null, /*#__PURE__*/React__default.createElement("a", {
4898
4903
  href: (brand === null || brand === void 0 ? void 0 : brand.redirectPath) || ''
4899
4904
  }, isVideo(brand === null || brand === void 0 ? void 0 : brand.url) ? /*#__PURE__*/React__default.createElement(Video, {
@@ -4930,7 +4935,9 @@ var BrandList = function BrandList(_ref) {
4930
4935
  size = _ref$size === void 0 ? 20 : _ref$size,
4931
4936
  _ref$isSlider = _ref.isSlider,
4932
4937
  isSlider = _ref$isSlider === void 0 ? true : _ref$isSlider,
4933
- noImgUrl = _ref.noImgUrl;
4938
+ noImgUrl = _ref.noImgUrl,
4939
+ _ref$filterNoUrlData = _ref.filterNoUrlData,
4940
+ filterNoUrlData = _ref$filterNoUrlData === void 0 ? false : _ref$filterNoUrlData;
4934
4941
  var _useState = React.useState(false),
4935
4942
  loading = _useState[0],
4936
4943
  setLoading = _useState[1];
@@ -4963,7 +4970,8 @@ var BrandList = function BrandList(_ref) {
4963
4970
  }, /*#__PURE__*/React__default.createElement(Root$7, null, /*#__PURE__*/React__default.createElement(material.CssBaseline, null), /*#__PURE__*/React__default.createElement(MainContainer$1, null, loading ? /*#__PURE__*/React__default.createElement(Loader, null) : /*#__PURE__*/React__default.createElement(LandingCarousel, {
4964
4971
  brandList: brandList,
4965
4972
  noImgUrl: noImgUrl,
4966
- isSlider: isSlider
4973
+ isSlider: isSlider,
4974
+ filterNoUrlData: filterNoUrlData
4967
4975
  }))));
4968
4976
  };
4969
4977
  var Root$7 = styled__default.div(_templateObject$p || (_templateObject$p = _taggedTemplateLiteralLoose([""])));
@@ -10883,6 +10891,124 @@ var InfoItem = function InfoItem(_ref3) {
10883
10891
  };
10884
10892
  var InfoItemContainer = styled__default.div(_templateObject2$y || (_templateObject2$y = _taggedTemplateLiteralLoose(["\n background: #00000010;\n padding: 0.5rem;\n"])));
10885
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
+ checked = _ref.checked,
10902
+ loading = _ref.loading;
10903
+ var isScriptInitialized;
10904
+ var paypalInterval;
10905
+ var renderPaypalScripts = function renderPaypalScripts(paypalClientId) {
10906
+ try {
10907
+ return Promise.resolve(new Promise(function (resolve, reject) {
10908
+ if (!isScriptInitialized && !window.paypal) {
10909
+ isScriptInitialized = true;
10910
+ var PAYPAL_SCRIPT = "https://www.paypal.com/sdk/js?client-id=" + paypalClientId;
10911
+ var script = document.createElement('script');
10912
+ script.setAttribute('src', PAYPAL_SCRIPT);
10913
+ document.body.appendChild(script);
10914
+ }
10915
+ if (window.paypal) {
10916
+ return resolve();
10917
+ }
10918
+ paypalInterval = setInterval(function () {
10919
+ if (window.paypal) {
10920
+ resolve();
10921
+ clearInterval(paypalInterval);
10922
+ }
10923
+ }, 1000);
10924
+ }));
10925
+ } catch (e) {
10926
+ return Promise.reject(e);
10927
+ }
10928
+ };
10929
+ var setCreateOrderLoading = function setCreateOrderLoading(isLoading) {
10930
+ var paypalLoading = document.querySelector('.paypal-loading');
10931
+ var paypalContainer = document.querySelector('.paypal-container');
10932
+ if (paypalLoading && paypalContainer) {
10933
+ if (isLoading) {
10934
+ paypalLoading.style.display = "block";
10935
+ paypalContainer.style.display = "none";
10936
+ } else {
10937
+ paypalLoading.style.display = "none";
10938
+ paypalContainer.style.display = "block";
10939
+ }
10940
+ }
10941
+ };
10942
+ React.useEffect(function () {
10943
+ (function () {
10944
+ try {
10945
+ var _temp = function () {
10946
+ if (paymentWithPaypal) {
10947
+ return Promise.resolve(API$1({
10948
+ apiEndPoint: apiEndPoint,
10949
+ token: token,
10950
+ url: "/payment/paypal/config"
10951
+ })).then(function (paypalObject) {
10952
+ return Promise.resolve(renderPaypalScripts(paypalObject.customerId)).then(function () {
10953
+ window.paypal.Buttons({
10954
+ createOrder: function createOrder(data, actions) {
10955
+ if (!checked) {
10956
+ throw {
10957
+ message: 'Please accept terms and conditions.'
10958
+ };
10959
+ }
10960
+ if (loading) {
10961
+ throw {
10962
+ message: 'We are placing your order, please wait.'
10963
+ };
10964
+ }
10965
+ return actions.order.create({
10966
+ purchase_units: [{
10967
+ amount: {
10968
+ value: (orderTotal === null || orderTotal === void 0 ? void 0 : orderTotal.totalAmount) || 0
10969
+ }
10970
+ }]
10971
+ });
10972
+ },
10973
+ onApprove: function (data, actions) {
10974
+ try {
10975
+ return Promise.resolve(actions.order.capture().then(function (details) {
10976
+ onSubmit(details.id);
10977
+ }));
10978
+ } catch (e) {
10979
+ return Promise.reject(e);
10980
+ }
10981
+ },
10982
+ onCancel: function onCancel(data) {
10983
+ alert('PayPal payment cancelled');
10984
+ },
10985
+ onError: function onError(err) {
10986
+ alert((err === null || err === void 0 ? void 0 : err.message) || 'Payment cannot be performed');
10987
+ }
10988
+ }).render('#paypal-button-container');
10989
+ setCreateOrderLoading(false);
10990
+ });
10991
+ });
10992
+ }
10993
+ }();
10994
+ return _temp && _temp.then ? _temp.then(function () {}) : void 0;
10995
+ } catch (e) {
10996
+ Promise.reject(e);
10997
+ }
10998
+ })();
10999
+ }, []);
11000
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
11001
+ css: {
11002
+ display: paymentInfo && paymentInfo.name === 'PayPal' ? 'block' : 'none'
11003
+ }
11004
+ }, /*#__PURE__*/React__default.createElement("div", {
11005
+ className: "paypal-loading"
11006
+ }, /*#__PURE__*/React__default.createElement(material.CircularProgress, null)), /*#__PURE__*/React__default.createElement("div", {
11007
+ className: "paypal-container",
11008
+ id: "paypal-button-container"
11009
+ })));
11010
+ };
11011
+
10886
11012
  var Step4 = function Step4(_ref) {
10887
11013
  var _cartData$cartLineIte;
10888
11014
  var apiEndPoint = _ref.apiEndPoint,
@@ -10901,7 +11027,9 @@ var Step4 = function Step4(_ref) {
10901
11027
  customer = _ref.customer,
10902
11028
  shippingInformation = _ref.shippingInformation,
10903
11029
  taxExempt = _ref.taxExempt,
10904
- orderTotal = _ref.orderTotal;
11030
+ orderTotal = _ref.orderTotal,
11031
+ paymentWithPaypal = _ref.paymentWithPaypal,
11032
+ selectedPaymentMethod = _ref.selectedPaymentMethod;
10905
11033
  var _React$useState = React__default.useState(false),
10906
11034
  checked = _React$useState[0],
10907
11035
  setChecked = _React$useState[1];
@@ -10916,6 +11044,13 @@ var Step4 = function Step4(_ref) {
10916
11044
  discountTotal = discountTotal + element.amount;
10917
11045
  });
10918
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
+ };
10919
11054
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, openConsentForm && /*#__PURE__*/React__default.createElement(ConsentForm, {
10920
11055
  apiEndPoint: apiEndPoint,
10921
11056
  token: token,
@@ -11172,7 +11307,7 @@ var Step4 = function Step4(_ref) {
11172
11307
  onClick: function onClick() {
11173
11308
  return handleBack();
11174
11309
  }
11175
- }, "back"), /*#__PURE__*/React__default.createElement("button", {
11310
+ }, "back"), !(paymentWithPaypal && (selectedPaymentMethod === null || selectedPaymentMethod === void 0 ? void 0 : selectedPaymentMethod.name) === 'PayPal') && /*#__PURE__*/React__default.createElement("button", {
11176
11311
  onClick: function onClick(e) {
11177
11312
  try {
11178
11313
  e.preventDefault();
@@ -11204,7 +11339,16 @@ var Step4 = function Step4(_ref) {
11204
11339
  style: {
11205
11340
  margin: '0 2.8em'
11206
11341
  }
11207
- }) : 'place order'))))))));
11342
+ }) : 'place order')), paymentWithPaypal && (selectedPaymentMethod === null || selectedPaymentMethod === void 0 ? void 0 : selectedPaymentMethod.name) === 'PayPal' && /*#__PURE__*/React__default.createElement(PaypalComponent, {
11343
+ apiEndPoint: apiEndPoint,
11344
+ token: token,
11345
+ paymentWithPaypal: paymentWithPaypal,
11346
+ paymentInfo: selectedPaymentMethod,
11347
+ onSubmit: onSubmitPaypal,
11348
+ orderTotal: orderTotal,
11349
+ checked: checked,
11350
+ loading: loading
11351
+ })))))));
11208
11352
  };
11209
11353
 
11210
11354
  var steps = [{
@@ -11238,6 +11382,7 @@ var CheckoutPageComponent = function CheckoutPageComponent(_ref) {
11238
11382
  var apiEndPoint = _ref.apiEndPoint,
11239
11383
  token = _ref.token,
11240
11384
  authoriseDotNet = _ref.authoriseDotNet,
11385
+ paymentWithPaypal = _ref.paymentWithPaypal,
11241
11386
  ccProcessingFees = _ref.ccProcessingFees,
11242
11387
  styles = _ref.styles,
11243
11388
  cartData = _ref.cartData,
@@ -11518,7 +11663,7 @@ var CheckoutPageComponent = function CheckoutPageComponent(_ref) {
11518
11663
  setSelectedPaymentMethod(paymentMethod);
11519
11664
  }
11520
11665
  };
11521
- var onPlaceOrder = function onPlaceOrder(note) {
11666
+ var onPlaceOrder = function onPlaceOrder(note, transactionId) {
11522
11667
  try {
11523
11668
  var _temp15 = function _temp15() {
11524
11669
  setOrdering(false);
@@ -11594,7 +11739,8 @@ var CheckoutPageComponent = function CheckoutPageComponent(_ref) {
11594
11739
  orderPaymentList = [_extends({
11595
11740
  amount: parseFloat((_ref7 = (orderTotal === null || orderTotal === void 0 ? void 0 : orderTotal.totalAmount) - discountTotal) === null || _ref7 === void 0 ? void 0 : _ref7.toFixed(2)),
11596
11741
  paymentModeId: selectedPaymentMethod === null || selectedPaymentMethod === void 0 ? void 0 : selectedPaymentMethod.id,
11597
- customerOrderCard: ecommerceCustomPaymentDto
11742
+ customerOrderCard: ecommerceCustomPaymentDto,
11743
+ transactionId: transactionId
11598
11744
  }, authorizeCustomerCardData)];
11599
11745
  }
11600
11746
  var paymentDtoList = orderPaymentList;
@@ -11791,7 +11937,9 @@ var CheckoutPageComponent = function CheckoutPageComponent(_ref) {
11791
11937
  return (item === null || item === void 0 ? void 0 : item.id) === shippingAddressId;
11792
11938
  }),
11793
11939
  taxExempt: taxExempt,
11794
- orderTotal: orderTotal
11940
+ orderTotal: orderTotal,
11941
+ paymentWithPaypal: paymentWithPaypal,
11942
+ selectedPaymentMethod: selectedPaymentMethod
11795
11943
  })));
11796
11944
  }))))), /*#__PURE__*/React__default.createElement(CheckoutSummary, {
11797
11945
  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) {