@bjsdistribution/dms-client-return 0.1.28-prod → 0.1.29-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.
@@ -6128,14 +6128,31 @@ function OrderDetailsFooter() {
6128
6128
  isClientPortal = _useClientPortal[0];
6129
6129
  var _useLiveRecalling = useLiveRecalling(),
6130
6130
  setRecalling = _useLiveRecalling[1];
6131
- //update order
6131
+ var _useOrderAlertsData = useOrderAlertsData(),
6132
+ setOrderAlertsData = _useOrderAlertsData[1];
6133
+ var _useStatusDetails = useStatusDetails(),
6134
+ setOrderStatus = _useStatusDetails[1];
6135
+ // call alerts api
6132
6136
  var _useAxios = useAxios({
6137
+ endpoint: "v1/orders/alerts/?order_id=" + (orderDetails == null ? void 0 : orderDetails.id),
6138
+ method: 'GET'
6139
+ }),
6140
+ callOrderAlertsApi = _useAxios.fetchData;
6141
+ //Order status api
6142
+ var _useAxios2 = useAxios({
6143
+ endpoint: "/orders/get_live_status/" + (orderDetails == null ? void 0 : orderDetails.id),
6144
+ method: 'GET'
6145
+ }),
6146
+ callOrderStatusApi = _useAxios2.fetchData;
6147
+ //update order
6148
+ var _useAxios3 = useAxios({
6133
6149
  endpoint: "/orders/update/",
6134
6150
  method: 'PUT'
6135
6151
  }),
6136
- callUpdateOrderAPI = _useAxios.fetchData;
6152
+ callUpdateOrderAPI = _useAxios3.fetchData;
6137
6153
  var errorFound = function errorFound() {
6138
- var isError = errorState.w3wError.length > 0 || errorState.emailError.length > 0 || errorState.homeContactError.length > 0 || errorState.workCOntanctError.length > 0 || errorState.mobileError.length > 0 || errorState.postCodeError.length > 0;
6154
+ var _errorState$w3wError, _errorState$emailErro, _errorState$homeConta, _errorState$workCOnta, _errorState$mobileErr, _errorState$postCodeE;
6155
+ var isError = (errorState == null || (_errorState$w3wError = errorState.w3wError) == null ? void 0 : _errorState$w3wError.length) > 0 || (errorState == null || (_errorState$emailErro = errorState.emailError) == null ? void 0 : _errorState$emailErro.length) > 0 || (errorState == null || (_errorState$homeConta = errorState.homeContactError) == null ? void 0 : _errorState$homeConta.length) > 0 || (errorState == null || (_errorState$workCOnta = errorState.workCOntanctError) == null ? void 0 : _errorState$workCOnta.length) > 0 || (errorState == null || (_errorState$mobileErr = errorState.mobileError) == null ? void 0 : _errorState$mobileErr.length) > 0 || (errorState == null || (_errorState$postCodeE = errorState.postCodeError) == null ? void 0 : _errorState$postCodeE.length) > 0;
6139
6156
  return isError;
6140
6157
  };
6141
6158
  var isDifferent = function isDifferent() {
@@ -6150,7 +6167,7 @@ function OrderDetailsFooter() {
6150
6167
  var onSave = /*#__PURE__*/function () {
6151
6168
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
6152
6169
  var _response$data;
6153
- var payload, serviceKeys, orderServicesPayload, includesKey, _iterator, _step, key, response, _response$data$, _response$data$2;
6170
+ var payload, serviceKeys, _i, _serviceKeys, key, response, _response$data$, _response$data$2, alertsApiRes, orderStatusApiRes;
6154
6171
  return _regeneratorRuntime().wrap(function _callee$(_context) {
6155
6172
  while (1) switch (_context.prev = _context.next) {
6156
6173
  case 0:
@@ -6159,28 +6176,22 @@ function OrderDetailsFooter() {
6159
6176
  setRecalling(false);
6160
6177
  payload = compareOrderDetailsStates(prevOrderDetails, orderDetails);
6161
6178
  serviceKeys = ['assemble', 'disassemble', 'unpack_items', 'collect_disposal', 'take_packaging_away', 'assembly_type'];
6162
- orderServicesPayload = {};
6163
- includesKey = serviceKeys.some(function (key) {
6164
- return key in payload;
6165
- });
6166
- if (includesKey) {
6167
- for (_iterator = _createForOfIteratorHelperLoose(serviceKeys); !(_step = _iterator()).done;) {
6168
- key = _step.value;
6169
- orderServicesPayload[key] = key in payload ? payload[key] : orderDetails[key];
6170
- delete payload[key];
6171
- if ((orderServicesPayload == null ? void 0 : orderServicesPayload.assemble) === false && (orderServicesPayload == null ? void 0 : orderServicesPayload.disassemble) === false) {
6172
- orderServicesPayload.assembly_type = null;
6173
- }
6179
+ for (_i = 0, _serviceKeys = serviceKeys; _i < _serviceKeys.length; _i++) {
6180
+ key = _serviceKeys[_i];
6181
+ if (key in payload) {
6182
+ payload[key] = payload[key];
6183
+ } else if (key in orderDetails) {
6184
+ payload[key] = orderDetails[key];
6174
6185
  }
6175
6186
  }
6176
- if (Object.keys(orderServicesPayload).length > 0) {
6177
- payload.order_services = [orderServicesPayload];
6187
+ if ((payload == null ? void 0 : payload.assemble) === false && (payload == null ? void 0 : payload.disassemble) === false) {
6188
+ payload.assembly_type = null;
6178
6189
  }
6179
- _context.next = 11;
6190
+ _context.next = 9;
6180
6191
  return callUpdateOrderAPI({
6181
6192
  payload: [payload]
6182
6193
  });
6183
- case 11:
6194
+ case 9:
6184
6195
  response = _context.sent;
6185
6196
  // const response = await updateOrder([payload]);
6186
6197
  setRecallOrders(true);
@@ -6199,7 +6210,21 @@ function OrderDetailsFooter() {
6199
6210
  } else {
6200
6211
  setOrderDetails(prevOrderDetails);
6201
6212
  }
6213
+ _context.next = 14;
6214
+ return callOrderAlertsApi();
6202
6215
  case 14:
6216
+ alertsApiRes = _context.sent;
6217
+ if ((alertsApiRes == null ? void 0 : alertsApiRes.code) === 200 && alertsApiRes != null && alertsApiRes.data) {
6218
+ setOrderAlertsData(alertsApiRes == null ? void 0 : alertsApiRes.data);
6219
+ }
6220
+ _context.next = 18;
6221
+ return callOrderStatusApi();
6222
+ case 18:
6223
+ orderStatusApiRes = _context.sent;
6224
+ if ((orderStatusApiRes == null ? void 0 : orderStatusApiRes.code) === 200 && orderStatusApiRes != null && orderStatusApiRes.data) {
6225
+ setOrderStatus(orderStatusApiRes == null ? void 0 : orderStatusApiRes.data);
6226
+ }
6227
+ case 20:
6203
6228
  case "end":
6204
6229
  return _context.stop();
6205
6230
  }
@@ -6209,6 +6234,7 @@ function OrderDetailsFooter() {
6209
6234
  return _ref.apply(this, arguments);
6210
6235
  };
6211
6236
  }();
6237
+ //here changes needed
6212
6238
  return React.createElement(Container$y, null, React.createElement(AllowTracking, null), React.createElement(Button, {
6213
6239
  onClick: onSave,
6214
6240
  disabled: isClientPortal ? true : !isDifferent() || errorFound()
@@ -6552,7 +6578,7 @@ var _templateObject$Y;
6552
6578
  function AuditLogs() {
6553
6579
  return React.createElement(Container$C, null, React.createElement(GenericAuditLogsTable, null));
6554
6580
  }
6555
- var Container$C = /*#__PURE__*/styled.div(_templateObject$Y || (_templateObject$Y = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n height: 550px; /* Set height to limit container size */\n overflow: auto; /* Enable scrolling */\n scrollbar-width: thin;\n"])));
6581
+ var Container$C = /*#__PURE__*/styled.div(_templateObject$Y || (_templateObject$Y = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n height: 500px;\n min-height: 200px;\n max-height: 500px;\n overflow: auto; /* Enable scrolling */\n scrollbar-width: thin;\n"])));
6556
6582
 
6557
6583
  var _templateObject$Z, _templateObject2$J, _templateObject3$k, _templateObject4$b;
6558
6584
  // import { useLocation } from 'react-router-dom';
@@ -14996,38 +15022,32 @@ function ForceDebriefModal(props) {
14996
15022
  }();
14997
15023
  var ordersUpdateApi = /*#__PURE__*/function () {
14998
15024
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
14999
- var ordersApiPayload, serviceKeys, orderServicesPayload, includesKey, _iterator, _step, key, _response$data, response, _response$data$, _response$data$2;
15025
+ var ordersApiPayload, serviceKeys, _i, _serviceKeys, key, _response$data, response, _response$data$, _response$data$2;
15000
15026
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
15001
15027
  while (1) switch (_context2.prev = _context2.next) {
15002
15028
  case 0:
15003
15029
  ordersApiPayload = compareOrderDetailsStates(prevOrderDetails, orderDetails);
15004
15030
  serviceKeys = ['assemble', 'disassemble', 'unpack_items', 'collect_disposal', 'take_packaging_away', 'assembly_type'];
15005
- orderServicesPayload = {};
15006
- includesKey = serviceKeys.some(function (key) {
15007
- return key in ordersApiPayload;
15008
- });
15009
- if (includesKey) {
15010
- for (_iterator = _createForOfIteratorHelperLoose(serviceKeys); !(_step = _iterator()).done;) {
15011
- key = _step.value;
15012
- orderServicesPayload[key] = key in ordersApiPayload ? ordersApiPayload[key] : orderDetails[key];
15013
- delete ordersApiPayload[key];
15014
- if ((orderServicesPayload == null ? void 0 : orderServicesPayload.assemble) === false && (orderServicesPayload == null ? void 0 : orderServicesPayload.disassemble) === false) {
15015
- orderServicesPayload.assembly_type = null;
15016
- }
15031
+ for (_i = 0, _serviceKeys = serviceKeys; _i < _serviceKeys.length; _i++) {
15032
+ key = _serviceKeys[_i];
15033
+ if (key in ordersApiPayload) {
15034
+ ordersApiPayload[key] = ordersApiPayload[key];
15035
+ } else if (key in orderDetails) {
15036
+ ordersApiPayload[key] = orderDetails[key];
15017
15037
  }
15018
15038
  }
15019
- if (Object.keys(orderServicesPayload).length > 0) {
15020
- ordersApiPayload.order_services = [orderServicesPayload];
15039
+ if ((ordersApiPayload == null ? void 0 : ordersApiPayload.assemble) === false && (ordersApiPayload == null ? void 0 : ordersApiPayload.disassemble) === false) {
15040
+ ordersApiPayload.assembly_type = null;
15021
15041
  }
15022
- _context2.prev = 6;
15023
- _context2.next = 9;
15042
+ _context2.prev = 4;
15043
+ _context2.next = 7;
15024
15044
  return callUpdateOrderAPI({
15025
15045
  payload: [ordersApiPayload]
15026
15046
  });
15027
- case 9:
15047
+ case 7:
15028
15048
  response = _context2.sent;
15029
15049
  if (!(response.code === 200 && (response == null || (_response$data = response.data) == null ? void 0 : _response$data.length) > 0)) {
15030
- _context2.next = 17;
15050
+ _context2.next = 15;
15031
15051
  break;
15032
15052
  }
15033
15053
  notification.success({
@@ -15040,20 +15060,20 @@ function ForceDebriefModal(props) {
15040
15060
  recipient_name: response == null || (_response$data$ = response.data[0]) == null || (_response$data$ = _response$data$.order_recipient) == null ? void 0 : _response$data$.recipient_name,
15041
15061
  postcode: response == null || (_response$data$2 = response.data[0]) == null || (_response$data$2 = _response$data$2.order_recipient) == null ? void 0 : _response$data$2.postcode
15042
15062
  });
15043
- _context2.next = 17;
15063
+ _context2.next = 15;
15044
15064
  return setRecallOrders(true);
15045
- case 17:
15046
- _context2.next = 22;
15065
+ case 15:
15066
+ _context2.next = 20;
15047
15067
  break;
15048
- case 19:
15049
- _context2.prev = 19;
15050
- _context2.t0 = _context2["catch"](6);
15068
+ case 17:
15069
+ _context2.prev = 17;
15070
+ _context2.t0 = _context2["catch"](4);
15051
15071
  setOrderDetails(prevOrderDetails);
15052
- case 22:
15072
+ case 20:
15053
15073
  case "end":
15054
15074
  return _context2.stop();
15055
15075
  }
15056
- }, _callee2, null, [[6, 19]]);
15076
+ }, _callee2, null, [[4, 17]]);
15057
15077
  }));
15058
15078
  return function ordersUpdateApi() {
15059
15079
  return _ref2.apply(this, arguments);