@bjsdistribution/dms-client-return 0.0.58 → 0.0.60

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.
@@ -86,7 +86,6 @@ declare function useSelectedProductId(): [number | undefined, (args_0: number |
86
86
  export declare function useReturnAfterOrderData(): [any[], (args_0: any[] | ((prev: any[]) => any[])) => void];
87
87
  declare function useClientData(): [ClientData[], (args_0: ClientData[] | ((prev: ClientData[]) => ClientData[])) => void];
88
88
  export { useAtom, useOrderDetails, useCustomerDetails, useProductDetails, useDepotDetails, useStatusDetails, useDepotOptions, usePrevOrderDetails, useEscData, useDeleteProdsID, useCreateOrderProducts, useRecieveOrderProducts, useUpdateOrderProducts, useOrderProductsResources, useOrderProductsToolbox, useOrderProductSystemLogs, useEventNotesData, useSelectedProductId, useSelectedProductActionTabKey, useClientData, };
89
- export declare const UseNotesLoading: () => [boolean, (args_0: boolean | ((prev: boolean) => boolean)) => void];
90
89
  export declare function usegetNotes(): [any, (args_0: any) => void];
91
90
  export declare function usemoduleIds(): [{
92
91
  id?: string | undefined;
@@ -110,16 +109,17 @@ export declare function useRouteId(): [number | undefined, (args_0: number | ((p
110
109
  export declare function useGsitOrderId(): [number | undefined, (args_0: number | ((prev: number | undefined) => number | undefined) | undefined) => void];
111
110
  export declare function useOrderProductId(): [number | undefined, (args_0: number | ((prev: number | undefined) => number | undefined) | undefined) => void];
112
111
  export declare function useReturnData(): [any[], (args_0: any[] | ((prev: any[]) => any[])) => void];
113
- export declare function useApiCalling(): [boolean, (args_0: boolean | ((prev: boolean) => boolean)) => void];
114
- export declare function useGlobalStateHitAuditLog(): [boolean, (args_0: boolean | ((prev: boolean) => boolean)) => void];
112
+ export declare function useUpdateApiCall(): [boolean, (args_0: boolean | ((prev: boolean) => boolean)) => void];
115
113
  export declare function useLiveRecalling(): [boolean, (args_0: boolean | ((prev: boolean) => boolean)) => void];
114
+ export declare function useDeleteRecall(): [boolean, (args_0: boolean | ((prev: boolean) => boolean)) => void];
116
115
  export declare const selectedTabKeyAtom: import("jotai/esm/").PrimitiveAtom<string> & {
117
116
  init: string;
118
117
  };
119
118
  export declare const letselectedProductIdAtom: import("jotai/esm/").PrimitiveAtom<number | null> & {
120
119
  init: number | null;
121
120
  };
122
- export declare const SeteauditLogToggle: () => [boolean, (args_0: boolean | ((prev: boolean) => boolean)) => void];
121
+ export declare function useAuditLogLoadingState(): [boolean, (args_0: boolean | ((prev: boolean) => boolean)) => void];
122
+ export declare function useGlobalStateHitAuditLog(): [boolean, (args_0: boolean | ((prev: boolean) => boolean)) => void];
123
123
  export declare const countReducerAtom: import("jotai/esm/").WritableAtom<{
124
124
  state: any;
125
125
  } | null, [any?], void>;
@@ -593,7 +593,7 @@ var loading = /*#__PURE__*/jotai.atom(false);
593
593
  var useStatsLoading = function useStatsLoading() {
594
594
  return jotai.useAtom(loading);
595
595
  };
596
- //this
596
+ //order return page
597
597
  var loadingState = /*#__PURE__*/jotai.atom(false);
598
598
  var useLoading = function useLoading() {
599
599
  return jotai.useAtom(loadingState);
@@ -823,10 +823,6 @@ var clientDataAtom = /*#__PURE__*/jotai.atom([]);
823
823
  function useClientData() {
824
824
  return jotai.useAtom(clientDataAtom);
825
825
  }
826
- var NotesLoading = /*#__PURE__*/jotai.atom(true);
827
- var UseNotesLoading = function UseNotesLoading() {
828
- return jotai.useAtom(NotesLoading);
829
- };
830
826
  var notes = /*#__PURE__*/jotai.atom([]);
831
827
  function usegetNotes() {
832
828
  return jotai.useAtom(notes);
@@ -859,9 +855,9 @@ var returnDataAtom = /*#__PURE__*/jotai.atom([]);
859
855
  function useReturnData() {
860
856
  return jotai.useAtom(returnDataAtom);
861
857
  }
862
- var apiCalling = /*#__PURE__*/jotai.atom(false);
863
- function useApiCalling() {
864
- return jotai.useAtom(apiCalling);
858
+ var apiUpdateCalling = /*#__PURE__*/jotai.atom(false);
859
+ function useUpdateApiCall() {
860
+ return jotai.useAtom(apiUpdateCalling);
865
861
  }
866
862
  var liveRecalling = /*#__PURE__*/jotai.atom(false);
867
863
  //re api call of live status
@@ -872,10 +868,14 @@ function useLiveRecalling() {
872
868
  // export const useBulkUPdateDisabledState = () => {
873
869
  // return useAtom(BulkUPdateDisabledState);
874
870
  // };
875
- var auditLogToggle = /*#__PURE__*/jotai.atom(true);
876
- var SeteauditLogToggle = function SeteauditLogToggle() {
877
- return jotai.useAtom(auditLogToggle);
878
- };
871
+ var auditLogLoadingState = /*#__PURE__*/jotai.atom(true);
872
+ function useAuditLogLoadingState() {
873
+ return jotai.useAtom(auditLogLoadingState);
874
+ }
875
+ var globalStateHitAuditLog = /*#__PURE__*/jotai.atom(false);
876
+ function useGlobalStateHitAuditLog() {
877
+ return jotai.useAtom(globalStateHitAuditLog);
878
+ }
879
879
  // Popup state Manage
880
880
  var initialState$1 = null;
881
881
  var popupReducer = function popupReducer(state, action) {
@@ -1080,7 +1080,8 @@ function SelectionFilter() {
1080
1080
  if (!currentSearch.includes('filter')) {
1081
1081
  console.log('inside include');
1082
1082
  // for dev
1083
- navigate("filter?" + queryParams.toString());
1083
+ //navigate(`filter?${queryParams.toString()}`);
1084
+ navigate("/orders/view/return/filter?" + queryParams.toString());
1084
1085
  // for local
1085
1086
  //navigate(`/filter?${queryParams.toString()}`);
1086
1087
  }
@@ -1173,7 +1174,7 @@ function SelectionFilter() {
1173
1174
  dispatch({
1174
1175
  type: 'CLEAR_CLIENT'
1175
1176
  });
1176
- window.location.href = '/order/return';
1177
+ window.location.href = '/orders/view/return/';
1177
1178
  }
1178
1179
  }, [clearState]);
1179
1180
  React.useEffect(function () {
@@ -5205,6 +5206,8 @@ var Container$y = /*#__PURE__*/styled__default.div(_templateObject3$h || (_templ
5205
5206
  function useUpdateOrder() {
5206
5207
  var controller;
5207
5208
  var ssoToken = getCookie('id_token');
5209
+ var _useUpdateApiCall = useUpdateApiCall(),
5210
+ setCallApi = _useUpdateApiCall[1]; //single detail
5208
5211
  var update = /*#__PURE__*/function () {
5209
5212
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data) {
5210
5213
  var endpoint, signal, requestOptions, response, json;
@@ -5247,9 +5250,10 @@ function useUpdateOrder() {
5247
5250
  message: 'Success',
5248
5251
  description: 'Order has been updated.'
5249
5252
  });
5253
+ setCallApi(true);
5250
5254
  return _context.abrupt("return", json);
5251
- case 18:
5252
- _context.prev = 18;
5255
+ case 19:
5256
+ _context.prev = 19;
5253
5257
  _context.t0 = _context["catch"](4);
5254
5258
  // setLoading(false);
5255
5259
  // console.log(err, 'error');
@@ -5257,14 +5261,14 @@ function useUpdateOrder() {
5257
5261
  message: 'Error',
5258
5262
  description: "" + _context.t0 || 'An error has occurred. Please try again later.'
5259
5263
  });
5260
- case 21:
5261
- _context.prev = 21;
5262
- return _context.finish(21);
5263
- case 23:
5264
+ case 22:
5265
+ _context.prev = 22;
5266
+ return _context.finish(22);
5267
+ case 24:
5264
5268
  case "end":
5265
5269
  return _context.stop();
5266
5270
  }
5267
- }, _callee, null, [[4, 18, 21, 23]]);
5271
+ }, _callee, null, [[4, 19, 22, 24]]);
5268
5272
  }));
5269
5273
  return function update(_x) {
5270
5274
  return _ref.apply(this, arguments);
@@ -5287,8 +5291,8 @@ function OrderDetailsFooter() {
5287
5291
  var _useAtom = jotai.useAtom(errorAtom),
5288
5292
  errorState = _useAtom[0];
5289
5293
  // const [, setLogsCallAPi] = useLogsCallAPi();
5290
- var _useApiCalling = useApiCalling(),
5291
- setCallApi = _useApiCalling[1]; //single detail
5294
+ var _useUpdateApiCall = useUpdateApiCall(),
5295
+ setCallApi = _useUpdateApiCall[1]; //single detail
5292
5296
  // const [, setNoteLoadingStore] = UseNotesLoading();
5293
5297
  var errorFound = function errorFound() {
5294
5298
  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;
@@ -5319,12 +5323,12 @@ function OrderDetailsFooter() {
5319
5323
  return _regeneratorRuntime().wrap(function _callee$(_context) {
5320
5324
  while (1) switch (_context.prev = _context.next) {
5321
5325
  case 0:
5322
- setCallApi(true);
5323
5326
  payload = compareOrderDetailsStates(prevOrderDetails, orderDetails);
5324
- _context.next = 4;
5327
+ _context.next = 3;
5325
5328
  return updateOrder([payload]);
5326
- case 4:
5329
+ case 3:
5327
5330
  response = _context.sent;
5331
+ setCallApi(false);
5328
5332
  // setLogsCallAPi(prev => !prev);
5329
5333
  if (response && (response == null || (_response$data = response.data) == null ? void 0 : _response$data.length) > 0) {
5330
5334
  setOrderDetails(response == null ? void 0 : response.data[0]);
@@ -5424,25 +5428,25 @@ function AddNote() {
5424
5428
  var ssoToken = getCookie('id_token');
5425
5429
  var _usemoduleIds = usemoduleIds(),
5426
5430
  moduleIds = _usemoduleIds[0];
5427
- var _UseNotesLoading = UseNotesLoading(),
5428
- NoteLoadingStore = _UseNotesLoading[0],
5429
- setNoteLoadingStore = _UseNotesLoading[1];
5431
+ var _useGlobalStateHitAud = useGlobalStateHitAuditLog(),
5432
+ setRecallAuditLog = _useGlobalStateHitAud[1];
5430
5433
  // Save New Note
5431
5434
  var _useState2 = React.useState(null),
5432
5435
  notificationData = _useState2[0],
5433
5436
  setNotificationData = _useState2[1];
5434
5437
  var saveNote = /*#__PURE__*/function () {
5435
5438
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
5436
- var endpoint, payload, response, message, error;
5439
+ var endpoint, payload, response;
5437
5440
  return _regeneratorRuntime().wrap(function _callee$(_context) {
5438
5441
  while (1) switch (_context.prev = _context.next) {
5439
5442
  case 0:
5443
+ setRecallAuditLog(false);
5440
5444
  if (noteText) {
5441
- _context.next = 2;
5445
+ _context.next = 3;
5442
5446
  break;
5443
5447
  }
5444
5448
  return _context.abrupt("return");
5445
- case 2:
5449
+ case 3:
5446
5450
  endpoint = dmsComponentLibrary.getBaseEndpoint() + "/audit_logs/orders/";
5447
5451
  payload = {
5448
5452
  audit_logs: [{
@@ -5456,8 +5460,8 @@ function AddNote() {
5456
5460
  manual: 1
5457
5461
  }]
5458
5462
  };
5459
- _context.prev = 4;
5460
- _context.next = 7;
5463
+ _context.prev = 5;
5464
+ _context.next = 8;
5461
5465
  return fetch(endpoint, {
5462
5466
  method: 'POST',
5463
5467
  headers: {
@@ -5466,42 +5470,36 @@ function AddNote() {
5466
5470
  },
5467
5471
  body: JSON.stringify(payload)
5468
5472
  });
5469
- case 7:
5473
+ case 8:
5470
5474
  response = _context.sent;
5471
5475
  // setNoteLoadingStore(false);
5472
- message = response.message, error = response.error;
5473
- if (response) {
5474
- setNotificationData({
5475
- type: 'success',
5476
+ if (response.ok) {
5477
+ antd.notification.success({
5476
5478
  message: 'Success',
5477
- description: message || 'Successfully Created Note.'
5479
+ description: 'Note saved successfully.'
5478
5480
  });
5479
- setNoteLoadingStore(!NoteLoadingStore);
5480
5481
  setNoteText('');
5481
- } else if (error) {
5482
- // Error: Set error notification
5483
- setNotificationData({
5484
- type: 'error',
5482
+ setRecallAuditLog(true);
5483
+ } else {
5484
+ antd.notification.error({
5485
5485
  message: 'Error',
5486
- description: error || 'Something went wrong. Please try again.'
5486
+ description: 'Failed to save note.'
5487
5487
  });
5488
5488
  }
5489
5489
  _context.next = 15;
5490
5490
  break;
5491
5491
  case 12:
5492
5492
  _context.prev = 12;
5493
- _context.t0 = _context["catch"](4);
5494
- // console.error('Error saving note:', error);
5495
- // alert('Failed to save note');
5493
+ _context.t0 = _context["catch"](5);
5496
5494
  antd.notification.error({
5497
5495
  message: 'Error',
5498
- description: "" + _context.t0 || 'An error has occurred. Please try again later.'
5496
+ description: 'Failed to save note due to an error.'
5499
5497
  });
5500
5498
  case 15:
5501
5499
  case "end":
5502
5500
  return _context.stop();
5503
5501
  }
5504
- }, _callee, null, [[4, 12]]);
5502
+ }, _callee, null, [[5, 12]]);
5505
5503
  }));
5506
5504
  return function saveNote() {
5507
5505
  return _ref.apply(this, arguments);
@@ -5608,22 +5606,23 @@ function AuditLogs() {
5608
5606
  var Container$C = /*#__PURE__*/styled__default.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"])));
5609
5607
 
5610
5608
  var _templateObject$_, _templateObject2$L, _templateObject3$m;
5609
+ // import { useLocation } from 'react-router-dom';
5611
5610
  function Notes() {
5612
5611
  var _usemoduleIds = usemoduleIds(),
5613
5612
  moduleIds = _usemoduleIds[0],
5614
5613
  setModuleIds = _usemoduleIds[1];
5615
5614
  var _useOrderId = useOrderId(),
5616
5615
  orderId = _useOrderId[0];
5617
- var location = reactRouterDom.useLocation();
5618
- var pathname = location.pathname;
5619
- var orderIdLocaation = pathname.split('/')[1];
5620
- var _UseNotesLoading = UseNotesLoading(),
5621
- apiBaseLoading = _UseNotesLoading[0];
5616
+ // const location = useLocation();
5617
+ // const pathname = location.pathname;
5618
+ // const orderIdLocaation = pathname.split('/')[1];
5619
+ var _useGlobalStateHitAud = useGlobalStateHitAuditLog(),
5620
+ recallAuditLog = _useGlobalStateHitAud[0];
5621
+ var _useAuditLogLoadingSt = useAuditLogLoadingState(),
5622
+ setAuditLogLoading = _useAuditLogLoadingSt[1];
5622
5623
  var _usegetNotes = usegetNotes(),
5623
5624
  setNotes = _usegetNotes[1];
5624
5625
  // const [loderStatus] = useCallAPi();
5625
- var _SeteauditLogToggle = SeteauditLogToggle(),
5626
- auditState = _SeteauditLogToggle[0];
5627
5626
  // Fetch module IDs
5628
5627
  var _useApiHook = dmsComponentLibrary.useApiHook({
5629
5628
  endpoint: 'audit_logs/modules/',
@@ -5654,7 +5653,7 @@ function Notes() {
5654
5653
  }
5655
5654
  }, [apiLoading, fetchedData]);
5656
5655
  var _useApiHook2 = dmsComponentLibrary.useApiHook({
5657
- endpoint: "audit_logs/?module_id=" + (moduleIds == null ? void 0 : moduleIds.parentId) + "&module_object_id=" + (orderId || orderIdLocaation),
5656
+ endpoint: "audit_logs/?module_id=" + (moduleIds == null ? void 0 : moduleIds.parentId) + "&module_object_id=" + orderId,
5658
5657
  method: 'GET',
5659
5658
  performAction: false
5660
5659
  }),
@@ -5662,7 +5661,6 @@ function Notes() {
5662
5661
  NotesLoading = _useApiHook2.loading,
5663
5662
  setShouldPerformAction = _useApiHook2.setShouldPerformAction;
5664
5663
  React.useEffect(function () {
5665
- var combinedArray = [];
5666
5664
  if (moduleIds && orderId) {
5667
5665
  setShouldPerformAction(true);
5668
5666
  }
@@ -5672,16 +5670,18 @@ function Notes() {
5672
5670
  }).map(function (item) {
5673
5671
  return [item['ORDER-NOTE'], item['ORDER']];
5674
5672
  }).flat().filter(Boolean);
5675
- combinedArray = updatedData.flat();
5673
+ // const orderData = NotesData?.data[0]?.ORDER || [];
5674
+ // const orderNotesData = NotesData?.data[1]?.['ORDER-NOTE'] || [];
5675
+ // const allNotes = [...orderData, ...orderNotesData];
5676
+ var combinedArray = updatedData.flat();
5676
5677
  combinedArray.sort(function (a, b) {
5677
5678
  return new Date(b.created_at).getTime() - new Date(a.created_at).getTime();
5678
5679
  });
5680
+ setNotes(combinedArray);
5681
+ recallAuditLog ? setShouldPerformAction(true) : setShouldPerformAction(false);
5679
5682
  }
5680
- setNotes({
5681
- data: combinedArray,
5682
- loading: NotesLoading
5683
- });
5684
- }, [moduleIds, NotesLoading, auditState, apiBaseLoading]);
5683
+ setAuditLogLoading(NotesLoading);
5684
+ }, [moduleIds, orderId, NotesLoading, recallAuditLog]);
5685
5685
  return React__default.createElement(Container$D, null, React__default.createElement(CardHeader, null, "NOTES"), React__default.createElement(CustomizedFormSection, null, React__default.createElement(AddNote, null), React__default.createElement(AuditLogs, null)));
5686
5686
  }
5687
5687
  var Container$D = /*#__PURE__*/styled__default.div(_templateObject$_ || (_templateObject$_ = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n border-radius: 5px;\n"])));
@@ -6603,7 +6603,8 @@ function ExpandedContent$2() {
6603
6603
  }
6604
6604
  //@ts-ignore
6605
6605
  if ((response == null ? void 0 : response.code) === 200 && newId) {
6606
- navigate("details/" + newId);
6606
+ // suggested by rahul
6607
+ navigate("" + newId);
6607
6608
  setSelectedProducts([]);
6608
6609
  }
6609
6610
  }, [response, newId, navigate, setSelectedProducts]);
@@ -11590,7 +11591,8 @@ var ReturnTable$1 = function ReturnTable() {
11590
11591
  customerId: customerId == null ? void 0 : customerId.toString()
11591
11592
  });
11592
11593
  //for dev
11593
- navigate("filter?" + queryParams.toString());
11594
+ //navigate(`filter?${queryParams.toString()}`);
11595
+ navigate("/orders/view/return/filter?" + queryParams.toString());
11594
11596
  //for local
11595
11597
  //navigate(`/filter?${queryParams.toString()}`);
11596
11598
  };
@@ -11616,13 +11618,12 @@ var ReturnTable$1 = function ReturnTable() {
11616
11618
  type: RTS
11617
11619
  });
11618
11620
  //for dev
11619
- navigate("filter?" + queryParams.toString());
11621
+ //navigate(`filter?${queryParams.toString()}`);
11622
+ navigate("/orders/view/return/filter?" + queryParams.toString());
11620
11623
  //for local
11621
11624
  //navigate(`/filter?${queryParams.toString()}`);
11622
11625
  };
11623
- return React__default.createElement(React__default.Fragment, null, statsLoading && React__default.createElement(Loader, null), React__default.createElement(StyledTableWrapper, {
11624
- id: "tableScrolling"
11625
- }, React__default.createElement(StyledTable, null, React__default.createElement("thead", null, React__default.createElement("tr", null, [{
11626
+ return React__default.createElement(React__default.Fragment, null, statsLoading && React__default.createElement(Loader, null), React__default.createElement(StyledTableWrapper, null, React__default.createElement(StyledTable, null, React__default.createElement("thead", null, React__default.createElement("tr", null, [{
11626
11627
  label: 'Trading Name',
11627
11628
  key: 'trading_as'
11628
11629
  }, {
@@ -11862,6 +11863,8 @@ function ReturnClient() {
11862
11863
  setSelectedClient = _useSelectedClient[1];
11863
11864
  var _useSearchParams = reactRouterDom.useSearchParams(),
11864
11865
  searchParams = _useSearchParams[0];
11866
+ var _useSelectedLocation = useSelectedLocation(),
11867
+ setSelectedLocationValue = _useSelectedLocation[1];
11865
11868
  var splitPath = function splitPath(str) {
11866
11869
  var _str$split;
11867
11870
  var parts = str == null || (_str$split = str.split('/')) == null ? void 0 : _str$split.filter(function (part) {
@@ -11876,6 +11879,7 @@ function ReturnClient() {
11876
11879
  setLocationOptions([]);
11877
11880
  setSelectedClient(null);
11878
11881
  setSelectedFilterValue(null);
11882
+ setSelectedLocationValue(null);
11879
11883
  }
11880
11884
  }, [location.pathname, searchParams]);
11881
11885
  // useEffect(() => {