@bjsdistribution/dms-client-return 0.0.58 → 0.0.59

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.
@@ -815,10 +815,6 @@ var clientDataAtom = /*#__PURE__*/atom([]);
815
815
  function useClientData() {
816
816
  return useAtom(clientDataAtom);
817
817
  }
818
- var NotesLoading = /*#__PURE__*/atom(true);
819
- var UseNotesLoading = function UseNotesLoading() {
820
- return useAtom(NotesLoading);
821
- };
822
818
  var notes = /*#__PURE__*/atom([]);
823
819
  function usegetNotes() {
824
820
  return useAtom(notes);
@@ -864,10 +860,14 @@ function useLiveRecalling() {
864
860
  // export const useBulkUPdateDisabledState = () => {
865
861
  // return useAtom(BulkUPdateDisabledState);
866
862
  // };
867
- var auditLogToggle = /*#__PURE__*/atom(true);
868
- var SeteauditLogToggle = function SeteauditLogToggle() {
869
- return useAtom(auditLogToggle);
870
- };
863
+ var auditLogLoadingState = /*#__PURE__*/atom(true);
864
+ function useAuditLogLoadingState() {
865
+ return useAtom(auditLogLoadingState);
866
+ }
867
+ var globalStateHitAuditLog = /*#__PURE__*/atom(false);
868
+ function useGlobalStateHitAuditLog() {
869
+ return useAtom(globalStateHitAuditLog);
870
+ }
871
871
  // Popup state Manage
872
872
  var initialState$1 = null;
873
873
  var popupReducer = function popupReducer(state, action) {
@@ -5416,25 +5416,25 @@ function AddNote() {
5416
5416
  var ssoToken = getCookie('id_token');
5417
5417
  var _usemoduleIds = usemoduleIds(),
5418
5418
  moduleIds = _usemoduleIds[0];
5419
- var _UseNotesLoading = UseNotesLoading(),
5420
- NoteLoadingStore = _UseNotesLoading[0],
5421
- setNoteLoadingStore = _UseNotesLoading[1];
5419
+ var _useGlobalStateHitAud = useGlobalStateHitAuditLog(),
5420
+ setRecallAuditLog = _useGlobalStateHitAud[1];
5422
5421
  // Save New Note
5423
5422
  var _useState2 = useState(null),
5424
5423
  notificationData = _useState2[0],
5425
5424
  setNotificationData = _useState2[1];
5426
5425
  var saveNote = /*#__PURE__*/function () {
5427
5426
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
5428
- var endpoint, payload, response, message, error;
5427
+ var endpoint, payload, response;
5429
5428
  return _regeneratorRuntime().wrap(function _callee$(_context) {
5430
5429
  while (1) switch (_context.prev = _context.next) {
5431
5430
  case 0:
5431
+ setRecallAuditLog(false);
5432
5432
  if (noteText) {
5433
- _context.next = 2;
5433
+ _context.next = 3;
5434
5434
  break;
5435
5435
  }
5436
5436
  return _context.abrupt("return");
5437
- case 2:
5437
+ case 3:
5438
5438
  endpoint = getBaseEndpoint() + "/audit_logs/orders/";
5439
5439
  payload = {
5440
5440
  audit_logs: [{
@@ -5448,8 +5448,8 @@ function AddNote() {
5448
5448
  manual: 1
5449
5449
  }]
5450
5450
  };
5451
- _context.prev = 4;
5452
- _context.next = 7;
5451
+ _context.prev = 5;
5452
+ _context.next = 8;
5453
5453
  return fetch(endpoint, {
5454
5454
  method: 'POST',
5455
5455
  headers: {
@@ -5458,42 +5458,36 @@ function AddNote() {
5458
5458
  },
5459
5459
  body: JSON.stringify(payload)
5460
5460
  });
5461
- case 7:
5461
+ case 8:
5462
5462
  response = _context.sent;
5463
5463
  // setNoteLoadingStore(false);
5464
- message = response.message, error = response.error;
5465
- if (response) {
5466
- setNotificationData({
5467
- type: 'success',
5464
+ if (response.ok) {
5465
+ notification.success({
5468
5466
  message: 'Success',
5469
- description: message || 'Successfully Created Note.'
5467
+ description: 'Note saved successfully.'
5470
5468
  });
5471
- setNoteLoadingStore(!NoteLoadingStore);
5472
5469
  setNoteText('');
5473
- } else if (error) {
5474
- // Error: Set error notification
5475
- setNotificationData({
5476
- type: 'error',
5470
+ setRecallAuditLog(true);
5471
+ } else {
5472
+ notification.error({
5477
5473
  message: 'Error',
5478
- description: error || 'Something went wrong. Please try again.'
5474
+ description: 'Failed to save note.'
5479
5475
  });
5480
5476
  }
5481
5477
  _context.next = 15;
5482
5478
  break;
5483
5479
  case 12:
5484
5480
  _context.prev = 12;
5485
- _context.t0 = _context["catch"](4);
5486
- // console.error('Error saving note:', error);
5487
- // alert('Failed to save note');
5481
+ _context.t0 = _context["catch"](5);
5488
5482
  notification.error({
5489
5483
  message: 'Error',
5490
- description: "" + _context.t0 || 'An error has occurred. Please try again later.'
5484
+ description: 'Failed to save note due to an error.'
5491
5485
  });
5492
5486
  case 15:
5493
5487
  case "end":
5494
5488
  return _context.stop();
5495
5489
  }
5496
- }, _callee, null, [[4, 12]]);
5490
+ }, _callee, null, [[5, 12]]);
5497
5491
  }));
5498
5492
  return function saveNote() {
5499
5493
  return _ref.apply(this, arguments);
@@ -5600,22 +5594,23 @@ function AuditLogs() {
5600
5594
  var Container$C = /*#__PURE__*/styled.div(_templateObject$Z || (_templateObject$Z = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n height: 295px; /* Set height to limit container size */\n overflow: auto; /* Enable scrolling */\n scrollbar-width: thin;\n"])));
5601
5595
 
5602
5596
  var _templateObject$_, _templateObject2$L, _templateObject3$m;
5597
+ // import { useLocation } from 'react-router-dom';
5603
5598
  function Notes() {
5604
5599
  var _usemoduleIds = usemoduleIds(),
5605
5600
  moduleIds = _usemoduleIds[0],
5606
5601
  setModuleIds = _usemoduleIds[1];
5607
5602
  var _useOrderId = useOrderId(),
5608
5603
  orderId = _useOrderId[0];
5609
- var location = useLocation();
5610
- var pathname = location.pathname;
5611
- var orderIdLocaation = pathname.split('/')[1];
5612
- var _UseNotesLoading = UseNotesLoading(),
5613
- apiBaseLoading = _UseNotesLoading[0];
5604
+ // const location = useLocation();
5605
+ // const pathname = location.pathname;
5606
+ // const orderIdLocaation = pathname.split('/')[1];
5607
+ var _useGlobalStateHitAud = useGlobalStateHitAuditLog(),
5608
+ recallAuditLog = _useGlobalStateHitAud[0];
5609
+ var _useAuditLogLoadingSt = useAuditLogLoadingState(),
5610
+ setAuditLogLoading = _useAuditLogLoadingSt[1];
5614
5611
  var _usegetNotes = usegetNotes(),
5615
5612
  setNotes = _usegetNotes[1];
5616
5613
  // const [loderStatus] = useCallAPi();
5617
- var _SeteauditLogToggle = SeteauditLogToggle(),
5618
- auditState = _SeteauditLogToggle[0];
5619
5614
  // Fetch module IDs
5620
5615
  var _useApiHook = useApiHook({
5621
5616
  endpoint: 'audit_logs/modules/',
@@ -5646,7 +5641,7 @@ function Notes() {
5646
5641
  }
5647
5642
  }, [apiLoading, fetchedData]);
5648
5643
  var _useApiHook2 = useApiHook({
5649
- endpoint: "audit_logs/?module_id=" + (moduleIds == null ? void 0 : moduleIds.parentId) + "&module_object_id=" + (orderId || orderIdLocaation),
5644
+ endpoint: "audit_logs/?module_id=" + (moduleIds == null ? void 0 : moduleIds.parentId) + "&module_object_id=" + orderId,
5650
5645
  method: 'GET',
5651
5646
  performAction: false
5652
5647
  }),
@@ -5654,7 +5649,6 @@ function Notes() {
5654
5649
  NotesLoading = _useApiHook2.loading,
5655
5650
  setShouldPerformAction = _useApiHook2.setShouldPerformAction;
5656
5651
  useEffect(function () {
5657
- var combinedArray = [];
5658
5652
  if (moduleIds && orderId) {
5659
5653
  setShouldPerformAction(true);
5660
5654
  }
@@ -5664,16 +5658,18 @@ function Notes() {
5664
5658
  }).map(function (item) {
5665
5659
  return [item['ORDER-NOTE'], item['ORDER']];
5666
5660
  }).flat().filter(Boolean);
5667
- combinedArray = updatedData.flat();
5661
+ // const orderData = NotesData?.data[0]?.ORDER || [];
5662
+ // const orderNotesData = NotesData?.data[1]?.['ORDER-NOTE'] || [];
5663
+ // const allNotes = [...orderData, ...orderNotesData];
5664
+ var combinedArray = updatedData.flat();
5668
5665
  combinedArray.sort(function (a, b) {
5669
5666
  return new Date(b.created_at).getTime() - new Date(a.created_at).getTime();
5670
5667
  });
5668
+ setNotes(combinedArray);
5669
+ recallAuditLog ? setShouldPerformAction(true) : setShouldPerformAction(false);
5671
5670
  }
5672
- setNotes({
5673
- data: combinedArray,
5674
- loading: NotesLoading
5675
- });
5676
- }, [moduleIds, NotesLoading, auditState, apiBaseLoading]);
5671
+ setAuditLogLoading(NotesLoading);
5672
+ }, [moduleIds, orderId, NotesLoading, recallAuditLog]);
5677
5673
  return React.createElement(Container$D, null, React.createElement(CardHeader, null, "NOTES"), React.createElement(CustomizedFormSection, null, React.createElement(AddNote, null), React.createElement(AuditLogs, null)));
5678
5674
  }
5679
5675
  var Container$D = /*#__PURE__*/styled.div(_templateObject$_ || (_templateObject$_ = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n border-radius: 5px;\n"])));