@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.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.58",
2
+ "version": "0.0.60",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -168,7 +168,8 @@ function SelectionFilter() {
168
168
  if (!currentSearch.includes('filter')) {
169
169
  console.log('inside include');
170
170
  // for dev
171
- navigate(`filter?${queryParams.toString()}`);
171
+ //navigate(`filter?${queryParams.toString()}`);
172
+ navigate(`/orders/view/return/filter?${queryParams.toString()}`);
172
173
 
173
174
  // for local
174
175
  //navigate(`/filter?${queryParams.toString()}`);
@@ -272,7 +273,7 @@ function SelectionFilter() {
272
273
  useEffect(() => {
273
274
  if (clearState) {
274
275
  dispatch({ type: 'CLEAR_CLIENT' });
275
- window.location.href = '/order/return';
276
+ window.location.href = '/orders/view/return/';
276
277
  }
277
278
  }, [clearState]);
278
279
 
@@ -41,7 +41,7 @@ export const useStatsLoading = () => {
41
41
  return useAtom(loading);
42
42
  };
43
43
 
44
- //this
44
+ //order return page
45
45
  const loadingState = atom<boolean>(false);
46
46
  export const useLoading = () => {
47
47
  return useAtom(loadingState);
@@ -138,7 +138,8 @@ const ReturnTable: React.FC = () => {
138
138
  customerId: customerId?.toString(),
139
139
  });
140
140
  //for dev
141
- navigate(`filter?${queryParams.toString()}`);
141
+ //navigate(`filter?${queryParams.toString()}`);
142
+ navigate(`/orders/view/return/filter?${queryParams.toString()}`);
142
143
 
143
144
  //for local
144
145
  //navigate(`/filter?${queryParams.toString()}`);
@@ -167,7 +168,8 @@ const ReturnTable: React.FC = () => {
167
168
  type: RTS,
168
169
  });
169
170
  //for dev
170
- navigate(`filter?${queryParams.toString()}`);
171
+ //navigate(`filter?${queryParams.toString()}`);
172
+ navigate(`/orders/view/return/filter?${queryParams.toString()}`);
171
173
 
172
174
  //for local
173
175
  //navigate(`/filter?${queryParams.toString()}`);
@@ -176,7 +178,7 @@ const ReturnTable: React.FC = () => {
176
178
  return (
177
179
  <>
178
180
  {statsLoading && <Loader />}
179
- <StyledTableWrapper id="tableScrolling">
181
+ <StyledTableWrapper>
180
182
  <StyledTable>
181
183
  <thead>
182
184
  <tr>
@@ -1,10 +1,12 @@
1
1
  import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
2
2
  import { getCookie } from '../utils';
3
3
  import { notification } from 'antd';
4
+ import { useUpdateApiCall } from '../store';
4
5
 
5
6
  function useUpdateOrder() {
6
7
  let controller: AbortController;
7
8
  const ssoToken = getCookie('id_token');
9
+ const [, setCallApi] = useUpdateApiCall(); //single detail
8
10
 
9
11
  const update = async (data: any) => {
10
12
  const endpoint = `${getBaseEndpoint()}/orders/update/`;
@@ -38,6 +40,7 @@ function useUpdateOrder() {
38
40
  message: 'Success',
39
41
  description: 'Order has been updated.',
40
42
  });
43
+ setCallApi(true);
41
44
  return json;
42
45
  } catch (err) {
43
46
  // setLoading(false);
@@ -58,7 +58,6 @@ function OrderView() {
58
58
  const [, setDepotOptions] = useDepotOptions();
59
59
  const [, setCustomerInfo] = useCustomerInfo();
60
60
  const [, setLocationOptions] = useLocationOptions();
61
-
62
61
  const [orderResources, setOrderResources] = useOrderProductsResources();
63
62
  const [orderToolbox, setOrderToolbox] = useOrderProductsToolbox();
64
63
  const [GsitCUstomerId, setGsitCUstomerId] = useGsitCUstomerId();
@@ -1,11 +1,11 @@
1
1
  import React, { useEffect } from 'react';
2
2
  import { useDeleteProdsID, useProductDetails } from '../store';
3
+ import { Empty, Skeleton } from 'antd';
3
4
  import {
4
5
  EmptyDataContainer,
5
6
  StyledTable,
6
7
  StyledTableWrapper,
7
- } from '../all-reminder/table-view/ReminderStyles';
8
- import { Empty, Skeleton } from 'antd';
8
+ } from '../order-actions/actions/confirm-order/tables/ReminderStyles';
9
9
 
10
10
  const DeleteProduct = () => {
11
11
  const [productdata] = useProductDetails();
@@ -9,7 +9,7 @@ import styled from 'styled-components';
9
9
  import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
10
10
  import { getCookie } from '../utils';
11
11
  import { useLocation } from 'react-router-dom';
12
- import { usemoduleIds, UseNotesLoading, useOrderId } from '../store';
12
+ import { useGlobalStateHitAuditLog, usemoduleIds, useOrderId } from '../store';
13
13
  import { notification } from 'antd';
14
14
 
15
15
  function AddNote() {
@@ -22,8 +22,8 @@ function AddNote() {
22
22
 
23
23
  const ssoToken = getCookie('id_token');
24
24
  const [moduleIds] = usemoduleIds();
25
+ const [, setRecallAuditLog] = useGlobalStateHitAuditLog();
25
26
 
26
- const [NoteLoadingStore, setNoteLoadingStore] = UseNotesLoading();
27
27
 
28
28
  // Save New Note
29
29
 
@@ -34,6 +34,7 @@ function AddNote() {
34
34
  } | null>(null);
35
35
 
36
36
  const saveNote = async () => {
37
+ setRecallAuditLog(false);
37
38
  if (!noteText) return;
38
39
  const endpoint = `${getBaseEndpoint()}/audit_logs/orders/`;
39
40
  const payload = {
@@ -63,30 +64,23 @@ function AddNote() {
63
64
 
64
65
  // setNoteLoadingStore(false);
65
66
 
66
- const { message, error }: any = response;
67
- if (response) {
68
- setNotificationData({
69
- type: 'success',
67
+ if (response.ok) {
68
+ notification.success({
70
69
  message: 'Success',
71
- description: message || 'Successfully Created Note.',
70
+ description: 'Note saved successfully.',
72
71
  });
73
- setNoteLoadingStore(!NoteLoadingStore);
74
72
  setNoteText('');
75
- } else if (error) {
76
- // Error: Set error notification
77
- setNotificationData({
78
- type: 'error',
73
+ setRecallAuditLog(true);
74
+ } else {
75
+ notification.error({
79
76
  message: 'Error',
80
- description: error || 'Something went wrong. Please try again.',
77
+ description: 'Failed to save note.',
81
78
  });
82
79
  }
83
80
  } catch (error) {
84
- // console.error('Error saving note:', error);
85
- // alert('Failed to save note');
86
81
  notification.error({
87
82
  message: 'Error',
88
- description:
89
- `${error}` || 'An error has occurred. Please try again later.',
83
+ description: 'Failed to save note due to an error.',
90
84
  });
91
85
  }
92
86
  };
@@ -4,24 +4,27 @@ import AddNote from './AddNote';
4
4
  import AuditLogs from './logs';
5
5
  import { useApiHook } from '@bjsdistribution/dms-component-library';
6
6
  import {
7
- SeteauditLogToggle,
7
+ useAuditLogLoadingState,
8
8
  // useCallAPi,
9
9
  usegetNotes,
10
+ useGlobalStateHitAuditLog,
10
11
  usemoduleIds,
11
- UseNotesLoading,
12
12
  useOrderId,
13
13
  } from '../store';
14
- import { useLocation } from 'react-router-dom';
14
+ // import { useLocation } from 'react-router-dom';
15
15
  function Notes() {
16
16
  const [moduleIds, setModuleIds] = usemoduleIds();
17
17
  const [orderId] = useOrderId();
18
- const location = useLocation();
19
- const pathname = location.pathname;
20
- const orderIdLocaation = pathname.split('/')[1];
21
- const [apiBaseLoading] = UseNotesLoading();
18
+ // const location = useLocation();
19
+ // const pathname = location.pathname;
20
+ // const orderIdLocaation = pathname.split('/')[1];
21
+
22
+ const[recallAuditLog] = useGlobalStateHitAuditLog()
23
+
24
+ const [,setAuditLogLoading] = useAuditLogLoadingState()
25
+
22
26
  const [, setNotes] = usegetNotes();
23
27
  // const [loderStatus] = useCallAPi();
24
- const [auditState] = SeteauditLogToggle();
25
28
 
26
29
  // Fetch module IDs
27
30
  const { data: fetchedData, loading: apiLoading } = useApiHook<{ data: any }>({
@@ -58,15 +61,14 @@ function Notes() {
58
61
  } = useApiHook<{ data: any }>({
59
62
  endpoint: `audit_logs/?module_id=${
60
63
  moduleIds?.parentId
61
- }&module_object_id=${orderId || orderIdLocaation}`,
64
+ }&module_object_id=${orderId}`,
62
65
  method: 'GET',
63
66
  performAction: false,
64
67
  });
65
68
 
66
69
  useEffect(() => {
67
- let combinedArray = [];
68
-
69
- if (moduleIds && orderId) {
70
+ if (moduleIds && orderId ) {
71
+
70
72
  setShouldPerformAction(true);
71
73
  }
72
74
  if (!NotesLoading && NotesData?.data) {
@@ -75,14 +77,21 @@ function Notes() {
75
77
  .map((item: any) => [item['ORDER-NOTE'], item['ORDER']])
76
78
  .flat()
77
79
  .filter(Boolean);
78
- combinedArray = updatedData.flat();
80
+
81
+ // const orderData = NotesData?.data[0]?.ORDER || [];
82
+ // const orderNotesData = NotesData?.data[1]?.['ORDER-NOTE'] || [];
83
+ // const allNotes = [...orderData, ...orderNotesData];
84
+ const combinedArray = updatedData.flat();
79
85
  combinedArray.sort(
80
86
  (a: any, b: any) =>
81
87
  new Date(b.created_at).getTime() - new Date(a.created_at).getTime()
82
88
  );
89
+ setNotes(combinedArray);
90
+ recallAuditLog ? setShouldPerformAction(true) : setShouldPerformAction(false)
91
+
83
92
  }
84
- setNotes({ data: combinedArray, loading: NotesLoading });
85
- }, [moduleIds, NotesLoading, auditState, apiBaseLoading]);
93
+ setAuditLogLoading(NotesLoading)
94
+ }, [moduleIds,orderId,NotesLoading,recallAuditLog]);
86
95
 
87
96
  return (
88
97
  <Container>
@@ -9,7 +9,7 @@ import {
9
9
  errorAtom,
10
10
  useCustomerInfo,
11
11
  // useLogsCallAPi,
12
- useApiCalling,
12
+ useUpdateApiCall,
13
13
  // UseNotesLoading,
14
14
  } from '../../../store';
15
15
  import useUpdateOrder from '../../../hooks/useUpdateOrder';
@@ -23,7 +23,7 @@ function OrderDetailsFooter() {
23
23
  const updateOrder = useUpdateOrder();
24
24
  const [errorState] = useAtom(errorAtom);
25
25
  // const [, setLogsCallAPi] = useLogsCallAPi();
26
- const [, setCallApi] = useApiCalling(); //single detail
26
+ const [, setCallApi] = useUpdateApiCall(); //single detail
27
27
  // const [, setNoteLoadingStore] = UseNotesLoading();
28
28
 
29
29
  const errorFound = () => {
@@ -78,12 +78,10 @@ function OrderDetailsFooter() {
78
78
  };
79
79
 
80
80
  const onSave = async () => {
81
- setCallApi(true);
82
81
  const payload = compareOrderDetailsStates(prevOrderDetails, orderDetails);
83
82
  const response = await updateOrder([payload]);
84
-
83
+ setCallApi(false);
85
84
  // setLogsCallAPi(prev => !prev);
86
-
87
85
  if (response && response?.data?.length > 0) {
88
86
  setOrderDetails(response?.data[0]);
89
87
  setPrevOrderDetails(response?.data[0]);
@@ -81,7 +81,8 @@ function ExpandedContent() {
81
81
 
82
82
  //@ts-ignore
83
83
  if (response?.code === 200 && newId) {
84
- navigate(`details/${newId}`);
84
+ // suggested by rahul
85
+ navigate(`${newId}`);
85
86
  setSelectedProducts([]);
86
87
  }
87
88
  }, [response, newId, navigate, setSelectedProducts]);
@@ -163,7 +163,7 @@ function useIsOnHoldOrder() {
163
163
  }
164
164
  //value
165
165
  const orderId = atom<any>(undefined);
166
- export const useOrderId = () => {
166
+ export const useOrderId = () => { //dddddddddddd
167
167
  return useAtom(orderId);
168
168
  };
169
169
 
@@ -366,10 +366,6 @@ export {
366
366
  useClientData,
367
367
  };
368
368
 
369
- const NotesLoading = atom<boolean>(true);
370
- export const UseNotesLoading = () => {
371
- return useAtom(NotesLoading);
372
- };
373
369
 
374
370
  const notes = atom<any>([]);
375
371
 
@@ -437,15 +433,10 @@ const returnDataAtom = atom<any[]>([]);
437
433
  export function useReturnData() {
438
434
  return useAtom(returnDataAtom);
439
435
  }
440
- const apiCalling = atom<boolean>(false);
441
-
442
- export function useApiCalling() {
443
- return useAtom(apiCalling);
444
- }
436
+ const apiUpdateCalling = atom<boolean>(false);
445
437
 
446
- const globalStateHitAuditLog = atom<boolean>(false);
447
- export function useGlobalStateHitAuditLog() {
448
- return useAtom(globalStateHitAuditLog);
438
+ export function useUpdateApiCall() {
439
+ return useAtom(apiUpdateCalling);
449
440
  }
450
441
 
451
442
 
@@ -455,6 +446,14 @@ const liveRecalling = atom<boolean>(false);
455
446
  export function useLiveRecalling() {
456
447
  return useAtom(liveRecalling);
457
448
  }
449
+
450
+ //delete products
451
+ const onDeleteProduct = atom<boolean>(false);
452
+
453
+ export function useDeleteRecall() {
454
+ return useAtom(onDeleteProduct);
455
+ }
456
+
458
457
  export const selectedTabKeyAtom = atom<string>('1');
459
458
  export const letselectedProductIdAtom = atom<number | null>(null);
460
459
 
@@ -463,10 +462,19 @@ export const letselectedProductIdAtom = atom<number | null>(null);
463
462
  // return useAtom(BulkUPdateDisabledState);
464
463
  // };
465
464
 
466
- const auditLogToggle = atom<boolean>(true);
467
- export const SeteauditLogToggle = () => {
468
- return useAtom(auditLogToggle);
469
- };
465
+
466
+ const auditLogLoadingState = atom<boolean>(true);
467
+ export function useAuditLogLoadingState() {
468
+ return useAtom(auditLogLoadingState);
469
+ }
470
+
471
+
472
+ const globalStateHitAuditLog = atom<boolean>(false);
473
+ export function useGlobalStateHitAuditLog() {
474
+ return useAtom(globalStateHitAuditLog);
475
+ }
476
+
477
+
470
478
 
471
479
  // Popup state Manage
472
480
  const initialState = null;
@@ -482,12 +490,10 @@ const popupReducer = (state: any, action: any) => {
482
490
  } else if (action.type === 'addProduct') {
483
491
  state = 'addProduct';
484
492
  return { state };
485
- }
486
- else if (action.type === 'split-order') {
493
+ } else if (action.type === 'split-order') {
487
494
  state = 'split-order';
488
495
  return { state };
489
- }
490
- else if (action.type === 'deleteProduct') {
496
+ } else if (action.type === 'deleteProduct') {
491
497
  state = 'deleteProduct';
492
498
  return { state };
493
499
  } else if (action.type === 'defectsModal') {
package/src/index.tsx CHANGED
@@ -5,6 +5,7 @@ import ReturnAfterTable from './components/order-daily-overview/return-after-tab
5
5
  import {
6
6
  useSelectedAction,
7
7
  useSelectedClient,
8
+ useSelectedLocation,
8
9
  } from './components/order-daily-overview/store/store';
9
10
  import { notification } from 'antd';
10
11
  import RouterHeader from './components/order-daily-overview/header/route-header/RouterHeader';
@@ -36,6 +37,7 @@ function ReturnClient() {
36
37
  const [, setSelectedFilterValue] = useSelectedAction();
37
38
  const [, setSelectedClient] = useSelectedClient();
38
39
  const [searchParams] = useSearchParams();
40
+ const [, setSelectedLocationValue] = useSelectedLocation();
39
41
  const splitPath = (str: any) => {
40
42
  const parts = str?.split('/')?.filter((part: any) => part !== ''); // Filter out empty parts
41
43
  return parts;
@@ -47,6 +49,7 @@ function ReturnClient() {
47
49
  setLocationOptions([]);
48
50
  setSelectedClient(null);
49
51
  setSelectedFilterValue(null);
52
+ setSelectedLocationValue(null);
50
53
  }
51
54
  }, [location.pathname, searchParams]);
52
55
  // useEffect(() => {
@@ -114,7 +117,7 @@ function ReturnClient() {
114
117
  <Route path="" element={<OrderViewQueryHandler />} />
115
118
  <Route path="overview" element={<ReturnAfterTable />} />
116
119
  <Route path="/:id" element={<OrderView />} />
117
-
120
+
118
121
  <Route path="filter" element={<ReturnTable />} />
119
122
  {/* <Route
120
123
  path=""
@@ -131,4 +134,4 @@ function ReturnClient() {
131
134
  </>
132
135
  );
133
136
  }
134
- export default ReturnClient;
137
+ export default ReturnClient;