@bjsdistribution/dms-client-return 0.0.57 → 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.
- package/dist/OrderViewQueryHandler.d.ts +3 -0
- package/dist/components/order-view/store.d.ts +2 -3
- package/dist/dms-client-return.cjs.development.js +10021 -10017
- package/dist/dms-client-return.cjs.development.js.map +1 -1
- package/dist/dms-client-return.cjs.production.min.js +1 -1
- package/dist/dms-client-return.cjs.production.min.js.map +1 -1
- package/dist/dms-client-return.esm.js +10033 -10029
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/OrderViewQueryHandler.tsx +14 -0
- package/src/components/order-view/notes/AddNote.tsx +11 -17
- package/src/components/order-view/notes/index.tsx +24 -15
- package/src/components/order-view/order-actions/actions/confirm-order/tables/NotesTable.tsx +1 -1
- package/src/components/order-view/store.ts +15 -15
- package/src/index.tsx +4 -3
package/package.json
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSearchParams } from 'react-router-dom';
|
|
3
|
+
import OrderView from './components/order-view';
|
|
4
|
+
import ReturnMainTable from './components/order-daily-overview';
|
|
5
|
+
|
|
6
|
+
const OrderViewQueryHandler = () => {
|
|
7
|
+
const [searchParams] = useSearchParams(); // Access the query params
|
|
8
|
+
const orderId = searchParams.get('order'); // Get the 'order' param
|
|
9
|
+
|
|
10
|
+
// If 'order' query param is present, render OrderViewWrapper, otherwise redirect to home
|
|
11
|
+
return orderId ? <OrderView /> : <ReturnMainTable />;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default OrderViewQueryHandler;
|
|
@@ -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 {
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
setNotificationData({
|
|
69
|
-
type: 'success',
|
|
67
|
+
if (response.ok) {
|
|
68
|
+
notification.success({
|
|
70
69
|
message: 'Success',
|
|
71
|
-
description:
|
|
70
|
+
description: 'Note saved successfully.',
|
|
72
71
|
});
|
|
73
|
-
setNoteLoadingStore(!NoteLoadingStore);
|
|
74
72
|
setNoteText('');
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
type: 'error',
|
|
73
|
+
setRecallAuditLog(true);
|
|
74
|
+
} else {
|
|
75
|
+
notification.error({
|
|
79
76
|
message: 'Error',
|
|
80
|
-
description:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
64
|
+
}&module_object_id=${orderId}`,
|
|
62
65
|
method: 'GET',
|
|
63
66
|
performAction: false,
|
|
64
67
|
});
|
|
65
68
|
|
|
66
69
|
useEffect(() => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (moduleIds) {
|
|
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
|
-
|
|
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
|
-
|
|
85
|
-
}, [moduleIds,
|
|
93
|
+
setAuditLogLoading(NotesLoading)
|
|
94
|
+
}, [moduleIds,orderId,NotesLoading,recallAuditLog]);
|
|
86
95
|
|
|
87
96
|
return (
|
|
88
97
|
<Container>
|
|
@@ -162,8 +162,8 @@ function useIsOnHoldOrder() {
|
|
|
162
162
|
return useAtom(isOnHold);
|
|
163
163
|
}
|
|
164
164
|
//value
|
|
165
|
-
const orderId = atom<any>(
|
|
166
|
-
export const useOrderId = () => {
|
|
165
|
+
const orderId = atom<any>(undefined);
|
|
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
|
|
|
@@ -443,11 +439,6 @@ export function useApiCalling() {
|
|
|
443
439
|
return useAtom(apiCalling);
|
|
444
440
|
}
|
|
445
441
|
|
|
446
|
-
const globalStateHitAuditLog = atom<boolean>(false);
|
|
447
|
-
export function useGlobalStateHitAuditLog() {
|
|
448
|
-
return useAtom(globalStateHitAuditLog);
|
|
449
|
-
}
|
|
450
|
-
|
|
451
442
|
|
|
452
443
|
const liveRecalling = atom<boolean>(false);
|
|
453
444
|
|
|
@@ -463,10 +454,19 @@ export const letselectedProductIdAtom = atom<number | null>(null);
|
|
|
463
454
|
// return useAtom(BulkUPdateDisabledState);
|
|
464
455
|
// };
|
|
465
456
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
457
|
+
|
|
458
|
+
const auditLogLoadingState = atom<boolean>(true);
|
|
459
|
+
export function useAuditLogLoadingState() {
|
|
460
|
+
return useAtom(auditLogLoadingState);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
const globalStateHitAuditLog = atom<boolean>(false);
|
|
465
|
+
export function useGlobalStateHitAuditLog() {
|
|
466
|
+
return useAtom(globalStateHitAuditLog);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
|
|
470
470
|
|
|
471
471
|
// Popup state Manage
|
|
472
472
|
const initialState = null;
|
package/src/index.tsx
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import React, { Suspense, useEffect } from 'react';
|
|
2
2
|
import { Route, Routes, useSearchParams } from 'react-router-dom';
|
|
3
|
-
import OrderView from './components/order-view';
|
|
4
3
|
import ReturnTable from './components/order-daily-overview/return-order-table/ReturnTable';
|
|
5
4
|
import ReturnAfterTable from './components/order-daily-overview/return-after-table/ReturnAfterTable';
|
|
6
5
|
import {
|
|
7
6
|
useSelectedAction,
|
|
8
7
|
useSelectedClient,
|
|
9
8
|
} from './components/order-daily-overview/store/store';
|
|
10
|
-
import ReturnMainTable from './components/order-daily-overview';
|
|
11
9
|
import { notification } from 'antd';
|
|
12
10
|
import RouterHeader from './components/order-daily-overview/header/route-header/RouterHeader';
|
|
13
11
|
import {
|
|
@@ -21,6 +19,8 @@ import {
|
|
|
21
19
|
import { ApiResponse } from './components/types';
|
|
22
20
|
import { useApiHook } from '@bjsdistribution/dms-component-library';
|
|
23
21
|
import { useLocationOptions } from './components/order-view/store';
|
|
22
|
+
import OrderViewQueryHandler from './OrderViewQueryHandler';
|
|
23
|
+
import OrderView from './components/order-view';
|
|
24
24
|
function ReturnClient() {
|
|
25
25
|
notification.config({
|
|
26
26
|
top: 80,
|
|
@@ -111,9 +111,10 @@ function ReturnClient() {
|
|
|
111
111
|
<Routes>
|
|
112
112
|
{/* for local */}
|
|
113
113
|
{/* for dev */}
|
|
114
|
-
<Route path="" element={<
|
|
114
|
+
<Route path="" element={<OrderViewQueryHandler />} />
|
|
115
115
|
<Route path="overview" element={<ReturnAfterTable />} />
|
|
116
116
|
<Route path="/:id" element={<OrderView />} />
|
|
117
|
+
|
|
117
118
|
<Route path="filter" element={<ReturnTable />} />
|
|
118
119
|
{/* <Route
|
|
119
120
|
path=""
|