@salesgenterp/ui-components 0.4.416 → 0.4.417

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
@@ -623,6 +623,142 @@ var jsonParse = function jsonParse(value) {
623
623
  }
624
624
  return value;
625
625
  };
626
+ var convertToBoolean = function convertToBoolean(value) {
627
+ return lodash.toNumber(value) === 1;
628
+ };
629
+
630
+ function useSystemFeatureList(_ref) {
631
+ var apiEndPoint = _ref.apiEndPoint,
632
+ token = _ref.token,
633
+ moduleName = _ref.moduleName,
634
+ listUpdate = _ref.listUpdate;
635
+ var _useState = React.useState(),
636
+ data = _useState[0],
637
+ setData = _useState[1];
638
+ var _useState2 = React.useState(false),
639
+ loading = _useState2[0],
640
+ setLoading = _useState2[1];
641
+ var _useState3 = React.useState(false),
642
+ error = _useState3[0],
643
+ setError = _useState3[1];
644
+ var _useState4 = React.useState(false),
645
+ status = _useState4[0],
646
+ setStatus = _useState4[1];
647
+ React.useEffect(function () {
648
+ (function () {
649
+ try {
650
+ var _temp2 = function () {
651
+ if (apiEndPoint && token) {
652
+ setError(false);
653
+ setStatus(null);
654
+ setLoading(true);
655
+ var _temp = _catch(function () {
656
+ return Promise.resolve(getSystemFeatureList({
657
+ apiEndPoint: apiEndPoint,
658
+ token: token,
659
+ moduleName: moduleName
660
+ })).then(function (modifyData) {
661
+ setData(modifyData);
662
+ setLoading(false);
663
+ });
664
+ }, function () {
665
+ setLoading(false);
666
+ setError(true);
667
+ setStatus(403);
668
+ });
669
+ if (_temp && _temp.then) return _temp.then(function () {});
670
+ }
671
+ }();
672
+ return _temp2 && _temp2.then ? _temp2.then(function () {}) : void 0;
673
+ } catch (e) {
674
+ Promise.reject(e);
675
+ }
676
+ })();
677
+ }, [moduleName, listUpdate]);
678
+ return {
679
+ systemFeatureList: data,
680
+ systemFeatureListLoading: loading,
681
+ error: error,
682
+ status: status
683
+ };
684
+ }
685
+ function useAllSystemFeatureValues(_ref4) {
686
+ var apiEndPoint = _ref4.apiEndPoint,
687
+ token = _ref4.token,
688
+ listUpdate = _ref4.listUpdate;
689
+ var _useState13 = React.useState(),
690
+ data = _useState13[0],
691
+ setData = _useState13[1];
692
+ var _useState14 = React.useState(false),
693
+ setLoading = _useState14[1];
694
+ var _useState15 = React.useState(false),
695
+ setError = _useState15[1];
696
+ var _useState16 = React.useState(false),
697
+ setStatus = _useState16[1];
698
+ var _useSystemFeatureList3 = useSystemFeatureList({
699
+ apiEndPoint: apiEndPoint,
700
+ token: token,
701
+ listUpdate: listUpdate
702
+ }),
703
+ systemFeatureListData = _useSystemFeatureList3.systemFeatureList;
704
+ React.useEffect(function () {
705
+ try {
706
+ if (apiEndPoint && token && systemFeatureListData) {
707
+ setError(false);
708
+ setStatus(null);
709
+ setLoading(true);
710
+ try {
711
+ var flattenData = function flattenData(data) {
712
+ return lodash.reduce(data, function (acc, item) {
713
+ acc = lodash.concat(acc, lodash.omit(item, 'systemFeatureList'));
714
+ if (item !== null && item !== void 0 && item.systemFeatureList) {
715
+ acc = lodash.concat(acc, flattenData(item === null || item === void 0 ? void 0 : item.systemFeatureList));
716
+ }
717
+ return acc;
718
+ }, []);
719
+ };
720
+ var flatArray = flattenData(systemFeatureListData);
721
+ var result = lodash.reduce(flatArray, function (acc, item) {
722
+ if (item !== null && item !== void 0 && item.featureName) {
723
+ acc[item === null || item === void 0 ? void 0 : item.featureName] = isNaN(item === null || item === void 0 ? void 0 : item.featureValue) ? item === null || item === void 0 ? void 0 : item.featureValue : Number(item === null || item === void 0 ? void 0 : item.featureValue) === 0 || Number(item === null || item === void 0 ? void 0 : item.featureValue) === 1 ? convertToBoolean(Number(item === null || item === void 0 ? void 0 : item.featureValue)) : Number(item === null || item === void 0 ? void 0 : item.featureValue);
724
+ }
725
+ return acc;
726
+ }, {});
727
+ setData(result);
728
+ setLoading(false);
729
+ } catch (e) {
730
+ setLoading(false);
731
+ setError(true);
732
+ setStatus(403);
733
+ }
734
+ }
735
+ } catch (e) {
736
+ Promise.reject(e);
737
+ }
738
+ }, [listUpdate, systemFeatureListData]);
739
+ return _extends({}, data);
740
+ }
741
+ var getSystemFeatureList = function getSystemFeatureList(_ref6) {
742
+ var apiEndPoint = _ref6.apiEndPoint,
743
+ token = _ref6.token,
744
+ moduleId = _ref6.moduleId,
745
+ moduleName = _ref6.moduleName;
746
+ try {
747
+ return Promise.resolve(API({
748
+ apiEndPoint: apiEndPoint,
749
+ token: token,
750
+ url: "/ecommerce/system/feature",
751
+ queryParams: {
752
+ moduleId: moduleId,
753
+ moduleName: moduleName
754
+ },
755
+ errorMessage: 'Error in getting System Feature.',
756
+ hideErrorMessage: true
757
+ }));
758
+ } catch (e) {
759
+ return Promise.reject(e);
760
+ }
761
+ };
626
762
 
627
763
  var convertCamCaseToSnake = function convertCamCaseToSnake(child) {
628
764
  var _Object$keys;
@@ -4256,17 +4392,21 @@ var AccountDetails = function AccountDetails(_ref) {
4256
4392
  sectionLeftImageSection = _ref.sectionLeftImageSection,
4257
4393
  exploreCategoryImage = _ref.exploreCategoryImage,
4258
4394
  sectionRightImageSection = _ref.sectionRightImageSection,
4259
- discountImageSection = _ref.discountImageSection,
4260
- _ref$hideDiscountImag = _ref.hideDiscountImage,
4261
- hideDiscountImage = _ref$hideDiscountImag === void 0 ? false : _ref$hideDiscountImag,
4262
- _ref$hideBannerSectio = _ref.hideBannerSection,
4263
- hideBannerSection = _ref$hideBannerSectio === void 0 ? false : _ref$hideBannerSectio,
4264
- _ref$imgNotFoundUrl = _ref.imgNotFoundUrl,
4265
- imgNotFoundUrl = _ref$imgNotFoundUrl === void 0 ? noImgAvailable$1 : _ref$imgNotFoundUrl,
4266
- _ref$hideInvoiceActio = _ref.hideInvoiceAction,
4267
- hideInvoiceAction = _ref$hideInvoiceActio === void 0 ? false : _ref$hideInvoiceActio,
4268
- _ref$removeSocialLink = _ref.removeSocialLinks,
4269
- removeSocialLinks = _ref$removeSocialLink === void 0 ? false : _ref$removeSocialLink;
4395
+ discountImageSection = _ref.discountImageSection;
4396
+ var _useAllSystemFeatureV = useAllSystemFeatureValues({
4397
+ apiEndPoint: apiEndPoint,
4398
+ token: token
4399
+ }),
4400
+ _useAllSystemFeatureV2 = _useAllSystemFeatureV.hideDiscountImageOnAccount,
4401
+ hideDiscountImage = _useAllSystemFeatureV2 === void 0 ? false : _useAllSystemFeatureV2,
4402
+ _useAllSystemFeatureV3 = _useAllSystemFeatureV.hideBannerSectionOnAccount,
4403
+ hideBannerSection = _useAllSystemFeatureV3 === void 0 ? false : _useAllSystemFeatureV3,
4404
+ _useAllSystemFeatureV4 = _useAllSystemFeatureV.imgNotFoundUrlOnAccount,
4405
+ imgNotFoundUrl = _useAllSystemFeatureV4 === void 0 ? noImgAvailable$1 : _useAllSystemFeatureV4,
4406
+ _useAllSystemFeatureV5 = _useAllSystemFeatureV.hideInvoiceActionOnAccount,
4407
+ hideInvoiceAction = _useAllSystemFeatureV5 === void 0 ? false : _useAllSystemFeatureV5,
4408
+ _useAllSystemFeatureV6 = _useAllSystemFeatureV.removeSocialLinksOnAccount,
4409
+ removeSocialLinks = _useAllSystemFeatureV6 === void 0 ? false : _useAllSystemFeatureV6;
4270
4410
  serviceApiEndPoint = serviceApiEndPoint || (apiEndPoint === null || apiEndPoint === void 0 ? void 0 : apiEndPoint.replace('/api', '/services/pdf'));
4271
4411
  var queryParams = searchQueryParams(window.location.search);
4272
4412
  var isMobile = useMediaQuery('(max-width:768px)');
@@ -7108,8 +7248,13 @@ var CartPageComponent = function CartPageComponent(_ref) {
7108
7248
  loading = _ref.loading,
7109
7249
  imgnotfoundUrl = _ref.imgnotfoundUrl,
7110
7250
  styles = _ref.styles,
7111
- onChangeDiscountCoupon = _ref.onChangeDiscountCoupon,
7112
- disabledSelectAllProductCheckbox = _ref.disabledSelectAllProductCheckbox;
7251
+ onChangeDiscountCoupon = _ref.onChangeDiscountCoupon;
7252
+ var _useAllSystemFeatureV = useAllSystemFeatureValues({
7253
+ apiEndPoint: apiEndPoint,
7254
+ token: token
7255
+ }),
7256
+ _useAllSystemFeatureV2 = _useAllSystemFeatureV.disabledSelectAllProductOnCartPage,
7257
+ disabledSelectAllProductCheckbox = _useAllSystemFeatureV2 === void 0 ? false : _useAllSystemFeatureV2;
7113
7258
  var _useState = React.useState([]),
7114
7259
  storeData = _useState[0],
7115
7260
  setStoreData = _useState[1];
@@ -12017,13 +12162,19 @@ var CheckoutPageComponent = function CheckoutPageComponent(_ref) {
12017
12162
  handleLogin = _ref.handleLogin,
12018
12163
  placeOrder = _ref.placeOrder,
12019
12164
  clickRedirect = _ref.clickRedirect,
12020
- shippingText = _ref.shippingText,
12021
- _ref$taxExempt = _ref.taxExempt,
12022
- taxExempt = _ref$taxExempt === void 0 ? false : _ref$taxExempt,
12023
- _ref$paymentWithPaypa = _ref.paymentWithPaypal,
12024
- paymentWithPaypal = _ref$paymentWithPaypa === void 0 ? false : _ref$paymentWithPaypa,
12025
- showShippingPriceRangeLimit = _ref.showShippingPriceRangeLimit,
12026
- disabledPaymentOnMoreThanAmount = _ref.disabledPaymentOnMoreThanAmount;
12165
+ shippingText = _ref.shippingText;
12166
+ var _useAllSystemFeatureV = useAllSystemFeatureValues({
12167
+ apiEndPoint: apiEndPoint,
12168
+ token: token
12169
+ }),
12170
+ _useAllSystemFeatureV2 = _useAllSystemFeatureV.showShippingPriceRangeLimitOnCheckoutPage,
12171
+ showShippingPriceRangeLimit = _useAllSystemFeatureV2 === void 0 ? false : _useAllSystemFeatureV2,
12172
+ _useAllSystemFeatureV3 = _useAllSystemFeatureV.disabledPaymentOnMoreThanAmountOnCheckoutPage,
12173
+ disabledPaymentOnMoreThanAmount = _useAllSystemFeatureV3 === void 0 ? false : _useAllSystemFeatureV3,
12174
+ _useAllSystemFeatureV4 = _useAllSystemFeatureV.taxExemptOnCheckoutPage,
12175
+ taxExempt = _useAllSystemFeatureV4 === void 0 ? false : _useAllSystemFeatureV4,
12176
+ _useAllSystemFeatureV5 = _useAllSystemFeatureV.paymentWithPaypalOnCheckoutPage,
12177
+ paymentWithPaypal = _useAllSystemFeatureV5 === void 0 ? false : _useAllSystemFeatureV5;
12027
12178
  var _useState = React.useState(false),
12028
12179
  loginLoading = _useState[0],
12029
12180
  setLoginLoading = _useState[1];