@salesgenterp/ui-components 0.4.563 → 0.4.564

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
@@ -473,6 +473,11 @@ var jsonParse = function jsonParse(value) {
473
473
  var convertToBoolean = function convertToBoolean(value) {
474
474
  return lodash.toNumber(value) === 1;
475
475
  };
476
+ var inDevelopment = function inDevelopment() {
477
+ if (typeof window === 'undefined') return false;
478
+ var list = ['localhost', 'calikulture-git-develop-salesgent-techgrow.vercel.app', 'calikulture-git-staging-salesgent-techgrow.vercel.app', 'aa-cell-sc-git-develop-salesgent-techgrow.vercel.app', 'aa-cell-sc-git-staging-salesgent-techgrow.vercel.app'];
479
+ return lodash.includes(list, window.location.hostname);
480
+ };
476
481
 
477
482
  function useSystemFeatureList(_ref) {
478
483
  var apiEndPoint = _ref.apiEndPoint,
@@ -3262,6 +3267,123 @@ var ExcessPaymentDialog = function ExcessPaymentDialog(_ref2) {
3262
3267
  })));
3263
3268
  };
3264
3269
 
3270
+ var CloneOrderDialog = function CloneOrderDialog(_ref) {
3271
+ var visible = _ref.visible,
3272
+ onClose = _ref.onClose,
3273
+ onSubmit = _ref.onSubmit,
3274
+ loading = _ref.loading,
3275
+ styles = _ref.styles;
3276
+ var _useState = React.useState(null),
3277
+ combineProduct = _useState[0],
3278
+ setCombineProduct = _useState[1];
3279
+ React.useEffect(function () {
3280
+ if (!visible) {
3281
+ setCombineProduct(null);
3282
+ }
3283
+ }, [visible]);
3284
+ var checkboxSx = {
3285
+ '&.Mui-checked': {
3286
+ color: styles === null || styles === void 0 ? void 0 : styles.primaryColor
3287
+ }
3288
+ };
3289
+ return /*#__PURE__*/React__default.createElement(material.Dialog, {
3290
+ open: !!visible,
3291
+ onClose: loading ? undefined : function () {
3292
+ return onClose === null || onClose === void 0 ? void 0 : onClose();
3293
+ },
3294
+ fullWidth: true,
3295
+ maxWidth: "xs"
3296
+ }, /*#__PURE__*/React__default.createElement(material.DialogTitle, null, "Clone Order"), /*#__PURE__*/React__default.createElement(material.DialogContent, null, /*#__PURE__*/React__default.createElement(material.Typography, {
3297
+ sx: {
3298
+ fontWeight: 600,
3299
+ mb: 1
3300
+ }
3301
+ }, "Do you want to combine the products?"), /*#__PURE__*/React__default.createElement(material.Typography, {
3302
+ variant: "body2",
3303
+ sx: {
3304
+ mb: 1
3305
+ }
3306
+ }, "Some products in this order may already be in your cart. Choose how their quantities should be handled:"), /*#__PURE__*/React__default.createElement(material.Typography, {
3307
+ component: "ul",
3308
+ variant: "body2",
3309
+ sx: {
3310
+ pl: 2.5,
3311
+ mb: 1
3312
+ }
3313
+ }, /*#__PURE__*/React__default.createElement("li", null, /*#__PURE__*/React__default.createElement("b", null, "Yes"), " - add the order quantity to what is already in your cart."), /*#__PURE__*/React__default.createElement("li", null, /*#__PURE__*/React__default.createElement("b", null, "No"), " - replace the cart quantity with the order quantity.")), /*#__PURE__*/React__default.createElement(material.Typography, {
3314
+ variant: "body2",
3315
+ sx: {
3316
+ mb: 1,
3317
+ p: 1.5,
3318
+ borderRadius: 1,
3319
+ bgcolor: 'action.hover'
3320
+ }
3321
+ }, /*#__PURE__*/React__default.createElement("b", null, "Example:"), " Your cart has 5 of Product X and this order has 10 of Product X.", /*#__PURE__*/React__default.createElement("br", null), "Yes \u2192 your cart will have ", /*#__PURE__*/React__default.createElement("b", null, "15"), " (5 + 10).", /*#__PURE__*/React__default.createElement("br", null), "No \u2192 your cart will have ", /*#__PURE__*/React__default.createElement("b", null, "10"), "."), /*#__PURE__*/React__default.createElement(material.Grid, {
3322
+ container: true,
3323
+ spacing: 2
3324
+ }, /*#__PURE__*/React__default.createElement(material.Grid, {
3325
+ item: true
3326
+ }, /*#__PURE__*/React__default.createElement(material.FormControlLabel, {
3327
+ label: "Yes",
3328
+ control: /*#__PURE__*/React__default.createElement(material.Checkbox, {
3329
+ checked: combineProduct === true,
3330
+ onChange: function onChange() {
3331
+ return setCombineProduct(true);
3332
+ },
3333
+ disabled: loading,
3334
+ sx: checkboxSx
3335
+ })
3336
+ })), /*#__PURE__*/React__default.createElement(material.Grid, {
3337
+ item: true
3338
+ }, /*#__PURE__*/React__default.createElement(material.FormControlLabel, {
3339
+ label: "No",
3340
+ control: /*#__PURE__*/React__default.createElement(material.Checkbox, {
3341
+ checked: combineProduct === false,
3342
+ onChange: function onChange() {
3343
+ return setCombineProduct(false);
3344
+ },
3345
+ disabled: loading,
3346
+ sx: checkboxSx
3347
+ })
3348
+ }))), /*#__PURE__*/React__default.createElement(material.DialogActions, {
3349
+ sx: {
3350
+ justifyContent: 'center',
3351
+ px: 0,
3352
+ pt: 2
3353
+ }
3354
+ }, /*#__PURE__*/React__default.createElement(material.Grid, {
3355
+ container: true,
3356
+ spacing: 4,
3357
+ alignItems: "center",
3358
+ justifyContent: "center"
3359
+ }, /*#__PURE__*/React__default.createElement(material.Grid, {
3360
+ item: true
3361
+ }, /*#__PURE__*/React__default.createElement(MuiButton, {
3362
+ primaryColor: combineProduct !== null && (styles === null || styles === void 0 ? void 0 : styles.primaryColor),
3363
+ sx: {
3364
+ fontSize: '1.3rem'
3365
+ },
3366
+ onClick: function onClick() {
3367
+ return onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(combineProduct);
3368
+ },
3369
+ loading: loading,
3370
+ disabled: combineProduct === null,
3371
+ size: "small"
3372
+ }, "Submit")), /*#__PURE__*/React__default.createElement(material.Grid, {
3373
+ item: true
3374
+ }, /*#__PURE__*/React__default.createElement(MuiButton, {
3375
+ primaryColor: styles === null || styles === void 0 ? void 0 : styles.primaryColor,
3376
+ sx: {
3377
+ fontSize: '1.3rem'
3378
+ },
3379
+ onClick: function onClick() {
3380
+ return onClose === null || onClose === void 0 ? void 0 : onClose();
3381
+ },
3382
+ disabled: loading,
3383
+ size: "small"
3384
+ }, "Cancel"))))));
3385
+ };
3386
+
3265
3387
  var _templateObject$b, _templateObject2$6, _templateObject3$4, _templateObject4$2, _templateObject5$1, _templateObject6$1, _templateObject7$1, _templateObject8$1, _templateObject9$1, _templateObject10$1, _templateObject11$1, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19;
3266
3388
  var totalIcons = [{
3267
3389
  name: '',
@@ -3341,6 +3463,7 @@ var Dashboard = function Dashboard(_ref) {
3341
3463
  showOnlyRecentOrder = _ref$showOnlyRecentOr === void 0 ? false : _ref$showOnlyRecentOr,
3342
3464
  hidePayActionButton = _ref.hidePayActionButton,
3343
3465
  paymentProvider = _ref.paymentProvider;
3466
+ var showCloneOrderButton = inDevelopment();
3344
3467
  var _useState = React.useState({}),
3345
3468
  customerData = _useState[0],
3346
3469
  setCustomerData = _useState[1];
@@ -3389,6 +3512,14 @@ var Dashboard = function Dashboard(_ref) {
3389
3512
  }),
3390
3513
  invoicePreview = _useState8[0],
3391
3514
  setInvoicePreview = _useState8[1];
3515
+ var _useState9 = React.useState({
3516
+ open: false
3517
+ }),
3518
+ cloneOrderDialog = _useState9[0],
3519
+ setCloneOrderDialog = _useState9[1];
3520
+ var _useState10 = React.useState(false),
3521
+ cloneOrderLoading = _useState10[0],
3522
+ setCloneOrderLoading = _useState10[1];
3392
3523
  var _ref2 = useSystemFeatureByFieldName({
3393
3524
  apiEndPoint: apiEndPoint,
3394
3525
  token: token,
@@ -3416,9 +3547,9 @@ var Dashboard = function Dashboard(_ref) {
3416
3547
  return featureName ? DASHBOARD_ORDER_LIST_BY_NAME === null || DASHBOARD_ORDER_LIST_BY_NAME === void 0 ? void 0 : DASHBOARD_ORDER_LIST_BY_NAME[featureName] : null;
3417
3548
  }).filter(Boolean);
3418
3549
  }, [selectedDashboardOrderIds, featureValueListById]);
3419
- var _useState9 = React.useState(null),
3420
- value = _useState9[0],
3421
- setValue = _useState9[1];
3550
+ var _useState11 = React.useState(null),
3551
+ value = _useState11[0],
3552
+ setValue = _useState11[1];
3422
3553
  React.useEffect(function () {
3423
3554
  if (!(visibleTabs !== null && visibleTabs !== void 0 && visibleTabs.length)) return;
3424
3555
  var isCurrentVisible = value != null && visibleTabs.some(function (tab) {
@@ -3501,6 +3632,74 @@ var Dashboard = function Dashboard(_ref) {
3501
3632
  return Promise.reject(e);
3502
3633
  }
3503
3634
  };
3635
+ var closeCloneOrderDialog = function closeCloneOrderDialog() {
3636
+ if (cloneOrderLoading) return;
3637
+ setCloneOrderDialog({
3638
+ open: false
3639
+ });
3640
+ };
3641
+ var handleCloneOrder = function handleCloneOrder(combineProduct) {
3642
+ try {
3643
+ var documentType = cloneOrderDialog.documentType,
3644
+ documentId = cloneOrderDialog.documentId;
3645
+ if (documentId == null || cloneOrderLoading) return Promise.resolve();
3646
+ setCloneOrderLoading(true);
3647
+ var _temp = _finallyRethrows(function () {
3648
+ return _catch(function () {
3649
+ return Promise.resolve(API({
3650
+ url: "/ecommerce/addToCart",
3651
+ method: 'post',
3652
+ apiEndPoint: apiEndPoint,
3653
+ token: token,
3654
+ body: {
3655
+ documentType: documentType,
3656
+ combineProduct: !!combineProduct,
3657
+ documentId: String(documentId),
3658
+ storeId: defaultStoreId != null ? String(defaultStoreId) : undefined
3659
+ }
3660
+ })).then(function () {
3661
+ setCloneOrderDialog({
3662
+ open: false
3663
+ });
3664
+ alert('Order items added to cart successfully.');
3665
+ window.location.reload();
3666
+ });
3667
+ }, function () {});
3668
+ }, function (_wasThrown, _result) {
3669
+ setCloneOrderLoading(false);
3670
+ if (_wasThrown) throw _result;
3671
+ return _result;
3672
+ });
3673
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
3674
+ } catch (e) {
3675
+ return Promise.reject(e);
3676
+ }
3677
+ };
3678
+ var getCloneOrderColumn = function getCloneOrderColumn(_ref3) {
3679
+ var documentType = _ref3.documentType,
3680
+ idKey = _ref3.idKey;
3681
+ return {
3682
+ id: 'cloneOrder',
3683
+ label: 'Clone Order',
3684
+ align: 'center',
3685
+ format: function format(_value, record) {
3686
+ return /*#__PURE__*/React__default.createElement(MuiButton, {
3687
+ primaryColor: (record === null || record === void 0 ? void 0 : record[idKey]) != null && primaryColor,
3688
+ disabled: (record === null || record === void 0 ? void 0 : record[idKey]) == null,
3689
+ onClick: function onClick() {
3690
+ return setCloneOrderDialog({
3691
+ open: true,
3692
+ documentType: documentType,
3693
+ documentId: record === null || record === void 0 ? void 0 : record[idKey]
3694
+ });
3695
+ },
3696
+ style: {
3697
+ whiteSpace: 'nowrap'
3698
+ }
3699
+ }, "Clone Order");
3700
+ }
3701
+ };
3702
+ };
3504
3703
  var columns = [{
3505
3704
  id: 'orderId',
3506
3705
  label: 'Invoice #'
@@ -3590,7 +3789,10 @@ var Dashboard = function Dashboard(_ref) {
3590
3789
  disabled: (record === null || record === void 0 ? void 0 : record.dueBalance) <= 0
3591
3790
  }, "Pay"));
3592
3791
  }
3593
- }];
3792
+ }].concat(showCloneOrderButton ? [getCloneOrderColumn({
3793
+ documentType: 'ORDER',
3794
+ idKey: 'orderId'
3795
+ })] : []);
3594
3796
  var salesOrderColumns = [{
3595
3797
  id: 'salesOrderId',
3596
3798
  label: 'SO #'
@@ -3644,7 +3846,10 @@ var Dashboard = function Dashboard(_ref) {
3644
3846
  }
3645
3847
  })));
3646
3848
  }
3647
- }];
3849
+ }].concat(showCloneOrderButton ? [getCloneOrderColumn({
3850
+ documentType: 'SALES_ORDER',
3851
+ idKey: 'salesOrderId'
3852
+ })] : []);
3648
3853
  var quotaionColumns = [{
3649
3854
  id: 'quotationId',
3650
3855
  label: 'ID'
@@ -3692,7 +3897,10 @@ var Dashboard = function Dashboard(_ref) {
3692
3897
  }
3693
3898
  })));
3694
3899
  }
3695
- }];
3900
+ }].concat(showCloneOrderButton ? [getCloneOrderColumn({
3901
+ documentType: 'QUOTATION',
3902
+ idKey: 'quotationId'
3903
+ })] : []);
3696
3904
  var returnOrderColumns = [{
3697
3905
  id: 'returnOrderId',
3698
3906
  label: 'ID'
@@ -3743,7 +3951,7 @@ var Dashboard = function Dashboard(_ref) {
3743
3951
  React.useEffect(function () {
3744
3952
  (function () {
3745
3953
  try {
3746
- var _temp = _catch(function () {
3954
+ var _temp2 = _catch(function () {
3747
3955
  return Promise.resolve(API({
3748
3956
  url: "/ecommerce/customer",
3749
3957
  apiEndPoint: apiEndPoint,
@@ -3760,7 +3968,7 @@ var Dashboard = function Dashboard(_ref) {
3760
3968
  });
3761
3969
  });
3762
3970
  }, function () {});
3763
- return _temp && _temp.then ? _temp.then(function () {}) : void 0;
3971
+ return _temp2 && _temp2.then ? _temp2.then(function () {}) : void 0;
3764
3972
  } catch (e) {
3765
3973
  Promise.reject(e);
3766
3974
  }
@@ -3845,6 +4053,12 @@ var Dashboard = function Dashboard(_ref) {
3845
4053
  orderId: isPaymentModal === null || isPaymentModal === void 0 ? void 0 : isPaymentModal.orderId,
3846
4054
  setTriggerTableData: setTriggerTableData,
3847
4055
  styles: styles
4056
+ }), /*#__PURE__*/React__default.createElement(CloneOrderDialog, {
4057
+ visible: !!(cloneOrderDialog !== null && cloneOrderDialog !== void 0 && cloneOrderDialog.open),
4058
+ onClose: closeCloneOrderDialog,
4059
+ onSubmit: handleCloneOrder,
4060
+ loading: cloneOrderLoading,
4061
+ styles: styles
3848
4062
  }), (isExcessPaymentModal === null || isExcessPaymentModal === void 0 ? void 0 : isExcessPaymentModal.open) && /*#__PURE__*/React__default.createElement(ExcessPaymentDialog, {
3849
4063
  excessPaymentToken: (_queryParams$excessPa = queryParams === null || queryParams === void 0 ? void 0 : queryParams.excessPayment) != null ? _queryParams$excessPa : '',
3850
4064
  customerData: customerData,