@bjsdistribution/dms-client-return 0.0.91 → 0.0.93
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/dms-client-return.cjs.development.js +93 -97
- 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 +93 -97
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +3 -1
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +65 -86
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.93",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -88,11 +88,13 @@
|
|
|
88
88
|
"@emotion/react": "^11.11.3",
|
|
89
89
|
"@emotion/styled": "^11.11.0",
|
|
90
90
|
"@mui/material": "^5.15.10",
|
|
91
|
+
"@reduxjs/toolkit": "^2.5.0",
|
|
91
92
|
"@tanstack/react-table": "^8.11.8",
|
|
92
93
|
"antd": "^5.18.3",
|
|
93
94
|
"dayjs": "^1.11.11",
|
|
94
95
|
"jotai": "^2.6.3",
|
|
95
96
|
"react-custom-scrollbars-2": "^4.5.0",
|
|
97
|
+
"react-redux": "^9.2.0",
|
|
96
98
|
"react-switch-selector": "^2.2.1"
|
|
97
99
|
}
|
|
98
100
|
}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { Checkbox, useApiHook } from '@bjsdistribution/dms-component-library';
|
|
2
|
-
import { Empty, notification } from 'antd';
|
|
2
|
+
import { Empty, notification, Skeleton } from 'antd';
|
|
3
|
+
import { format } from 'date-fns';
|
|
3
4
|
import { useAtom } from 'jotai';
|
|
4
5
|
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
5
|
-
import
|
|
6
|
+
import DownIcon from '../../../../assets/icons/DownIcon';
|
|
7
|
+
import PrinterIcon from '../../../../assets/icons/PrinterIcon';
|
|
8
|
+
import CaretDownFilledIcon from '../../../../common/CaretDownFilledIcon';
|
|
9
|
+
import SortIcon from '../../../../common/SortIcon';
|
|
10
|
+
import PrintDropDownReturn from '../../../order-view/details-filters/left-side-filters/dropdowns/PrintDropDownReturn';
|
|
11
|
+
import { usefetchAgain, useReturnData } from '../../../order-view/store';
|
|
6
12
|
import {
|
|
7
13
|
useGroupedPayload,
|
|
8
14
|
useLocationData,
|
|
@@ -11,32 +17,24 @@ import {
|
|
|
11
17
|
useSelectAll,
|
|
12
18
|
useSelectedOrders,
|
|
13
19
|
} from '../../../store';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import PrinterIcon from '../../../../assets/icons/PrinterIcon';
|
|
18
|
-
import DownIcon from '../../../../assets/icons/DownIcon';
|
|
20
|
+
import { ApiResponse } from '../../../types';
|
|
21
|
+
import { filtersReducerAtom } from '../../header-filters/filterStore';
|
|
22
|
+
import { displayValueOrNA } from '../../shared/utlis';
|
|
19
23
|
import {
|
|
20
24
|
useLoading,
|
|
21
25
|
UsePaginationData,
|
|
22
26
|
usePrintOptionTOggle,
|
|
23
27
|
} from '../../store/store';
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
import PrintDropDownReturn from '../../../order-view/details-filters/left-side-filters/dropdowns/PrintDropDownReturn';
|
|
28
|
-
import { format } from 'date-fns';
|
|
29
|
-
import CaretDownFilledIcon from '../../../../common/CaretDownFilledIcon';
|
|
30
|
-
import SortIcon from '../../../../common/SortIcon';
|
|
28
|
+
import { EmptyDataContainer } from '../../table/table-data/styles';
|
|
29
|
+
import { CustomDrop, StyledTable, StyledTableWrapper } from './returnstyles';
|
|
30
|
+
|
|
31
31
|
const ReturnOrderTable = () => {
|
|
32
32
|
const [state] = useAtom(filtersReducerAtom);
|
|
33
|
-
|
|
34
33
|
const [selectedReturnOrder, setSelectedReturnOrder] = useSelectedOrders();
|
|
35
34
|
const [selectAll, setSelectAll] = useSelectAll();
|
|
36
35
|
const { 'x-filters': filters, 'x-pagination': pagination } = state;
|
|
37
36
|
const [returnData, setReturnData] = useReturnData();
|
|
38
37
|
const [load, setLoading] = useLoading();
|
|
39
|
-
// const [postLoading] = usePostLoading();
|
|
40
38
|
const dropdownRefParent = useRef<HTMLDivElement>(null);
|
|
41
39
|
const dropdownRef = useRef<HTMLDivElement>(null);
|
|
42
40
|
const [printToogle, setPrintToggle] = usePrintOptionTOggle();
|
|
@@ -171,40 +169,32 @@ const ReturnOrderTable = () => {
|
|
|
171
169
|
}, [fetchedOrderData, returnDataLoad, locationData, state, callForFetch]);
|
|
172
170
|
|
|
173
171
|
const handleSelectAll = (e: any) => {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
if (e.target.checked) {
|
|
177
|
-
setSelectedReturnOrder(
|
|
178
|
-
returnData
|
|
179
|
-
?.filter(
|
|
180
|
-
(loc: any) => loc?.order_product_return_action?.type === 'RTS'
|
|
181
|
-
)
|
|
182
|
-
.map((loc: any) => ({
|
|
183
|
-
id: loc.id,
|
|
184
|
-
return_locations: loc?.return_locations,
|
|
185
|
-
return_location: loc?.return_location,
|
|
186
|
-
products: loc?.legacy_product_id,
|
|
187
|
-
order_product_return_action: loc?.order_product_return_action,
|
|
188
|
-
return_location_token: loc?.return_location,
|
|
189
|
-
// new_location: loc?.new_location,
|
|
190
|
-
}))
|
|
191
|
-
);
|
|
172
|
+
const isChecked = e.target.checked;
|
|
173
|
+
setSelectAll(isChecked);
|
|
192
174
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
(loc: any) => loc?.order_product_return_action?.type === 'RTS'
|
|
197
|
-
)
|
|
198
|
-
.map((loc: any) => ({
|
|
199
|
-
id: loc.id,
|
|
200
|
-
account_number: createReturn?.account_number,
|
|
201
|
-
customer_id: +createReturn?.customer_id,
|
|
202
|
-
products: [loc?.legacy_product_id],
|
|
203
|
-
return_action: loc?.order_product_return_action?.type,
|
|
204
|
-
return_location_token: loc?.return_location || null,
|
|
205
|
-
// new_location: loc?.new_location,
|
|
206
|
-
}))
|
|
175
|
+
if (isChecked) {
|
|
176
|
+
const filteredData = returnData?.filter(
|
|
177
|
+
(loc: any) => loc?.order_product_return_action?.type === 'RTS'
|
|
207
178
|
);
|
|
179
|
+
const selectedOrders = filteredData.map((loc: any) => ({
|
|
180
|
+
id: loc.id,
|
|
181
|
+
return_locations: loc?.return_locations,
|
|
182
|
+
return_location: loc?.return_location,
|
|
183
|
+
products: loc?.legacy_product_id,
|
|
184
|
+
order_product_return_action: loc?.order_product_return_action,
|
|
185
|
+
return_location_token: loc?.return_location,
|
|
186
|
+
}));
|
|
187
|
+
const newPayload = filteredData.map((loc: any) => ({
|
|
188
|
+
id: loc.id,
|
|
189
|
+
account_number: createReturn?.account_number,
|
|
190
|
+
customer_id: +createReturn?.customer_id,
|
|
191
|
+
products: [loc?.legacy_product_id],
|
|
192
|
+
return_action: loc?.order_product_return_action?.type,
|
|
193
|
+
return_location_token: loc?.return_location || null,
|
|
194
|
+
}));
|
|
195
|
+
|
|
196
|
+
setSelectedReturnOrder(selectedOrders);
|
|
197
|
+
setNewPayload(newPayload);
|
|
208
198
|
} else {
|
|
209
199
|
setSelectedReturnOrder([]);
|
|
210
200
|
setNewPayload([]);
|
|
@@ -217,7 +207,6 @@ const ReturnOrderTable = () => {
|
|
|
217
207
|
return_location: any,
|
|
218
208
|
return_locations: any,
|
|
219
209
|
order_product_return_action: any,
|
|
220
|
-
// new_location: any,
|
|
221
210
|
legacy_product_id: any
|
|
222
211
|
) => {
|
|
223
212
|
setSelectedReturnOrder((prevSelectedLocations: any) => {
|
|
@@ -242,6 +231,7 @@ const ReturnOrderTable = () => {
|
|
|
242
231
|
prevPayload.filter((item: any) => item.id !== id)
|
|
243
232
|
);
|
|
244
233
|
|
|
234
|
+
setSelectAll(false); // Ensure "select all" is false if one is deselected
|
|
245
235
|
return updatedSelectedLocations;
|
|
246
236
|
} else {
|
|
247
237
|
const newReturnPayload = {
|
|
@@ -249,32 +239,28 @@ const ReturnOrderTable = () => {
|
|
|
249
239
|
account_number: createReturn?.account_number,
|
|
250
240
|
customer_id: +createReturn?.customer_id,
|
|
251
241
|
products: [legacy_product_id],
|
|
252
|
-
return_action: order_product_return_action?.type
|
|
253
|
-
? [order_product_return_action.type]
|
|
254
|
-
: null,
|
|
242
|
+
return_action: order_product_return_action?.type || null,
|
|
255
243
|
return_location_token: return_location || null,
|
|
256
244
|
};
|
|
257
245
|
|
|
258
246
|
setNewPayload((prevPayload: any) => [...prevPayload, newReturnPayload]);
|
|
259
247
|
|
|
260
|
-
|
|
261
|
-
...prevState,
|
|
262
|
-
products: legacy_product_id,
|
|
263
|
-
return_action: order_product_return_action?.type || null,
|
|
264
|
-
return_location_token: return_location || null,
|
|
265
|
-
// new_location: new_location,
|
|
266
|
-
}));
|
|
267
|
-
|
|
268
|
-
return [
|
|
248
|
+
const updatedSelectedLocations = [
|
|
269
249
|
...prevSelectedLocations,
|
|
270
250
|
{
|
|
271
251
|
id,
|
|
272
252
|
return_location,
|
|
273
253
|
return_locations,
|
|
274
254
|
order_product_return_action,
|
|
275
|
-
// new_location,
|
|
276
255
|
},
|
|
277
256
|
];
|
|
257
|
+
setSelectAll(
|
|
258
|
+
updatedSelectedLocations?.length ===
|
|
259
|
+
returnData?.filter(
|
|
260
|
+
(loc: any) => loc?.order_product_return_action?.type === 'RTS'
|
|
261
|
+
)?.length
|
|
262
|
+
);
|
|
263
|
+
return updatedSelectedLocations;
|
|
278
264
|
}
|
|
279
265
|
});
|
|
280
266
|
};
|
|
@@ -397,33 +383,26 @@ const ReturnOrderTable = () => {
|
|
|
397
383
|
sortedData?.map((item: any, index: any) => (
|
|
398
384
|
<tr key={item.id}>
|
|
399
385
|
<td>
|
|
400
|
-
{item?.order_product_return_action?.type
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
}
|
|
418
|
-
/>
|
|
419
|
-
</>
|
|
386
|
+
{item?.order_product_return_action?.type === 'RTS' ? (
|
|
387
|
+
<Checkbox
|
|
388
|
+
className="custom-check"
|
|
389
|
+
checked={selectedReturnOrder.some(
|
|
390
|
+
(selectedInvoice: any) =>
|
|
391
|
+
selectedInvoice?.id === item?.id
|
|
392
|
+
)}
|
|
393
|
+
onChange={() =>
|
|
394
|
+
handleSelectOrderReturn(
|
|
395
|
+
item?.id,
|
|
396
|
+
item?.return_location,
|
|
397
|
+
item?.return_locations,
|
|
398
|
+
item?.order_product_return_action,
|
|
399
|
+
item?.legacy_product_id
|
|
400
|
+
)
|
|
401
|
+
}
|
|
402
|
+
/>
|
|
420
403
|
) : null}
|
|
421
404
|
</td>
|
|
422
405
|
|
|
423
|
-
{/* <>
|
|
424
|
-
<Checkbox disabled onChange={() => {}} checked={false} />
|
|
425
|
-
</> */}
|
|
426
|
-
|
|
427
406
|
<td>
|
|
428
407
|
{item?.orders_products_stock?.location !== null &&
|
|
429
408
|
item?.orders_products_stock?.location !== undefined ? (
|