@bjsdistribution/dms-client-return 0.1.18-dev → 0.1.20-dev
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/client-portal/OutstandingTable.d.ts +3 -0
- package/dist/components/client-portal/ReturnStatus.d.ts +5 -0
- package/dist/components/client-portal/return-confirm/ConfirmedMain.d.ts +3 -0
- package/dist/components/client-portal/return-confirm/ReturnConfirmedTable.d.ts +3 -0
- package/dist/components/store.d.ts +5 -1
- package/dist/dms-client-return.cjs.development.js +1105 -298
- 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 +1106 -299
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/client-portal/OutstandingTable.tsx +412 -0
- package/src/components/client-portal/ReturnAfterSearchBar.tsx +116 -11
- package/src/components/client-portal/ReturnOverview.tsx +4 -4
- package/src/components/client-portal/ReturnRTFilters.tsx +59 -40
- package/src/components/client-portal/ReturnSearchBar.tsx +93 -12
- package/src/components/client-portal/ReturnStatus.tsx +36 -3
- package/src/components/client-portal/return-confirm/ConfirmedMain.tsx +235 -0
- package/src/components/client-portal/return-confirm/ReturnConfirmedTable.tsx +404 -0
- package/src/components/order-daily-overview/return-after-table/ReturnAfterTable.tsx +18 -38
- package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +18 -24
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +35 -146
- package/src/components/store.ts +23 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Checkbox,
|
|
1
|
+
import { Checkbox, useApiHook } from '@bjsdistribution/dms-component-library';
|
|
2
2
|
import { Empty, notification, Skeleton } from 'antd';
|
|
3
3
|
import { format } from 'date-fns';
|
|
4
4
|
import { useAtom } from 'jotai';
|
|
@@ -10,17 +10,12 @@ import SortIcon from '../../../../common/SortIcon';
|
|
|
10
10
|
import PrintDropDownReturn from '../../../order-view/details-filters/left-side-filters/dropdowns/PrintDropDownReturn';
|
|
11
11
|
import { usefetchAgain, useReturnData } from '../../../order-view/store';
|
|
12
12
|
import {
|
|
13
|
-
useClientPortal,
|
|
14
|
-
useEndDate,
|
|
15
13
|
useGroupedPayload,
|
|
16
14
|
useLocationData,
|
|
17
15
|
useNewReturnPayload,
|
|
18
16
|
useReturnPayload,
|
|
19
|
-
useSearchText,
|
|
20
17
|
useSelectAll,
|
|
21
|
-
useSelectedClientPortOrders,
|
|
22
18
|
useSelectedOrders,
|
|
23
|
-
useStartDate,
|
|
24
19
|
} from '../../../store';
|
|
25
20
|
import { ApiResponse } from '../../../types';
|
|
26
21
|
import { filtersReducerAtom } from '../../header-filters/filterStore';
|
|
@@ -32,8 +27,7 @@ import {
|
|
|
32
27
|
} from '../../store/store';
|
|
33
28
|
import { EmptyDataContainer } from '../../table/table-data/styles';
|
|
34
29
|
import { CustomDrop, StyledTable, StyledTableWrapper } from './returnstyles';
|
|
35
|
-
import { NavLink
|
|
36
|
-
import dayjs from 'dayjs';
|
|
30
|
+
import { NavLink } from 'react-router-dom';
|
|
37
31
|
|
|
38
32
|
const ReturnOrderTable = () => {
|
|
39
33
|
const [state] = useAtom(filtersReducerAtom);
|
|
@@ -51,11 +45,6 @@ const ReturnOrderTable = () => {
|
|
|
51
45
|
const [locationData] = useLocationData();
|
|
52
46
|
const [, setPaginationObject] = UsePaginationData();
|
|
53
47
|
const [callForFetch] = usefetchAgain();
|
|
54
|
-
const [clientPortal] = useClientPortal();
|
|
55
|
-
const { status } = useParams();
|
|
56
|
-
const [selectedOrderIds, setSelectedOrderIds] = useSelectedClientPortOrders();
|
|
57
|
-
const [selectClientAll, setSelectClientAll] = useState(false);
|
|
58
|
-
const [modifiedFilters, setModifiedFilters] = useState<any[]>([]);
|
|
59
48
|
|
|
60
49
|
//sorting
|
|
61
50
|
const [sortConfig, setSortConfig] = useState<{
|
|
@@ -122,67 +111,17 @@ const ReturnOrderTable = () => {
|
|
|
122
111
|
}
|
|
123
112
|
};
|
|
124
113
|
|
|
125
|
-
//CP
|
|
126
|
-
const [startDate] = useStartDate();
|
|
127
|
-
const [endDate] = useEndDate();
|
|
128
|
-
|
|
129
|
-
useEffect(() => {
|
|
130
|
-
if (!clientPortal) return;
|
|
131
|
-
|
|
132
|
-
const stored = JSON.parse(localStorage.getItem('returnDate') || '{}');
|
|
133
|
-
|
|
134
|
-
const sDate = startDate?.isValid?.() ? startDate : dayjs(stored?.startDate);
|
|
135
|
-
const eDate = endDate?.isValid?.()
|
|
136
|
-
? endDate
|
|
137
|
-
: stored?.endDate
|
|
138
|
-
? dayjs(stored?.endDate)
|
|
139
|
-
: null;
|
|
140
|
-
|
|
141
|
-
if (!sDate?.isValid?.()) return;
|
|
142
|
-
|
|
143
|
-
let dateFilters = [];
|
|
144
|
-
|
|
145
|
-
if (eDate && eDate.isValid()) {
|
|
146
|
-
dateFilters = [
|
|
147
|
-
{ field: 'created_at', op: '>=', value: sDate.format('YYYY-MM-DD') },
|
|
148
|
-
{
|
|
149
|
-
field: 'created_at',
|
|
150
|
-
op: '<=',
|
|
151
|
-
value: eDate.add(1, 'day').format('YYYY-MM-DD'),
|
|
152
|
-
},
|
|
153
|
-
];
|
|
154
|
-
} else {
|
|
155
|
-
dateFilters = [
|
|
156
|
-
{
|
|
157
|
-
field: 'created_at',
|
|
158
|
-
op: '=',
|
|
159
|
-
value: sDate.format('YYYY-MM-DD'),
|
|
160
|
-
},
|
|
161
|
-
];
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
const updatedFilters =
|
|
165
|
-
status === 'outstanding_return'
|
|
166
|
-
? [
|
|
167
|
-
{ field: 'isdeleted', op: '=', value: 0 },
|
|
168
|
-
{ field: 'product_return_action_id', op: '=', value: 'RTS' },
|
|
169
|
-
...dateFilters,
|
|
170
|
-
]
|
|
171
|
-
: dateFilters;
|
|
172
|
-
|
|
173
|
-
setModifiedFilters(updatedFilters);
|
|
174
|
-
}, [startDate, endDate, status]);
|
|
175
|
-
|
|
176
114
|
const {
|
|
177
115
|
data: fetchedOrderData,
|
|
178
116
|
loading: returnDataLoad,
|
|
179
117
|
paginationData,
|
|
180
|
-
|
|
181
|
-
} =
|
|
118
|
+
setShouldPerformAction,
|
|
119
|
+
} = useApiHook<ApiResponse>({
|
|
182
120
|
endpoint: '/v1/return/product/pending/',
|
|
183
121
|
method: 'GET',
|
|
184
|
-
filters:
|
|
122
|
+
filters: filters,
|
|
185
123
|
pagination: pagination,
|
|
124
|
+
performAction: false,
|
|
186
125
|
});
|
|
187
126
|
|
|
188
127
|
useEffect(() => {
|
|
@@ -209,21 +148,9 @@ const ReturnOrderTable = () => {
|
|
|
209
148
|
}
|
|
210
149
|
}, [fetchedOrderData, returnDataLoad]);
|
|
211
150
|
|
|
212
|
-
useEffect(() => {
|
|
213
|
-
if (!clientPortal) {
|
|
214
|
-
fetchData();
|
|
215
|
-
}
|
|
216
|
-
}, []);
|
|
217
|
-
const [debouncedSearchText] = useSearchText();
|
|
218
|
-
|
|
219
|
-
useEffect(() => {
|
|
220
|
-
if (clientPortal && debouncedSearchText == '') {
|
|
221
|
-
fetchData();
|
|
222
|
-
}
|
|
223
|
-
}, [debouncedSearchText]);
|
|
224
|
-
|
|
225
151
|
useEffect(() => {
|
|
226
152
|
setLoading(returnDataLoad);
|
|
153
|
+
setShouldPerformAction(true);
|
|
227
154
|
if (fetchedOrderData && fetchedOrderData?.data && locationData) {
|
|
228
155
|
const updatedReturnData = fetchedOrderData.data.map(returnItem => {
|
|
229
156
|
const matchingLocation = locationData.find(
|
|
@@ -250,7 +177,7 @@ const ReturnOrderTable = () => {
|
|
|
250
177
|
const filteredData = returnData?.filter(
|
|
251
178
|
(loc: any) => loc?.product_return_action === 'RTS'
|
|
252
179
|
);
|
|
253
|
-
const selectedOrders = filteredData
|
|
180
|
+
const selectedOrders = filteredData.map((loc: any) => ({
|
|
254
181
|
id: loc.id,
|
|
255
182
|
return_locations: loc?.return_location_name,
|
|
256
183
|
return_location: loc?.return_location,
|
|
@@ -373,24 +300,6 @@ const ReturnOrderTable = () => {
|
|
|
373
300
|
setGrouped(mergedPayload);
|
|
374
301
|
}, [newpayload]);
|
|
375
302
|
|
|
376
|
-
//Client Portal
|
|
377
|
-
const handleSelectOrderId = (id: string | number) => {
|
|
378
|
-
setSelectedOrderIds(prev =>
|
|
379
|
-
prev.includes(id) ? prev.filter(orderId => orderId !== id) : [...prev, id]
|
|
380
|
-
);
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
const handleClientSelectAll = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
384
|
-
const isChecked = e.target.checked;
|
|
385
|
-
setSelectClientAll(isChecked);
|
|
386
|
-
|
|
387
|
-
if (isChecked) {
|
|
388
|
-
setSelectedOrderIds(returnData?.map((item: any) => item?.order_id) || []);
|
|
389
|
-
} else {
|
|
390
|
-
setSelectedOrderIds([]);
|
|
391
|
-
}
|
|
392
|
-
};
|
|
393
|
-
|
|
394
303
|
return (
|
|
395
304
|
<>
|
|
396
305
|
<StyledTableWrapper className="fortables">
|
|
@@ -406,23 +315,14 @@ const ReturnOrderTable = () => {
|
|
|
406
315
|
<th className="emailInvoiceCheckbox">
|
|
407
316
|
<Checkbox checked={selectAll} onChange={handleSelectAll} />
|
|
408
317
|
</th>
|
|
409
|
-
) : clientPortal ? (
|
|
410
|
-
<th className="emailInvoiceCheckbox">
|
|
411
|
-
<Checkbox
|
|
412
|
-
checked={selectClientAll}
|
|
413
|
-
onChange={handleClientSelectAll}
|
|
414
|
-
/>
|
|
415
|
-
</th>
|
|
416
318
|
) : (
|
|
417
319
|
<th></th>
|
|
418
320
|
)}
|
|
419
|
-
{
|
|
420
|
-
<
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
</th>
|
|
425
|
-
)}
|
|
321
|
+
<th onClick={() => handleSort('location')}>
|
|
322
|
+
<div className="sortIconClass">
|
|
323
|
+
Product Location {renderSortIcon('location')}
|
|
324
|
+
</div>
|
|
325
|
+
</th>
|
|
426
326
|
<th onClick={() => handleSort('return_location_name')}>
|
|
427
327
|
<div className="sortIconClass">
|
|
428
328
|
Return Location {renderSortIcon('return_location_name')}
|
|
@@ -476,44 +376,33 @@ const ReturnOrderTable = () => {
|
|
|
476
376
|
sortedData?.map((item: any, index: any) => (
|
|
477
377
|
<tr key={item.id}>
|
|
478
378
|
<td>
|
|
479
|
-
{
|
|
379
|
+
{item?.product_return_action === 'RTS' ? (
|
|
480
380
|
<Checkbox
|
|
481
|
-
|
|
482
|
-
|
|
381
|
+
className="custom-check"
|
|
382
|
+
checked={selectedReturnOrder.some(
|
|
383
|
+
(selectedInvoice: any) =>
|
|
384
|
+
selectedInvoice?.id === item?.id
|
|
385
|
+
)}
|
|
386
|
+
onChange={() =>
|
|
387
|
+
handleSelectOrderReturn(
|
|
388
|
+
item?.id,
|
|
389
|
+
item?.return_location,
|
|
390
|
+
item?.return_location_name,
|
|
391
|
+
item?.product_return_action,
|
|
392
|
+
item?.legacy_product_id
|
|
393
|
+
)
|
|
394
|
+
}
|
|
483
395
|
/>
|
|
396
|
+
) : null}
|
|
397
|
+
</td>
|
|
398
|
+
|
|
399
|
+
<td>
|
|
400
|
+
{item?.location !== null && item?.location !== undefined ? (
|
|
401
|
+
item?.location
|
|
484
402
|
) : (
|
|
485
|
-
|
|
486
|
-
{item?.product_return_action === 'RTS' ? (
|
|
487
|
-
<Checkbox
|
|
488
|
-
className="custom-check"
|
|
489
|
-
checked={selectedReturnOrder?.some(
|
|
490
|
-
(selectedInvoice: any) =>
|
|
491
|
-
selectedInvoice?.id === item?.id
|
|
492
|
-
)}
|
|
493
|
-
onChange={() =>
|
|
494
|
-
handleSelectOrderReturn(
|
|
495
|
-
item?.id,
|
|
496
|
-
item?.return_location,
|
|
497
|
-
item?.return_location_name,
|
|
498
|
-
item?.product_return_action,
|
|
499
|
-
item?.legacy_product_id
|
|
500
|
-
)
|
|
501
|
-
}
|
|
502
|
-
/>
|
|
503
|
-
) : null}
|
|
504
|
-
</>
|
|
403
|
+
<div className="awaiting">Awaiting</div>
|
|
505
404
|
)}
|
|
506
405
|
</td>
|
|
507
|
-
{!clientPortal && (
|
|
508
|
-
<td>
|
|
509
|
-
{item?.location !== null &&
|
|
510
|
-
item?.location !== undefined ? (
|
|
511
|
-
item?.location
|
|
512
|
-
) : (
|
|
513
|
-
<div className="awaiting">Awaiting</div>
|
|
514
|
-
)}
|
|
515
|
-
</td>
|
|
516
|
-
)}
|
|
517
406
|
<td> {displayValueOrNA(item?.return_location_name)}</td>
|
|
518
407
|
<td>
|
|
519
408
|
<ul style={{ listStyleType: 'none', padding: 0 }}>
|
package/src/components/store.ts
CHANGED
|
@@ -125,6 +125,12 @@ function useSelectedClientPortOrders() {
|
|
|
125
125
|
return useAtom(selectedCPOrderlList);
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
const selectedCPOrderAfterlList = atom<any[]>([]);
|
|
129
|
+
|
|
130
|
+
function useSelectedClientAfterOrders() {
|
|
131
|
+
return useAtom(selectedCPOrderAfterlList);
|
|
132
|
+
}
|
|
133
|
+
|
|
128
134
|
//start date and end date
|
|
129
135
|
const startCPDate = atom<dayjs.Dayjs | null>(dayjs());
|
|
130
136
|
|
|
@@ -156,6 +162,22 @@ export const useSearchAfterText = () => {
|
|
|
156
162
|
return useAtom(searchAfter);
|
|
157
163
|
};
|
|
158
164
|
|
|
165
|
+
const rclientReturnDataAtom = atom<any[]>([]);
|
|
166
|
+
export function useClientOutstandingReturnData() {
|
|
167
|
+
return useAtom(rclientReturnDataAtom);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const returnConfirmedOrderAtom = atom<any[]>([]);
|
|
171
|
+
|
|
172
|
+
export function useReturnConfirmedOrderData() {
|
|
173
|
+
return useAtom(returnConfirmedOrderAtom);
|
|
174
|
+
}
|
|
175
|
+
const statsCPCount = atom<any>(null);
|
|
176
|
+
|
|
177
|
+
export function useStatsCPCount() {
|
|
178
|
+
return useAtom(statsCPCount);
|
|
179
|
+
}
|
|
180
|
+
|
|
159
181
|
function useCustomerData() {
|
|
160
182
|
return useAtom(customerData);
|
|
161
183
|
}
|
|
@@ -283,4 +305,5 @@ export {
|
|
|
283
305
|
useSelectedClientPortOrders,
|
|
284
306
|
useStartDate,
|
|
285
307
|
useEndDate,
|
|
308
|
+
useSelectedClientAfterOrders,
|
|
286
309
|
};
|