@bjsdistribution/dms-client-return 0.1.46-prod → 0.1.47-prod

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.
@@ -9870,161 +9870,71 @@ function ConfirmOrder(props) {
9870
9870
  setOrderDetailsConfirmOrder(clone);
9871
9871
  };
9872
9872
  }, []);
9873
- function hasOnlyIdKey(obj) {
9874
- return Object.keys(obj).length === 1 && obj.hasOwnProperty('id');
9875
- }
9876
- var handleSuccess = function handleSuccess(message, res) {
9877
- var _res$data, _res$data2;
9878
- var apiMessage = (res == null || (_res$data = res.data) == null ? void 0 : _res$data.message) || (res == null ? void 0 : res.message) || (res == null || (_res$data2 = res.data) == null || (_res$data2 = _res$data2.data) == null ? void 0 : _res$data2.message);
9879
- antd.notification.success({
9880
- message: 'Success',
9881
- description: apiMessage || message
9882
- });
9883
- };
9884
- var handleError = function handleError(error, fallback) {
9885
- var _err$response, _err$response2;
9886
- var err = error;
9887
- antd.notification.error({
9888
- message: 'Request Failed',
9889
- description: (err == null || (_err$response = err.response) == null || (_err$response = _err$response.data) == null ? void 0 : _err$response.error) || (err == null || (_err$response2 = err.response) == null || (_err$response2 = _err$response2.data) == null ? void 0 : _err$response2.message) || (err == null ? void 0 : err.message) || fallback
9890
- });
9891
- };
9892
9873
  var executeActions = /*#__PURE__*/function () {
9893
9874
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
9894
- var _response, response, _response2, _response3, _response4, _response5, _response6, _response7, _response8;
9895
9875
  return _regeneratorRuntime().wrap(function _callee$(_context) {
9896
9876
  while (1) switch (_context.prev = _context.next) {
9897
9877
  case 0:
9898
9878
  _context.t0 = selectedAction;
9899
- _context.next = _context.t0 === 'decline_and_propose_new_date' ? 3 : _context.t0 === 'decline_and_confirm_new_date' ? 19 : _context.t0 === 'declined_proposed_date(outstanding)' ? 35 : _context.t0 === 'no_response_propose_new_date' ? 47 : _context.t0 === 'confirmed' ? 63 : 79;
9879
+ _context.next = _context.t0 === 'decline_and_propose_new_date' ? 3 : _context.t0 === 'decline_and_confirm_new_date' ? 9 : _context.t0 === 'declined_proposed_date(outstanding)' ? 15 : _context.t0 === 'no_response_propose_new_date' ? 19 : _context.t0 === 'confirmed' ? 25 : 28;
9900
9880
  break;
9901
9881
  case 3:
9902
- _context.prev = 3;
9903
9882
  if (!((confirmedDate == null ? void 0 : confirmedDate.previousDate) !== null)) {
9904
- _context.next = 9;
9883
+ _context.next = 6;
9905
9884
  break;
9906
9885
  }
9907
- _context.next = 7;
9886
+ _context.next = 6;
9908
9887
  return declineDate();
9909
- case 7:
9910
- _response = _context.sent;
9911
- handleSuccess('Previous date declined successfully', _response);
9912
- case 9:
9913
- _context.next = 11;
9888
+ case 6:
9889
+ _context.next = 8;
9914
9890
  return proposeDate();
9915
- case 11:
9916
- response = _context.sent;
9917
- handleSuccess('New date proposed successfully', response);
9918
- _context.next = 18;
9919
- break;
9920
- case 15:
9921
- _context.prev = 15;
9922
- _context.t1 = _context["catch"](3);
9923
- handleError(_context.t1, 'Failed to propose new date');
9924
- case 18:
9925
- return _context.abrupt("break", 80);
9926
- case 19:
9927
- _context.prev = 19;
9891
+ case 8:
9892
+ return _context.abrupt("break", 29);
9893
+ case 9:
9928
9894
  if (!((confirmedDate == null ? void 0 : confirmedDate.previousDate) !== null)) {
9929
- _context.next = 25;
9895
+ _context.next = 12;
9930
9896
  break;
9931
9897
  }
9932
- _context.next = 23;
9898
+ _context.next = 12;
9933
9899
  return declineDate();
9934
- case 23:
9935
- _response2 = _context.sent;
9936
- handleSuccess('Previous date declined successfully', _response2);
9937
- case 25:
9938
- _context.next = 27;
9900
+ case 12:
9901
+ _context.next = 14;
9939
9902
  return confirmDeliveryDate();
9940
- case 27:
9941
- _response3 = _context.sent;
9942
- handleSuccess('New date confirmed successfully', _response3);
9943
- _context.next = 34;
9944
- break;
9945
- case 31:
9946
- _context.prev = 31;
9947
- _context.t2 = _context["catch"](19);
9948
- handleError(_context.t2, 'Failed to confirm new date');
9949
- case 34:
9950
- return _context.abrupt("break", 80);
9951
- case 35:
9952
- _context.prev = 35;
9903
+ case 14:
9904
+ return _context.abrupt("break", 29);
9905
+ case 15:
9953
9906
  if (!((confirmedDate == null ? void 0 : confirmedDate.previousDate) !== null)) {
9954
- _context.next = 41;
9907
+ _context.next = 18;
9955
9908
  break;
9956
9909
  }
9957
- _context.next = 39;
9910
+ _context.next = 18;
9958
9911
  return declineDate();
9959
- case 39:
9960
- _response4 = _context.sent;
9961
- handleSuccess('Proposed date declined successfully', _response4);
9962
- case 41:
9963
- _context.next = 46;
9964
- break;
9965
- case 43:
9966
- _context.prev = 43;
9967
- _context.t3 = _context["catch"](35);
9968
- handleError(_context.t3, 'Failed to decline proposed date');
9969
- case 46:
9970
- return _context.abrupt("break", 80);
9971
- case 47:
9972
- _context.prev = 47;
9912
+ case 18:
9913
+ return _context.abrupt("break", 29);
9914
+ case 19:
9973
9915
  if (!((confirmedDate == null ? void 0 : confirmedDate.previousDate) !== null)) {
9974
- _context.next = 53;
9916
+ _context.next = 22;
9975
9917
  break;
9976
9918
  }
9977
- _context.next = 51;
9919
+ _context.next = 22;
9978
9920
  return declineDate();
9979
- case 51:
9980
- _response5 = _context.sent;
9981
- handleSuccess('Previous date declined successfully', _response5);
9982
- case 53:
9983
- _context.next = 55;
9921
+ case 22:
9922
+ _context.next = 24;
9984
9923
  return noResponseApi();
9985
- case 55:
9986
- _response6 = _context.sent;
9987
- handleSuccess('No response date proposed successfully', _response6);
9988
- _context.next = 62;
9989
- break;
9990
- case 59:
9991
- _context.prev = 59;
9992
- _context.t4 = _context["catch"](47);
9993
- handleError(_context.t4, 'Failed to propose date (no response)');
9994
- case 62:
9995
- return _context.abrupt("break", 80);
9996
- case 63:
9997
- _context.prev = 63;
9998
- if (!((confirmedDate == null ? void 0 : confirmedDate.previousDate) !== null)) {
9999
- _context.next = 69;
10000
- break;
10001
- }
10002
- _context.next = 67;
10003
- return declineDate();
10004
- case 67:
10005
- _response7 = _context.sent;
10006
- handleSuccess('Previous date declined successfully', _response7);
10007
- case 69:
10008
- _context.next = 71;
9924
+ case 24:
9925
+ return _context.abrupt("break", 29);
9926
+ case 25:
9927
+ _context.next = 27;
10009
9928
  return confirmDeliveryDate();
10010
- case 71:
10011
- _response8 = _context.sent;
10012
- handleSuccess('Delivery date confirmed successfully', _response8);
10013
- _context.next = 78;
10014
- break;
10015
- case 75:
10016
- _context.prev = 75;
10017
- _context.t5 = _context["catch"](63);
10018
- handleError(_context.t5, 'Failed to confirm delivery date');
10019
- case 78:
10020
- return _context.abrupt("break", 80);
10021
- case 79:
10022
- return _context.abrupt("break", 80);
10023
- case 80:
9929
+ case 27:
9930
+ return _context.abrupt("break", 29);
9931
+ case 28:
9932
+ return _context.abrupt("break", 29);
9933
+ case 29:
10024
9934
  case "end":
10025
9935
  return _context.stop();
10026
9936
  }
10027
- }, _callee, null, [[3, 15], [19, 31], [35, 43], [47, 59], [63, 75]]);
9937
+ }, _callee);
10028
9938
  }));
10029
9939
  return function executeActions() {
10030
9940
  return _ref.apply(this, arguments);
@@ -10032,60 +9942,35 @@ function ConfirmOrder(props) {
10032
9942
  }();
10033
9943
  var executeSendComs = /*#__PURE__*/function () {
10034
9944
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
10035
- var response, _response9, _response10;
10036
9945
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
10037
9946
  while (1) switch (_context2.prev = _context2.next) {
10038
9947
  case 0:
10039
9948
  _context2.t0 = selectedAction;
10040
- _context2.next = _context2.t0 === 'left_message' ? 3 : _context2.t0 === 'contact_made' ? 3 : _context2.t0 === 'no_contact' ? 3 : _context2.t0 === 'precall' ? 14 : 30;
9949
+ _context2.next = _context2.t0 === 'left_message' ? 3 : _context2.t0 === 'contact_made' ? 3 : _context2.t0 === 'no_contact' ? 3 : _context2.t0 === 'precall' ? 5 : 11;
10041
9950
  break;
10042
9951
  case 3:
10043
- _context2.prev = 3;
10044
- _context2.next = 6;
10045
- return notificationCall();
10046
- case 6:
10047
- response = _context2.sent;
10048
- handleSuccess('Notification sent successfully', response);
10049
- _context2.next = 13;
10050
- break;
10051
- case 10:
10052
- _context2.prev = 10;
10053
- _context2.t1 = _context2["catch"](3);
10054
- handleError(_context2.t1, 'Failed to send notification');
10055
- case 13:
10056
- return _context2.abrupt("break", 31);
10057
- case 14:
10058
- _context2.prev = 14;
9952
+ // Only send comms (Update Order already handled in confirmOrder)
9953
+ notificationCall();
9954
+ return _context2.abrupt("break", 12);
9955
+ case 5:
10059
9956
  if (!((confirmedDate == null ? void 0 : confirmedDate.previousDate) !== null)) {
10060
- _context2.next = 20;
9957
+ _context2.next = 8;
10061
9958
  break;
10062
9959
  }
10063
- _context2.next = 18;
9960
+ _context2.next = 8;
10064
9961
  return declineDate();
10065
- case 18:
10066
- _response9 = _context2.sent;
10067
- handleSuccess('Previous date declined successfully', _response9);
10068
- case 20:
10069
- _context2.next = 22;
9962
+ case 8:
9963
+ _context2.next = 10;
10070
9964
  return sendComs();
10071
- case 22:
10072
- _response10 = _context2.sent;
10073
- handleSuccess('Precall communication sent successfully', _response10);
10074
- _context2.next = 29;
10075
- break;
10076
- case 26:
10077
- _context2.prev = 26;
10078
- _context2.t2 = _context2["catch"](14);
10079
- handleError(_context2.t2, 'Failed to send precall communication');
10080
- case 29:
10081
- return _context2.abrupt("break", 31);
10082
- case 30:
10083
- return _context2.abrupt("break", 31);
10084
- case 31:
9965
+ case 10:
9966
+ return _context2.abrupt("break", 12);
9967
+ case 11:
9968
+ return _context2.abrupt("break", 12);
9969
+ case 12:
10085
9970
  case "end":
10086
9971
  return _context2.stop();
10087
9972
  }
10088
- }, _callee2, null, [[3, 10], [14, 26]]);
9973
+ }, _callee2);
10089
9974
  }));
10090
9975
  return function executeSendComs() {
10091
9976
  return _ref2.apply(this, arguments);
@@ -10093,17 +9978,16 @@ function ConfirmOrder(props) {
10093
9978
  }();
10094
9979
  var confirmOrder = /*#__PURE__*/function () {
10095
9980
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
10096
- var keysToRemovefromOrders, filteredOrderDetails, filteredPrevOrderDetails, payload, updatedPayload, notUpdateOrder, _response$data, response, updatedOrder, formattedDate;
9981
+ var keysToRemovefromOrders, filteredOrderDetails, filteredPrevOrderDetails, payload, restrictedActions, isRestrictedAction, updatedPayload, keys, notUpdateOrder, shouldUpdateOrder, _response$data, response, updatedOrder, formattedDate;
10097
9982
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
10098
9983
  while (1) switch (_context3.prev = _context3.next) {
10099
9984
  case 0:
10100
- _context3.prev = 0;
10101
9985
  if (!(selectedAction === 'left_message' || selectedAction === 'contact_made' || selectedAction === 'no_contact' || selectedAction === 'precall')) {
10102
- _context3.next = 8;
9986
+ _context3.next = 7;
10103
9987
  break;
10104
9988
  }
10105
9989
  if (!((contactHome == null ? void 0 : contactHome.length) === 0 && (contactMobile == null ? void 0 : contactMobile.length) === 0 && (contactWork == null ? void 0 : contactWork.length) === 0)) {
10106
- _context3.next = 5;
9990
+ _context3.next = 4;
10107
9991
  break;
10108
9992
  }
10109
9993
  antd.notification.info({
@@ -10111,9 +9995,9 @@ function ConfirmOrder(props) {
10111
9995
  description: 'Please add contact information'
10112
9996
  });
10113
9997
  return _context3.abrupt("return");
10114
- case 5:
9998
+ case 4:
10115
9999
  if (!((confirmedDate == null ? void 0 : confirmedDate.previousDate) === null && (confirmedDate == null ? void 0 : confirmedDate.currentDate) === null)) {
10116
- _context3.next = 8;
10000
+ _context3.next = 7;
10117
10001
  break;
10118
10002
  }
10119
10003
  antd.notification.info({
@@ -10121,116 +10005,63 @@ function ConfirmOrder(props) {
10121
10005
  description: 'Please add delivery date'
10122
10006
  });
10123
10007
  return _context3.abrupt("return");
10124
- case 8:
10125
- keysToRemovefromOrders = ['order_locked', 'order_communications', 'updated_at', 'updated_by', 'stock_alias', 'order_delivery_declined_dates', 'order_eta_updates', 'order_status', 'tomtom_status', 'refused_service', 'order_type', 'order_failures', 'order_on_hold', 'order_cancellations', 'order_routes'];
10008
+ case 7:
10009
+ keysToRemovefromOrders = ['order_locked', 'order_communications', 'updated_at', 'updated_by', 'stock_alias', 'order_delivery_declined_dates', 'order_eta_updates', 'order_status', 'tomtom_status', 'refused_service', 'order_type', 'order_failures', 'order_on_hold', 'order_cancellations', 'order_routes', 'order_services', 'labels'];
10126
10010
  filteredOrderDetails = filterObject(orderDetailsConfirmOrder, keysToRemovefromOrders);
10127
10011
  filteredPrevOrderDetails = filterObject(prevOrderDetails, keysToRemovefromOrders);
10128
10012
  payload = compareOrderDetailsStates(filteredPrevOrderDetails, filteredOrderDetails);
10013
+ restrictedActions = ['decline_and_confirm_new_date', 'decline_and_propose_new_date', 'declined_proposed_date(outstanding)', 'confirmed', 'no_response_propose_new_date'];
10014
+ isRestrictedAction = restrictedActions.includes(selectedAction);
10129
10015
  updatedPayload = _extends({}, payload, {
10130
10016
  action_date: confirmedDate == null ? void 0 : confirmedDate.currentDate
10131
- });
10132
- notUpdateOrder = hasOnlyIdKey(updatedPayload);
10133
- if (notUpdateOrder) {
10134
- _context3.next = 26;
10017
+ }); // ✅ Remove action_date for restricted actions
10018
+ if (isRestrictedAction) {
10019
+ delete updatedPayload.action_date;
10020
+ }
10021
+ keys = Object.keys(updatedPayload);
10022
+ notUpdateOrder = keys.length === 1 && keys.includes('id');
10023
+ shouldUpdateOrder = !notUpdateOrder;
10024
+ if (!shouldUpdateOrder) {
10025
+ _context3.next = 23;
10135
10026
  break;
10136
10027
  }
10137
- _context3.prev = 15;
10138
- _context3.next = 18;
10028
+ _context3.next = 21;
10139
10029
  return callUpdateOrderAPI({
10140
10030
  payload: [updatedPayload]
10141
10031
  });
10142
- case 18:
10032
+ case 21:
10143
10033
  response = _context3.sent;
10144
10034
  if ((response == null || (_response$data = response.data) == null ? void 0 : _response$data.length) > 0) {
10145
10035
  updatedOrder = response == null ? void 0 : response.data[0];
10146
10036
  setOrderDetails(updatedOrder);
10147
10037
  setPrevOrderDetails(updatedOrder);
10148
- handleSuccess('Order updated successfully', response);
10149
10038
  } else {
10150
10039
  setOrderDetails(prevOrderDetails);
10151
10040
  }
10152
- _context3.next = 26;
10153
- break;
10154
- case 22:
10155
- _context3.prev = 22;
10156
- _context3.t0 = _context3["catch"](15);
10157
- handleError(_context3.t0, 'Failed to update order');
10158
- setOrderDetails(prevOrderDetails);
10159
- case 26:
10160
- _context3.prev = 26;
10161
- _context3.next = 29;
10041
+ case 23:
10042
+ _context3.next = 25;
10162
10043
  return executeActions();
10163
- case 29:
10164
- _context3.next = 34;
10165
- break;
10166
- case 31:
10167
- _context3.prev = 31;
10168
- _context3.t1 = _context3["catch"](26);
10169
- handleError(_context3.t1, 'Failed to execute actions');
10170
- case 34:
10171
- _context3.prev = 34;
10172
- _context3.next = 37;
10044
+ case 25:
10045
+ _context3.next = 27;
10173
10046
  return executeSendComs();
10174
- case 37:
10175
- _context3.next = 42;
10176
- break;
10177
- case 39:
10178
- _context3.prev = 39;
10179
- _context3.t2 = _context3["catch"](34);
10180
- handleError(_context3.t2, 'Failed to send communications');
10181
- case 42:
10047
+ case 27:
10182
10048
  if (orderId && deliveryDate) {
10183
10049
  formattedDate = dateFns.format(new Date(deliveryDate), 'yyyy-MM-dd');
10184
10050
  setDeliveryDate(formattedDate);
10185
10051
  }
10186
- _context3.prev = 43;
10187
- _context3.next = 46;
10188
- return props == null ? void 0 : props.callOrderStatusApi();
10189
- case 46:
10190
- handleSuccess('Order status refreshed successfully');
10191
- _context3.next = 52;
10192
- break;
10193
- case 49:
10194
- _context3.prev = 49;
10195
- _context3.t3 = _context3["catch"](43);
10196
- handleError(_context3.t3, 'Failed to refresh order status');
10197
- case 52:
10198
- _context3.prev = 52;
10199
- _context3.next = 55;
10052
+ setTimeout(function () {
10053
+ props == null || props.callOrderStatusApi();
10054
+ }, 1000);
10055
+ _context3.next = 31;
10200
10056
  return props == null ? void 0 : props.callOrderAlertsApi();
10201
- case 55:
10202
- handleSuccess('Order alerts refreshed successfully');
10203
- _context3.next = 61;
10204
- break;
10205
- case 58:
10206
- _context3.prev = 58;
10207
- _context3.t4 = _context3["catch"](52);
10208
- handleError(_context3.t4, 'Failed to refresh alerts');
10209
- case 61:
10210
- _context3.prev = 61;
10211
- _context3.next = 64;
10057
+ case 31:
10058
+ _context3.next = 33;
10212
10059
  return props == null ? void 0 : props.callOrdersApi();
10213
- case 64:
10214
- handleSuccess('Orders refreshed successfully');
10215
- _context3.next = 70;
10216
- break;
10217
- case 67:
10218
- _context3.prev = 67;
10219
- _context3.t5 = _context3["catch"](61);
10220
- handleError(_context3.t5, 'Failed to refresh orders');
10221
- case 70:
10222
- handleSuccess('Order processed successfully');
10223
- _context3.next = 76;
10224
- break;
10225
- case 73:
10226
- _context3.prev = 73;
10227
- _context3.t6 = _context3["catch"](0);
10228
- handleError(_context3.t6, 'Something went wrong');
10229
- case 76:
10060
+ case 33:
10230
10061
  case "end":
10231
10062
  return _context3.stop();
10232
10063
  }
10233
- }, _callee3, null, [[0, 73], [15, 22], [26, 31], [34, 39], [43, 49], [52, 58], [61, 67]]);
10064
+ }, _callee3);
10234
10065
  }));
10235
10066
  return function confirmOrder() {
10236
10067
  return _ref3.apply(this, arguments);