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