@bjsdistribution/dms-client-return 0.0.19 → 0.0.21
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/components/order-daily-overview/store/store.d.ts +1 -1
- package/dist/components/order-view/utils.d.ts +2 -0
- package/dist/dms-client-return.cjs.development.js +519 -402
- 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 +520 -403
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/order-daily-overview/header-filters/HeaderFilter.tsx +58 -58
- package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +85 -46
- package/src/components/order-daily-overview/header-filters/Styledfilters.tsx +1 -0
- package/src/components/order-daily-overview/header-filters/filterStore.ts +17 -1
- package/src/components/order-daily-overview/index.tsx +9 -8
- package/src/components/order-daily-overview/return-after-table/ReturnAfterTable.tsx +9 -5
- package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +5 -5
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.ts +1 -0
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx +22 -19
- package/src/components/order-daily-overview/return-after-table/table-filters/TableFilters.tsx +55 -55
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +73 -38
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/RightFilters.tsx +42 -43
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/returnstyles.ts +1 -0
- package/src/components/order-daily-overview/store/store.ts +1 -1
- package/src/components/order-view/index.tsx +6 -6
- package/src/components/order-view/modalsPopup/ModalManager.tsx +69 -31
- package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +21 -2
- package/src/index.tsx +74 -1
|
@@ -25,7 +25,7 @@ import { ApiResponse } from '../types';
|
|
|
25
25
|
import CreateReturnModal from './CreateReturnModal';
|
|
26
26
|
import {
|
|
27
27
|
useFinalPayload,
|
|
28
|
-
|
|
28
|
+
useGroupedPayload,
|
|
29
29
|
useNewReturnPayload,
|
|
30
30
|
usePostLoading,
|
|
31
31
|
useSelectAll,
|
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
useSelectedOrders,
|
|
34
34
|
} from '../../store';
|
|
35
35
|
import { notification } from 'antd';
|
|
36
|
+
import { useNavigate } from 'react-router-dom';
|
|
36
37
|
|
|
37
38
|
const ModalManager = () => {
|
|
38
39
|
const [popupName, dispatch] = useAtom(countReducerAtom);
|
|
@@ -50,9 +51,10 @@ const ModalManager = () => {
|
|
|
50
51
|
const [, setSelectedReturnOrder] = useSelectedOrders();
|
|
51
52
|
const [forDisabledCheck, setCheck] = useSelectedConfirmLoc();
|
|
52
53
|
const [, setNewPayload] = useNewReturnPayload();
|
|
53
|
-
|
|
54
|
+
const [, setGrouped] = useGroupedPayload();
|
|
54
55
|
const [, setSelectAll] = useSelectAll();
|
|
55
56
|
const [, setCallForFetch] = usefetchAgain();
|
|
57
|
+
const navigate = useNavigate();
|
|
56
58
|
|
|
57
59
|
console.log(orderProduct, 'abcabcabcabcabcabcabcabcabcabcabc');
|
|
58
60
|
|
|
@@ -134,7 +136,7 @@ const ModalManager = () => {
|
|
|
134
136
|
data: response,
|
|
135
137
|
setShouldPerformAction,
|
|
136
138
|
loading: confirmLoading,
|
|
137
|
-
error,
|
|
139
|
+
error: apiError,
|
|
138
140
|
setError,
|
|
139
141
|
} = useApiHook<{
|
|
140
142
|
data: ApiResponse[];
|
|
@@ -150,42 +152,78 @@ const ModalManager = () => {
|
|
|
150
152
|
}, [confirmLoading]);
|
|
151
153
|
|
|
152
154
|
const handleConfirmReturn = () => {
|
|
153
|
-
|
|
154
|
-
if (newGrouped.length > 0) {
|
|
155
|
+
if (newGrouped?.length > 0) {
|
|
155
156
|
setShouldPerformAction(true);
|
|
156
157
|
setCallForFetch(true);
|
|
157
158
|
}
|
|
158
159
|
dispatch({ type: 'close' });
|
|
159
160
|
};
|
|
160
161
|
|
|
161
|
-
useEffect(() => {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
162
|
+
// useEffect(() => {
|
|
163
|
+
// console.log(error, 'error');
|
|
164
|
+
// //@ts-ignore
|
|
165
|
+
// if (!confirmLoading) {
|
|
166
|
+
// // if (error && error.errorStatus !== 200) {
|
|
167
|
+
// // console.log(error, 'errorINsodeofIFFFFFF');
|
|
168
|
+
// // notification.error({
|
|
169
|
+
// // message: error.errorStatus || 'Error',
|
|
170
|
+
// // description: error.errorMessage || 'Something went wrong',
|
|
171
|
+
// // });
|
|
172
|
+
// // setError(null);
|
|
173
|
+
// // }
|
|
174
|
+
|
|
175
|
+
// //@ts-ignore
|
|
176
|
+
// if (error === null && response && response?.code === 200) {
|
|
177
|
+
// notification.success({
|
|
178
|
+
// message: 'Success',
|
|
179
|
+
// // @ts-ignore
|
|
180
|
+
// description: `${response?.message}`,
|
|
181
|
+
// });
|
|
182
|
+
// dispatch({ type: 'close' });
|
|
183
|
+
// setSelectedReturnOrder([]);
|
|
184
|
+
// setCheck([]);
|
|
185
|
+
// setNewPayload([]);
|
|
186
|
+
// setSelectAll(false);
|
|
187
|
+
// }
|
|
188
|
+
// }
|
|
189
|
+
// }, [confirmLoading]); //forCheck
|
|
173
190
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
191
|
+
useEffect(() => {
|
|
192
|
+
// @ts-ignore
|
|
193
|
+
if (apiError && apiError?.code !== 200) {
|
|
194
|
+
dispatch({ type: 'close' });
|
|
195
|
+
setSelectedReturnOrder([]);
|
|
196
|
+
setCheck([]);
|
|
197
|
+
setNewPayload([]);
|
|
198
|
+
setGrouped([]);
|
|
199
|
+
setSelectAll(false);
|
|
200
|
+
setShouldPerformAction(false);
|
|
201
|
+
notification.error({
|
|
202
|
+
message: 'Failure',
|
|
203
|
+
// @ts-ignore
|
|
204
|
+
description: `${apiError?.message}`,
|
|
205
|
+
});
|
|
206
|
+
setError(null);
|
|
207
|
+
// @ts-ignore
|
|
208
|
+
} else if (response?.code === 200) {
|
|
209
|
+
notification.success({
|
|
210
|
+
message: 'Success',
|
|
211
|
+
// @ts-ignore
|
|
212
|
+
description: `${response?.message}`,
|
|
213
|
+
});
|
|
214
|
+
dispatch({ type: 'close' });
|
|
215
|
+
setSelectedReturnOrder([]);
|
|
216
|
+
setCheck([]);
|
|
217
|
+
setNewPayload([]);
|
|
218
|
+
setShouldPerformAction(false);
|
|
219
|
+
setSelectAll(false);
|
|
220
|
+
setError(null);
|
|
221
|
+
navigate('/order-return');
|
|
187
222
|
}
|
|
188
|
-
}, [
|
|
223
|
+
}, [response, apiError]);
|
|
224
|
+
|
|
225
|
+
console.log(apiError, 'apiError apiError');
|
|
226
|
+
console.log(response, 'response response ');
|
|
189
227
|
|
|
190
228
|
return (
|
|
191
229
|
<>
|
package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
import { Checkbox, useApiHook } from '@bjsdistribution/dms-component-library';
|
|
7
7
|
import ActionIcon from '../../../../assets/icons/ActionIcon';
|
|
8
8
|
import { useSelectedOrders } from '../../../store';
|
|
9
|
-
import { useOrderId, useProductDetails } from '../../store';
|
|
9
|
+
import { useOrderId, useOrderStaticData, useProductDetails } from '../../store';
|
|
10
10
|
import { ApiResponse } from '../../types';
|
|
11
11
|
|
|
12
12
|
const ReturnProductTable = () => {
|
|
@@ -52,6 +52,23 @@ const ReturnProductTable = () => {
|
|
|
52
52
|
setSelectAll(prevSelectAll => !prevSelectAll);
|
|
53
53
|
}, []);
|
|
54
54
|
|
|
55
|
+
// const returnreason =
|
|
56
|
+
const [orderStaticData] = useOrderStaticData();
|
|
57
|
+
|
|
58
|
+
const returnReasonsOptions = orderStaticData?.return_reasons?.map(
|
|
59
|
+
(option: any) => ({
|
|
60
|
+
label: option.reason,
|
|
61
|
+
value: option.id,
|
|
62
|
+
})
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const getReturnReasonLabel = (returnReasonId: number) => {
|
|
66
|
+
const matchedReason = returnReasonsOptions?.find(
|
|
67
|
+
(option: any) => option.value === returnReasonId
|
|
68
|
+
);
|
|
69
|
+
return matchedReason ? matchedReason.label : 'N/A'; // Return label or 'N/A' if no match found
|
|
70
|
+
};
|
|
71
|
+
|
|
55
72
|
return (
|
|
56
73
|
<div>
|
|
57
74
|
<StyledTableWrapper id="tableScrolling">
|
|
@@ -85,7 +102,9 @@ const ReturnProductTable = () => {
|
|
|
85
102
|
<td>{'N/A'}</td>
|
|
86
103
|
<td>{invoice.code}</td>
|
|
87
104
|
<td>{invoice.description}</td>
|
|
88
|
-
<td>
|
|
105
|
+
<td>
|
|
106
|
+
{getReturnReasonLabel(invoice?.return_reason_id)}
|
|
107
|
+
</td>{' '}
|
|
89
108
|
<td>1 of 1</td>
|
|
90
109
|
<td>
|
|
91
110
|
<div
|
package/src/index.tsx
CHANGED
|
@@ -10,6 +10,17 @@ import { useTableName } from './components/order-daily-overview/store/store';
|
|
|
10
10
|
import ReturnMainTable from './components/order-daily-overview';
|
|
11
11
|
import { notification } from 'antd';
|
|
12
12
|
import RouterHeader from './components/order-daily-overview/header/route-header/RouterHeader';
|
|
13
|
+
import {
|
|
14
|
+
useActionType,
|
|
15
|
+
// useAtom,
|
|
16
|
+
// useAtom,
|
|
17
|
+
useCustomerData,
|
|
18
|
+
useLocationData,
|
|
19
|
+
useStatusOrderData,
|
|
20
|
+
} from './components/store';
|
|
21
|
+
import { ApiResponse } from './components/types';
|
|
22
|
+
import { useApiHook } from '@bjsdistribution/dms-component-library';
|
|
23
|
+
// import { filtersReducerAtom } from './components/order-daily-overview/header-filters/filterStore';
|
|
13
24
|
|
|
14
25
|
function ReturnClient() {
|
|
15
26
|
notification.config({
|
|
@@ -20,14 +31,22 @@ function ReturnClient() {
|
|
|
20
31
|
const navigate = useNavigate();
|
|
21
32
|
let selectedClientString = selectedClient?.replace(/\s+/g, '-');
|
|
22
33
|
selectedClientString = selectedClientString?.toLowerCase();
|
|
34
|
+
const [, setCustomers] = useCustomerData();
|
|
35
|
+
const [, setActionType] = useActionType();
|
|
36
|
+
const [, setLocationData] = useLocationData();
|
|
37
|
+
const [, setStatusOfOrders] = useStatusOrderData();
|
|
38
|
+
// const [, dispatch] = useAtom(filtersReducerAtom);
|
|
23
39
|
|
|
24
40
|
console.log(selectedClientString, 'selectedClient');
|
|
25
41
|
console.log(`../filter/:${selectedClientString}`);
|
|
26
42
|
|
|
27
43
|
useEffect(() => {
|
|
28
|
-
if (
|
|
44
|
+
if (location.pathname.includes('/returnClient')) {
|
|
29
45
|
localStorage.removeItem('clientName');
|
|
30
46
|
localStorage.removeItem('clientId');
|
|
47
|
+
localStorage.removeItem('uuid');
|
|
48
|
+
localStorage.removeItem('customer_id');
|
|
49
|
+
// dispatch({ type: 'CLEAR_CLIENT', payload: [] });
|
|
31
50
|
}
|
|
32
51
|
}, [location.pathname]);
|
|
33
52
|
|
|
@@ -38,6 +57,60 @@ function ReturnClient() {
|
|
|
38
57
|
}
|
|
39
58
|
}, [selectedClient]);
|
|
40
59
|
|
|
60
|
+
//API for client data
|
|
61
|
+
const { data: fetchedCustomerData, loading: loading } = useApiHook<
|
|
62
|
+
ApiResponse
|
|
63
|
+
>({
|
|
64
|
+
endpoint: `/customers/`,
|
|
65
|
+
method: 'GET',
|
|
66
|
+
//@ts-ignore
|
|
67
|
+
pagination: { is_pagination: false },
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
//API for action type
|
|
71
|
+
const { data: fetchedStaticData, loading: actionLoading } = useApiHook<
|
|
72
|
+
ApiResponse
|
|
73
|
+
>({
|
|
74
|
+
endpoint: `/orders/getStaticData/all/`,
|
|
75
|
+
method: 'GET',
|
|
76
|
+
// pagination: { page: 1, per_page: 50 },
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
//API for return locations
|
|
80
|
+
const { data: fetchedLocationData, loading: locationloading } = useApiHook<
|
|
81
|
+
ApiResponse
|
|
82
|
+
>({
|
|
83
|
+
endpoint: `/return_locations/`,
|
|
84
|
+
method: 'GET',
|
|
85
|
+
//@ts-ignore
|
|
86
|
+
pagination: { is_pagination: false },
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (fetchedCustomerData && fetchedCustomerData?.data) {
|
|
91
|
+
setCustomers(fetchedCustomerData?.data);
|
|
92
|
+
}
|
|
93
|
+
}, [loading]);
|
|
94
|
+
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (fetchedStaticData && fetchedStaticData?.data) {
|
|
97
|
+
setActionType(
|
|
98
|
+
fetchedStaticData?.data?.flatMap(
|
|
99
|
+
(i: any) => i?.order_product_return_action
|
|
100
|
+
)
|
|
101
|
+
);
|
|
102
|
+
setStatusOfOrders(
|
|
103
|
+
fetchedStaticData?.data?.flatMap((i: any) => i?.order_stock_alias)
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
}, [actionLoading]);
|
|
107
|
+
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
if (fetchedLocationData && fetchedLocationData?.data) {
|
|
110
|
+
setLocationData(fetchedLocationData?.data);
|
|
111
|
+
}
|
|
112
|
+
}, [locationloading]);
|
|
113
|
+
|
|
41
114
|
return (
|
|
42
115
|
<>
|
|
43
116
|
<RouterHeader />
|