@bjsdistribution/dms-client-return 0.0.33 → 0.0.34
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 +3 -0
- package/dist/components/order-view/notes/order-dropdown/NewReturnDropdown.d.ts +3 -0
- package/dist/components/store.d.ts +12 -2
- package/dist/components/types.d.ts +4 -0
- package/dist/dms-client-return.cjs.development.js +619 -345
- 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 +623 -349
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +118 -139
- package/src/components/order-daily-overview/header-filters/filterStore.ts +4 -4
- package/src/components/order-daily-overview/index.tsx +29 -25
- package/src/components/order-daily-overview/return-after-table/ReturnAfterTable.tsx +14 -10
- package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +88 -32
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.ts +18 -2
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx +18 -7
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnFilter.tsx +2 -3
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +6 -4
- package/src/components/order-daily-overview/store/store.ts +15 -0
- package/src/components/order-daily-overview/table/ReturnTable.tsx +16 -11
- package/src/components/order-daily-overview/table/table-data/styles.ts +1 -1
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/OptionsDropDown.tsx +3 -3
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/PrintDropDownReturn.tsx +1 -1
- package/src/components/order-view/general-information/dropdowns/Print.tsx +1 -1
- package/src/components/order-view/modalsPopup/ModalManager.tsx +3 -9
- package/src/components/order-view/notes/order-dropdown/NewReturnDropdown.tsx +88 -13
- package/src/components/order-view/products-info/expanded-content/index.tsx +91 -16
- package/src/components/order-view/products-info/index.tsx +1 -1
- package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +47 -42
- package/src/components/store.ts +51 -1
- package/src/components/types.ts +5 -0
- package/src/index.tsx +25 -16
package/package.json
CHANGED
|
@@ -10,158 +10,141 @@ import {
|
|
|
10
10
|
} from './Styledfilters';
|
|
11
11
|
import { atom, useAtom } from 'jotai';
|
|
12
12
|
import {
|
|
13
|
-
|
|
13
|
+
useActionTypeOptions,
|
|
14
14
|
useClearState,
|
|
15
15
|
useCustomerData,
|
|
16
|
-
useGroupedPayload,
|
|
17
|
-
useLocationData,
|
|
18
|
-
useNewReturnPayload,
|
|
19
16
|
useReturnPayload,
|
|
20
|
-
useSelectAll,
|
|
21
|
-
useSelectedConfirmLoc,
|
|
22
|
-
useSelectedOrders,
|
|
23
17
|
} from '../../store';
|
|
24
18
|
import { filtersReducerAtom } from './filterStore';
|
|
25
19
|
import {
|
|
26
20
|
useSelectedAction,
|
|
27
21
|
useSelectedClient,
|
|
28
22
|
useSelectedLocation,
|
|
23
|
+
useIdForTableName,
|
|
24
|
+
useLoading,
|
|
29
25
|
useTableName,
|
|
30
26
|
} from '../store/store';
|
|
31
27
|
import styled from 'styled-components';
|
|
32
28
|
import { Select } from 'antd';
|
|
33
|
-
import {
|
|
29
|
+
import { useLocationOptions } from '../../order-view/store';
|
|
34
30
|
|
|
35
31
|
export const clickedState = atom<boolean>(false);
|
|
36
32
|
|
|
37
33
|
function SelectionFilter() {
|
|
38
34
|
const [customers] = useCustomerData();
|
|
39
|
-
const [actionType] = useActionType();
|
|
40
|
-
const [locationData] = useLocationData();
|
|
41
|
-
const [filteredLocationOptions, setFilteredLocationOptions] = useState([]);
|
|
42
|
-
const [, setUuid] = useState<any>();
|
|
43
35
|
const [selectedFilterValue, setSelectedFilterValue] = useSelectedAction();
|
|
44
36
|
const [, dispatch] = useAtom(filtersReducerAtom);
|
|
45
37
|
const [
|
|
46
38
|
selectedLocationValue,
|
|
47
39
|
setSelectedLocationValue,
|
|
48
40
|
] = useSelectedLocation();
|
|
49
|
-
const [, setSelectedClient] = useSelectedClient();
|
|
50
|
-
const [,
|
|
51
|
-
const [, setName] = useState<any>();
|
|
41
|
+
const [selectedClient, setSelectedClient] = useSelectedClient();
|
|
42
|
+
const [, setClientIdForTable] = useIdForTableName();
|
|
52
43
|
const [isButtonEnabled, setIsButtonEnabled] = useState(false);
|
|
53
44
|
const [, setReturnPayload] = useReturnPayload();
|
|
54
|
-
const [
|
|
55
|
-
const [
|
|
56
|
-
const [, setNewPayload] = useNewReturnPayload();
|
|
57
|
-
const [, setGrouped] = useGroupedPayload();
|
|
58
|
-
const [, setSelectedReturnOrder] = useSelectedOrders();
|
|
59
|
-
const [, setSelectAll] = useSelectAll();
|
|
60
|
-
const [, setCheck] = useSelectedConfirmLoc();
|
|
45
|
+
const [load] = useLoading();
|
|
46
|
+
const [, setTableName] = useTableName();
|
|
61
47
|
const [clearState, setClear] = useClearState();
|
|
48
|
+
const [actionTypeOptions, setActionTypeOptions] = useActionTypeOptions();
|
|
49
|
+
const [locationOptions, setLocationOptions] = useLocationOptions();
|
|
62
50
|
|
|
63
|
-
//client options
|
|
64
51
|
const clientOptions = customers?.map((option: any) => ({
|
|
65
52
|
label:
|
|
66
53
|
option?.customer_name?.charAt(0)?.toUpperCase() +
|
|
67
54
|
option?.customer_name?.slice(1),
|
|
68
|
-
value:
|
|
69
|
-
|
|
70
|
-
|
|
55
|
+
value: option?.customer_id,
|
|
56
|
+
actions: option?.actions,
|
|
57
|
+
return_locations: option?.return_locations,
|
|
71
58
|
account_number: option?.account_number,
|
|
72
|
-
gsit_customer_id: option?.gsit_customer_id,
|
|
73
59
|
}));
|
|
74
60
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
value
|
|
78
|
-
|
|
61
|
+
//client change
|
|
62
|
+
const handleClientChange = (value: any, option: any) => {
|
|
63
|
+
// console.log(value, 'value');
|
|
64
|
+
setSelectedClient(value);
|
|
79
65
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}));
|
|
66
|
+
localStorage.setItem('clientName', option?.label);
|
|
67
|
+
localStorage.setItem('clientId', value?.toString());
|
|
68
|
+
localStorage.setItem('account_number', option?.account_number);
|
|
84
69
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
localStorage.setItem('account_number', selectAccountNumber);
|
|
100
|
-
localStorage.setItem('uuid', selectedUuids);
|
|
101
|
-
localStorage.setItem('customer_id', selectedCustomerId?.toString());
|
|
102
|
-
const storedAccNo = localStorage.getItem('account_number');
|
|
103
|
-
const storedCustomerId = localStorage.getItem('customer_id');
|
|
104
|
-
const storedUuid = localStorage.getItem('uuid');
|
|
105
|
-
setUuid(storedUuid);
|
|
70
|
+
const selectedClient = clientOptions?.find(
|
|
71
|
+
(client: any) => client?.value === value
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const clientActions = selectedClient?.actions || [];
|
|
75
|
+
|
|
76
|
+
const clientLocations = selectedClient?.return_locations || [];
|
|
77
|
+
|
|
78
|
+
setActionTypeOptions(
|
|
79
|
+
clientActions?.map((action: any) => ({
|
|
80
|
+
label: action,
|
|
81
|
+
value: action,
|
|
82
|
+
}))
|
|
83
|
+
);
|
|
106
84
|
|
|
85
|
+
setLocationOptions(
|
|
86
|
+
clientLocations?.map((action: any) => ({
|
|
87
|
+
label: action,
|
|
88
|
+
value: action,
|
|
89
|
+
}))
|
|
90
|
+
);
|
|
107
91
|
//set payload
|
|
108
92
|
setReturnPayload((prevState: any) => ({
|
|
109
93
|
...prevState,
|
|
110
|
-
account_number:
|
|
111
|
-
customer_id:
|
|
94
|
+
account_number: option?.account_number,
|
|
95
|
+
customer_id: value,
|
|
112
96
|
}));
|
|
113
|
-
|
|
114
|
-
//filtering locations
|
|
115
|
-
const filteredSubLocations = locationData
|
|
116
|
-
?.filter((subCat: any) => subCat?.customer_id === storedUuid)
|
|
117
|
-
.map((subCat: any) => ({
|
|
118
|
-
label: subCat?.location_name,
|
|
119
|
-
value: subCat?.token,
|
|
120
|
-
}));
|
|
121
|
-
|
|
122
|
-
setFilteredLocationOptions(filteredSubLocations);
|
|
123
|
-
|
|
124
|
-
//clearing states
|
|
125
|
-
setUuid('');
|
|
126
|
-
setSelectedReturnOrder([]);
|
|
127
|
-
setNewPayload([]);
|
|
128
|
-
setGrouped([]);
|
|
129
|
-
setSelectAll(false);
|
|
130
|
-
setCheck([]);
|
|
131
97
|
};
|
|
132
98
|
|
|
99
|
+
const storedName = localStorage.getItem('clientName');
|
|
100
|
+
const storedClientId = localStorage.getItem('clientId');
|
|
101
|
+
const storedAccountNumber = localStorage.getItem('account_number');
|
|
102
|
+
|
|
133
103
|
useEffect(() => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
if (customerIdFromStorage) {
|
|
140
|
-
setStoredCustomerId(customerIdFromStorage);
|
|
104
|
+
if (storedClientId !== selectedClient) {
|
|
105
|
+
localStorage.removeItem('clientDetails');
|
|
106
|
+
localStorage.removeItem('clientActions');
|
|
107
|
+
localStorage.removeItem('clientLocations');
|
|
141
108
|
}
|
|
142
|
-
|
|
109
|
+
}, [storedClientId]);
|
|
110
|
+
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
if (storedClientId && storedAccountNumber) {
|
|
143
113
|
setReturnPayload((prevState: any) => ({
|
|
144
114
|
...prevState,
|
|
145
|
-
account_number:
|
|
146
|
-
customer_id:
|
|
115
|
+
account_number: storedAccountNumber,
|
|
116
|
+
customer_id: storedClientId,
|
|
147
117
|
}));
|
|
148
118
|
}
|
|
149
|
-
}, [
|
|
150
|
-
|
|
151
|
-
const storedUuid = localStorage.getItem('uuid');
|
|
119
|
+
}, [storedClientId, storedAccountNumber]);
|
|
152
120
|
|
|
153
121
|
useEffect(() => {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
122
|
+
const storedClientId = localStorage.getItem('clientId');
|
|
123
|
+
|
|
124
|
+
if (storedClientId && clientOptions?.length > 0) {
|
|
125
|
+
const filteredClient = clientOptions?.find(
|
|
126
|
+
(client: any) => client?.value == storedClientId
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
if (filteredClient) {
|
|
130
|
+
const mappedActions = filteredClient?.actions?.map((action: any) => ({
|
|
131
|
+
label: action,
|
|
132
|
+
value: action,
|
|
160
133
|
}));
|
|
161
134
|
|
|
162
|
-
|
|
135
|
+
setActionTypeOptions(mappedActions);
|
|
136
|
+
|
|
137
|
+
const mappedLocations = filteredClient?.return_locations?.map(
|
|
138
|
+
(location: any) => ({
|
|
139
|
+
label: location,
|
|
140
|
+
value: location,
|
|
141
|
+
})
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
setLocationOptions(mappedLocations);
|
|
145
|
+
}
|
|
163
146
|
}
|
|
164
|
-
}, [
|
|
147
|
+
}, [load]);
|
|
165
148
|
|
|
166
149
|
//location change
|
|
167
150
|
const handleLocationChange = (value: any) => {
|
|
@@ -175,8 +158,11 @@ function SelectionFilter() {
|
|
|
175
158
|
|
|
176
159
|
//Apply filters
|
|
177
160
|
const applyFilters = () => {
|
|
161
|
+
if (selectedClient) {
|
|
162
|
+
setClientIdForTable(selectedClient);
|
|
163
|
+
}
|
|
178
164
|
if (storedName) {
|
|
179
|
-
|
|
165
|
+
setTableName(storedName);
|
|
180
166
|
}
|
|
181
167
|
//client value
|
|
182
168
|
if (storedClientId) {
|
|
@@ -218,8 +204,7 @@ function SelectionFilter() {
|
|
|
218
204
|
}
|
|
219
205
|
};
|
|
220
206
|
|
|
221
|
-
const storedName = localStorage.getItem('clientName');
|
|
222
|
-
const storedClientId = localStorage.getItem('clientId');
|
|
207
|
+
// const storedName = localStorage.getItem('clientName');
|
|
223
208
|
|
|
224
209
|
useEffect(() => {
|
|
225
210
|
if (storedClientId) {
|
|
@@ -231,12 +216,12 @@ function SelectionFilter() {
|
|
|
231
216
|
}, []);
|
|
232
217
|
|
|
233
218
|
useEffect(() => {
|
|
234
|
-
if (
|
|
219
|
+
if (storedClientId || selectedFilterValue || selectedLocationValue) {
|
|
235
220
|
setIsButtonEnabled(true);
|
|
236
221
|
} else {
|
|
237
222
|
setIsButtonEnabled(false);
|
|
238
223
|
}
|
|
239
|
-
}, [
|
|
224
|
+
}, [storedClientId, selectedFilterValue, selectedLocationValue]);
|
|
240
225
|
|
|
241
226
|
useEffect(() => {}, [location.pathname]);
|
|
242
227
|
|
|
@@ -255,16 +240,14 @@ function SelectionFilter() {
|
|
|
255
240
|
|
|
256
241
|
const handleClear = () => {
|
|
257
242
|
setClear(false);
|
|
258
|
-
localStorage.removeItem('
|
|
259
|
-
localStorage.removeItem('clientId');
|
|
243
|
+
localStorage.removeItem('clientDetails');
|
|
260
244
|
setClear(true);
|
|
261
245
|
};
|
|
262
246
|
|
|
263
247
|
useEffect(() => {
|
|
264
248
|
if (clearState) {
|
|
265
249
|
dispatch({ type: 'CLEAR_CLIENT' });
|
|
266
|
-
|
|
267
|
-
window.location.replace('/returnclient');
|
|
250
|
+
window.location.href = '/returnclient';
|
|
268
251
|
}
|
|
269
252
|
}, [clearState]);
|
|
270
253
|
|
|
@@ -277,7 +260,7 @@ function SelectionFilter() {
|
|
|
277
260
|
<StyledAntSelect
|
|
278
261
|
options={clientOptions}
|
|
279
262
|
placeholder="Select Client Name"
|
|
280
|
-
onChange={
|
|
263
|
+
onChange={handleClientChange}
|
|
281
264
|
style={{ minWidth: '14vw' }}
|
|
282
265
|
value={storedName}
|
|
283
266
|
allowClear
|
|
@@ -285,38 +268,34 @@ function SelectionFilter() {
|
|
|
285
268
|
/>
|
|
286
269
|
</FilterColumn>
|
|
287
270
|
|
|
288
|
-
{storedName && location.pathname.includes(`filter/`) ? (
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
/>
|
|
317
|
-
</FilterColumn>
|
|
318
|
-
</>
|
|
319
|
-
) : null}
|
|
271
|
+
{/* {storedName && location.pathname.includes(`filter/`) ? ( */}
|
|
272
|
+
<>
|
|
273
|
+
<FilterColumn>
|
|
274
|
+
<Label>Action Type</Label>
|
|
275
|
+
<StyledAntSelect
|
|
276
|
+
options={actionTypeOptions}
|
|
277
|
+
placeholder="Select Action Type"
|
|
278
|
+
value={selectedFilterValue}
|
|
279
|
+
onChange={handleActionClick}
|
|
280
|
+
style={{ minWidth: '14vw' }}
|
|
281
|
+
allowClear
|
|
282
|
+
/>
|
|
283
|
+
</FilterColumn>
|
|
284
|
+
|
|
285
|
+
<FilterColumn>
|
|
286
|
+
<Label>Location </Label>
|
|
287
|
+
<StyledAntSelect
|
|
288
|
+
options={locationOptions}
|
|
289
|
+
value={selectedLocationValue}
|
|
290
|
+
placeholder="Select Location"
|
|
291
|
+
onChange={handleLocationChange}
|
|
292
|
+
style={{ minWidth: '14vw' }}
|
|
293
|
+
allowClear
|
|
294
|
+
mode="multiple"
|
|
295
|
+
/>
|
|
296
|
+
</FilterColumn>
|
|
297
|
+
</>
|
|
298
|
+
{/* ) : null} */}
|
|
320
299
|
</LeftColumn>
|
|
321
300
|
<RightColumn>
|
|
322
301
|
<ApplyButton onClick={applyFilters} disabled={!isButtonEnabled}>
|
|
@@ -24,7 +24,7 @@ interface FilterState {
|
|
|
24
24
|
}
|
|
25
25
|
// let todayDate = new Date();
|
|
26
26
|
const initialState: FilterState = {
|
|
27
|
-
'x-filters': [],
|
|
27
|
+
'x-filters': [{ field: 'isdeleted', op: '=', value: 0 }],
|
|
28
28
|
'x-pagination': { page: 1, per_page: 50 },
|
|
29
29
|
};
|
|
30
30
|
|
|
@@ -75,10 +75,10 @@ const filterReducer = (state: FilterState, action: any): FilterState => {
|
|
|
75
75
|
...state,
|
|
76
76
|
'x-filters': [
|
|
77
77
|
...state['x-filters'].filter(
|
|
78
|
-
f => f.field !== '
|
|
78
|
+
f => f.field !== 'order_product_return_action.type'
|
|
79
79
|
),
|
|
80
80
|
{
|
|
81
|
-
field: '
|
|
81
|
+
field: 'order_product_return_action.type',
|
|
82
82
|
op: '=',
|
|
83
83
|
value: action.payload,
|
|
84
84
|
},
|
|
@@ -110,7 +110,7 @@ const filterReducer = (state: FilterState, action: any): FilterState => {
|
|
|
110
110
|
return {
|
|
111
111
|
...state,
|
|
112
112
|
'x-filters': state['x-filters'].filter(
|
|
113
|
-
f => f.field !== '
|
|
113
|
+
f => f.field !== 'order_product_return_action.type'
|
|
114
114
|
),
|
|
115
115
|
};
|
|
116
116
|
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import {
|
|
3
|
+
useItemsPerOverviewPage,
|
|
3
4
|
//useItemsPerPage,
|
|
4
5
|
useLoading,
|
|
6
|
+
UsePaginationOverviewData,
|
|
7
|
+
useTableName,
|
|
5
8
|
//UsePaginationData,
|
|
6
9
|
} from './store/store';
|
|
7
10
|
import Filters from './filters/Filters';
|
|
@@ -9,49 +12,52 @@ import styled from 'styled-components';
|
|
|
9
12
|
import { useStickyStatus } from '../store';
|
|
10
13
|
import HeaderFilter from './header-filters/HeaderFilter';
|
|
11
14
|
import { useApiHook } from '@bjsdistribution/dms-component-library';
|
|
12
|
-
import { useClientData } from '../order-view/store';
|
|
15
|
+
import { useAtom, useClientData } from '../order-view/store';
|
|
13
16
|
import { ClientData } from './common/interface';
|
|
14
17
|
import ReturnFilter from './return-order-table/return-orders-filters/ReturnFilter';
|
|
15
18
|
import { Text } from './filters/FilterStyle';
|
|
16
19
|
import ReturnTable from './table/ReturnTable';
|
|
20
|
+
import { overviewfiltersReducerAtom } from './header-filters/overViewFilter';
|
|
21
|
+
// import { notification } from 'antd';
|
|
22
|
+
import Pagination from './table-view/Pagination';
|
|
17
23
|
// import Pagination from './table-view/Pagination';
|
|
18
24
|
// import { overviewfiltersReducerAtom } from './header-filters/overViewFilter';
|
|
19
25
|
|
|
20
26
|
function ReturnMainTable() {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
const [state] = useAtom(overviewfiltersReducerAtom);
|
|
28
|
+
const [paginationObj] = UsePaginationOverviewData();
|
|
29
|
+
const [, setCurrentPage] = useState(1);
|
|
30
|
+
const [itemsPerPage, setItemsPerPage] = useItemsPerOverviewPage();
|
|
31
|
+
const { 'x-pagination': pagination } = state;
|
|
32
|
+
const { page, total } = paginationObj;
|
|
27
33
|
// const [selectedClient] = useTableName();
|
|
28
|
-
// const [, setPaginationObject] = UsePaginationData();
|
|
29
34
|
const [isScrolled] = useStickyStatus();
|
|
30
35
|
const [, setLoading] = useLoading();
|
|
31
36
|
const [, setClientData] = useClientData();
|
|
37
|
+
const [tableName] = useTableName();
|
|
32
38
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
const handlePageChange = (page: number) => {
|
|
40
|
+
setCurrentPage(page);
|
|
41
|
+
};
|
|
42
|
+
const handleItemsPerPageChange = (itemsPerPage: number) => {
|
|
43
|
+
setItemsPerPage(itemsPerPage);
|
|
44
|
+
};
|
|
39
45
|
|
|
40
46
|
const {
|
|
41
47
|
data: fetchedClientData,
|
|
42
|
-
loading:
|
|
48
|
+
loading: statsDataLoading,
|
|
43
49
|
// paginationData,
|
|
44
50
|
} = useApiHook<{
|
|
45
51
|
data: ClientData[];
|
|
46
52
|
}>({
|
|
47
|
-
endpoint: `/return_orders/
|
|
53
|
+
endpoint: `/return_orders/stats/`,
|
|
48
54
|
method: 'GET',
|
|
49
55
|
//@ts-ignore
|
|
50
|
-
pagination:
|
|
56
|
+
pagination: pagination,
|
|
51
57
|
});
|
|
52
58
|
|
|
53
59
|
useEffect(() => {
|
|
54
|
-
setLoading(
|
|
60
|
+
setLoading(statsDataLoading);
|
|
55
61
|
if (fetchedClientData && fetchedClientData.data) {
|
|
56
62
|
const result = fetchedClientData?.data;
|
|
57
63
|
setClientData(result);
|
|
@@ -65,9 +71,7 @@ function ReturnMainTable() {
|
|
|
65
71
|
// });
|
|
66
72
|
// }
|
|
67
73
|
}
|
|
68
|
-
}, [
|
|
69
|
-
|
|
70
|
-
const getClient = localStorage.getItem('clientName');
|
|
74
|
+
}, [statsDataLoading]);
|
|
71
75
|
|
|
72
76
|
return (
|
|
73
77
|
<>
|
|
@@ -78,11 +82,11 @@ function ReturnMainTable() {
|
|
|
78
82
|
<Container>
|
|
79
83
|
<Row>
|
|
80
84
|
<Text>Client Return</Text>
|
|
81
|
-
{
|
|
85
|
+
{tableName ? <ReturnFilter /> : <Filters />}
|
|
82
86
|
</Row>
|
|
83
87
|
<ReturnTable />
|
|
84
88
|
</Container>
|
|
85
|
-
{
|
|
89
|
+
{total > 0 && (
|
|
86
90
|
<Pagination
|
|
87
91
|
currentPage={page}
|
|
88
92
|
totalItems={total}
|
|
@@ -90,7 +94,7 @@ function ReturnMainTable() {
|
|
|
90
94
|
onPageChange={handlePageChange}
|
|
91
95
|
onItemsPerPageChange={handleItemsPerPageChange}
|
|
92
96
|
></Pagination>
|
|
93
|
-
)}
|
|
97
|
+
)}
|
|
94
98
|
</div>
|
|
95
99
|
</DashBoardWrapper>
|
|
96
100
|
</>
|
|
@@ -14,22 +14,19 @@ import { useApiHook } from '@bjsdistribution/dms-component-library';
|
|
|
14
14
|
import { filtersReducerReturnAtom } from './table-filters/ReturnFilterStore';
|
|
15
15
|
import { notification } from 'antd';
|
|
16
16
|
import ReturnPagination from '../table-view/ReturnPagination';
|
|
17
|
+
import { useCallApiAgain } from '../../store';
|
|
17
18
|
|
|
18
19
|
const ReturnAfterTable = () => {
|
|
19
|
-
const [, setReturnOrderData] = useReturnAfterOrderData();
|
|
20
|
+
const [returnAfterOrder, setReturnOrderData] = useReturnAfterOrderData();
|
|
20
21
|
const [, setLoading] = useLoading();
|
|
21
22
|
const [state] = useAtom(filtersReducerReturnAtom);
|
|
23
|
+
const [callApi] = useCallApiAgain();
|
|
24
|
+
|
|
22
25
|
const { 'x-filters': filters, 'x-pagination': pagination } = state;
|
|
23
|
-
const splitPath = (str: any) => {
|
|
24
|
-
const parts = str?.split('/')?.filter((part: any) => part !== ''); // Filter out empty parts
|
|
25
|
-
return parts;
|
|
26
|
-
};
|
|
27
|
-
const paths = splitPath(location.pathname);
|
|
28
26
|
const [paginationObj] = UsePaginationReturnData();
|
|
29
27
|
const [, setCurrentPage] = useState(1);
|
|
30
28
|
const [itemsPerPage, setItemsPerPage] = useItemsPerReturnPage();
|
|
31
29
|
const [, setPaginationObject] = UsePaginationData();
|
|
32
|
-
console.log(paths, 'paths');
|
|
33
30
|
const { page, total } = paginationObj;
|
|
34
31
|
|
|
35
32
|
const handlePageChange = (page: number) => {
|
|
@@ -41,17 +38,23 @@ const ReturnAfterTable = () => {
|
|
|
41
38
|
|
|
42
39
|
const {
|
|
43
40
|
data: fetchedReturnOrderData,
|
|
44
|
-
loading
|
|
41
|
+
loading,
|
|
42
|
+
setShouldPerformAction,
|
|
45
43
|
paginationData,
|
|
46
44
|
} = useApiHook<ApiResponse>({
|
|
47
45
|
endpoint: '/return_orders/?skip_filters=0',
|
|
48
46
|
method: 'GET',
|
|
49
47
|
filters: filters,
|
|
50
48
|
pagination: pagination,
|
|
49
|
+
performAction: false,
|
|
51
50
|
});
|
|
52
51
|
|
|
53
52
|
useEffect(() => {
|
|
54
|
-
|
|
53
|
+
callApi ? setShouldPerformAction(true) : setShouldPerformAction(false);
|
|
54
|
+
}, [callApi]);
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
setLoading(loading);
|
|
55
58
|
if (fetchedReturnOrderData && fetchedReturnOrderData?.data) {
|
|
56
59
|
setReturnOrderData(fetchedReturnOrderData?.data);
|
|
57
60
|
if (paginationData !== null) {
|
|
@@ -64,7 +67,8 @@ const ReturnAfterTable = () => {
|
|
|
64
67
|
});
|
|
65
68
|
}
|
|
66
69
|
}
|
|
67
|
-
}, [fetchedReturnOrderData,
|
|
70
|
+
}, [fetchedReturnOrderData, loading, returnAfterOrder]);
|
|
71
|
+
|
|
68
72
|
return (
|
|
69
73
|
<div>
|
|
70
74
|
<DashBoardWrapper>
|