@bjsdistribution/dms-client-return 0.0.11 → 0.0.12
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/common/fakedata.d.ts +4 -0
- package/dist/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.d.ts +1 -1
- package/dist/components/order-view/details-filters/left-side-filters/dropdowns/{PrintDropDown.d.ts → PrintDropDownReturn.d.ts} +2 -2
- package/dist/components/store.d.ts +6 -1
- package/dist/dms-client-return.cjs.development.js +279 -112
- 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 +280 -113
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/order-daily-overview/common/fakedata.tsx +4 -0
- package/src/components/order-daily-overview/header-filters/HeaderFilter.tsx +10 -1
- package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +15 -7
- package/src/components/order-daily-overview/index.tsx +1 -1
- package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +4 -8
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.ts +12 -14
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx +32 -33
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +74 -30
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/returnstyles.ts +3 -0
- package/src/components/order-daily-overview/table-view/Pagination.tsx +15 -14
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/{PrintDropDown.tsx → PrintDropDownReturn.tsx} +4 -4
- package/src/components/order-view/modalsPopup/CreateReturnModal.tsx +74 -36
- package/src/components/order-view/modalsPopup/ModalManager.tsx +47 -12
- package/src/components/store.ts +35 -0
|
@@ -2,14 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { PrintIconMap } from '../../../../order-daily-overview/shared/utlis';
|
|
4
4
|
import { PrintData } from '../../../../order-daily-overview/shared/interface';
|
|
5
|
-
import {
|
|
5
|
+
import { optionsForReturnPrint } from '../../../../order-daily-overview/common/fakedata';
|
|
6
6
|
// import { PrintIconMap } from '../utils';
|
|
7
7
|
// import { optionsPrint } from '../fakeData';
|
|
8
8
|
// import { PrintData } from '../interface';
|
|
9
9
|
|
|
10
|
-
const options: PrintData[] =
|
|
10
|
+
const options: PrintData[] = optionsForReturnPrint;
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const PrintDropDownReturn = () => {
|
|
13
13
|
const downloadFiles = () => {};
|
|
14
14
|
return (
|
|
15
15
|
<OptionsList>
|
|
@@ -26,7 +26,7 @@ const PrintDropDown = () => {
|
|
|
26
26
|
);
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
export default
|
|
29
|
+
export default PrintDropDownReturn;
|
|
30
30
|
|
|
31
31
|
export const OptionsList = styled.ul`
|
|
32
32
|
margin: 0;
|
|
@@ -1,56 +1,94 @@
|
|
|
1
1
|
import { Alert, Checkbox } from '@bjsdistribution/dms-component-library';
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
useFinalPayload,
|
|
6
|
+
useGroupedPayload,
|
|
7
|
+
usePostLoading,
|
|
8
|
+
useSelectedConfirmLoc,
|
|
9
|
+
useSelectedOrders,
|
|
10
|
+
} from '../../store';
|
|
11
|
+
import { displayValueOrNA } from '../../order-daily-overview/shared/utlis';
|
|
12
|
+
import Loader from '../../order-daily-overview/header/loader/Loader';
|
|
5
13
|
|
|
6
14
|
const CreateReturnModal = () => {
|
|
7
|
-
const [selectedlocation, setSelectedLocations] =
|
|
15
|
+
const [selectedlocation, setSelectedLocations] = useSelectedConfirmLoc();
|
|
8
16
|
const [selectedReturnOrder] = useSelectedOrders();
|
|
17
|
+
const [load] = usePostLoading();
|
|
18
|
+
const [groupedPayload] = useGroupedPayload();
|
|
19
|
+
const [forDisabledCheck] = useSelectedConfirmLoc();
|
|
20
|
+
const [, setNew] = useFinalPayload();
|
|
9
21
|
|
|
10
22
|
const handleSelectLocations = (id: number) => {
|
|
11
23
|
setSelectedLocations((prevSelectedLocations: number[]) => {
|
|
12
|
-
const isSelected = prevSelectedLocations
|
|
24
|
+
const isSelected = prevSelectedLocations?.includes(id);
|
|
13
25
|
|
|
14
26
|
if (isSelected) {
|
|
15
|
-
return prevSelectedLocations
|
|
27
|
+
return prevSelectedLocations?.filter(selectedId => selectedId !== id);
|
|
16
28
|
} else {
|
|
17
29
|
return [...prevSelectedLocations, id];
|
|
18
30
|
}
|
|
19
31
|
});
|
|
20
32
|
};
|
|
21
33
|
|
|
34
|
+
const uniqueLocations = selectedReturnOrder?.reduce((acc, current) => {
|
|
35
|
+
const x = acc.find(
|
|
36
|
+
(item: any) => item.return_location === current.return_location
|
|
37
|
+
);
|
|
38
|
+
if (!x) {
|
|
39
|
+
acc.push(current);
|
|
40
|
+
}
|
|
41
|
+
return acc;
|
|
42
|
+
}, []);
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (groupedPayload?.length > 0 && forDisabledCheck?.length > 0) {
|
|
46
|
+
const matchedItems = groupedPayload?.filter((item: any) =>
|
|
47
|
+
forDisabledCheck.includes(item.id)
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
if (matchedItems.length > 0) {
|
|
51
|
+
const finalPayload = matchedItems?.map(({ id, ...rest }: any) => rest);
|
|
52
|
+
setNew(finalPayload);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}, [forDisabledCheck]);
|
|
56
|
+
|
|
22
57
|
return (
|
|
23
|
-
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
58
|
+
<>
|
|
59
|
+
{load && <Loader />}
|
|
60
|
+
<Wrapper>
|
|
61
|
+
<Alert
|
|
62
|
+
onClose={() => {}}
|
|
63
|
+
description=""
|
|
64
|
+
type="info"
|
|
65
|
+
title="Do you wish to proceed?"
|
|
66
|
+
showOkButton={false}
|
|
67
|
+
/>
|
|
68
|
+
<Container>
|
|
69
|
+
<ul style={{ listStyle: 'none', padding: 0 }}>
|
|
70
|
+
{uniqueLocations?.map((returnLoc: any) => (
|
|
71
|
+
<li
|
|
72
|
+
key={returnLoc.id}
|
|
73
|
+
style={{
|
|
74
|
+
marginBottom: '8px',
|
|
75
|
+
display: 'flex',
|
|
76
|
+
alignItems: 'center',
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
<Checkbox
|
|
80
|
+
checked={selectedlocation?.includes(returnLoc.id)}
|
|
81
|
+
onChange={() => handleSelectLocations(returnLoc.id)}
|
|
82
|
+
/>
|
|
83
|
+
<StyledText style={{ marginLeft: '8px' }}>
|
|
84
|
+
{displayValueOrNA(returnLoc?.new_location)}
|
|
85
|
+
</StyledText>
|
|
86
|
+
</li>
|
|
87
|
+
))}
|
|
88
|
+
</ul>
|
|
89
|
+
</Container>
|
|
90
|
+
</Wrapper>
|
|
91
|
+
</>
|
|
54
92
|
);
|
|
55
93
|
};
|
|
56
94
|
|
|
@@ -21,7 +21,16 @@ import DefectsModal from './DefectsModal';
|
|
|
21
21
|
import repackModal from './RepackModal';
|
|
22
22
|
import { ApiResponse } from '../types';
|
|
23
23
|
import CreateReturnModal from './CreateReturnModal';
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
useFinalPayload,
|
|
26
|
+
useGroupedPayload,
|
|
27
|
+
useNewReturnPayload,
|
|
28
|
+
usePostLoading,
|
|
29
|
+
useSelectAll,
|
|
30
|
+
useSelectedConfirmLoc,
|
|
31
|
+
useSelectedOrders,
|
|
32
|
+
} from '../../store';
|
|
33
|
+
|
|
25
34
|
const ModalManager = () => {
|
|
26
35
|
const [popupName, dispatch] = useAtom(countReducerAtom);
|
|
27
36
|
const [,] = useProductDetails();
|
|
@@ -33,7 +42,13 @@ const ModalManager = () => {
|
|
|
33
42
|
const [selectedProductId] = useAtom(selectedProductIdAtom);
|
|
34
43
|
const [selectedTab] = useAtom(selectedTabKeyAtom);
|
|
35
44
|
const [, setIsFormValid] = useState(false);
|
|
36
|
-
const [
|
|
45
|
+
const [newGrouped, setNewGrouped] = useFinalPayload();
|
|
46
|
+
const [, SetPostLoading] = usePostLoading();
|
|
47
|
+
const [, setSelectedReturnOrder] = useSelectedOrders();
|
|
48
|
+
const [, setCheck] = useSelectedConfirmLoc();
|
|
49
|
+
const [, setNewPayload] = useNewReturnPayload();
|
|
50
|
+
const [, setGrouped] = useGroupedPayload();
|
|
51
|
+
const [, setSelectAll] = useSelectAll();
|
|
37
52
|
|
|
38
53
|
console.log(orderProduct, 'abcabcabcabcabcabcabcabcabcabcabc');
|
|
39
54
|
|
|
@@ -227,27 +242,47 @@ const ModalManager = () => {
|
|
|
227
242
|
}, [updateResponse]);
|
|
228
243
|
|
|
229
244
|
//Confirm return popup
|
|
230
|
-
const {
|
|
245
|
+
const {
|
|
246
|
+
data: response,
|
|
247
|
+
setShouldPerformAction,
|
|
248
|
+
loading: confirmLoading,
|
|
249
|
+
} = useApiHook<{
|
|
231
250
|
data: ApiResponse[];
|
|
232
251
|
}>({
|
|
233
252
|
endpoint: `return_orders/`,
|
|
234
253
|
method: 'POST',
|
|
235
|
-
body:
|
|
254
|
+
body: newGrouped,
|
|
236
255
|
performAction: false,
|
|
237
256
|
});
|
|
238
|
-
const handleConfirmReturn = () => {
|
|
239
|
-
const payloadWithoutId = newPayload?.map(({ id, ...rest }: any) => ({
|
|
240
|
-
...rest,
|
|
241
|
-
}));
|
|
242
257
|
|
|
243
|
-
|
|
258
|
+
useEffect(() => {
|
|
259
|
+
SetPostLoading(confirmLoading);
|
|
260
|
+
}, [confirmLoading]);
|
|
261
|
+
|
|
262
|
+
console.log(response);
|
|
244
263
|
|
|
245
|
-
|
|
246
|
-
|
|
264
|
+
useEffect(() => {
|
|
265
|
+
if (response === null || (response && response?.data)) {
|
|
266
|
+
dispatch({ type: 'close' });
|
|
267
|
+
setNewGrouped([]);
|
|
268
|
+
setSelectedReturnOrder([]);
|
|
269
|
+
setCheck([]);
|
|
270
|
+
setNewPayload([]);
|
|
271
|
+
setGrouped([]);
|
|
272
|
+
setShouldPerformAction(false);
|
|
273
|
+
setSelectAll(false);
|
|
274
|
+
}
|
|
275
|
+
}, [response]);
|
|
276
|
+
|
|
277
|
+
const handleConfirmReturn = () => {
|
|
278
|
+
setShouldPerformAction(false);
|
|
279
|
+
|
|
280
|
+
if (newGrouped.length > 0) {
|
|
247
281
|
setShouldPerformAction(true);
|
|
248
282
|
} else {
|
|
249
283
|
setShouldPerformAction(false);
|
|
250
284
|
}
|
|
285
|
+
dispatch({ type: 'close' });
|
|
251
286
|
};
|
|
252
287
|
|
|
253
288
|
return (
|
|
@@ -267,7 +302,7 @@ const ModalManager = () => {
|
|
|
267
302
|
btnStyle: 'rounded',
|
|
268
303
|
onClick: handleConfirmReturn,
|
|
269
304
|
type: 'button',
|
|
270
|
-
disabled:
|
|
305
|
+
// disabled: forDisabledCheck.length === 0,
|
|
271
306
|
},
|
|
272
307
|
],
|
|
273
308
|
|
package/src/components/store.ts
CHANGED
|
@@ -41,6 +41,16 @@ const newPayload = atom<any>([]);
|
|
|
41
41
|
|
|
42
42
|
const grpPayload = atom<any>([]);
|
|
43
43
|
|
|
44
|
+
const statusOfOrder = atom<any>([]);
|
|
45
|
+
|
|
46
|
+
const selectedLocationConfirm = atom<any[]>([]);
|
|
47
|
+
|
|
48
|
+
const selectAll = atom<boolean>(false);
|
|
49
|
+
|
|
50
|
+
const postLoading = atom<boolean>(false);
|
|
51
|
+
|
|
52
|
+
const final = atom<any[]>([]);
|
|
53
|
+
|
|
44
54
|
function useReminderData() {
|
|
45
55
|
return useAtom(reminderTableData);
|
|
46
56
|
}
|
|
@@ -105,6 +115,26 @@ function useGroupedPayload() {
|
|
|
105
115
|
return useAtom(grpPayload);
|
|
106
116
|
}
|
|
107
117
|
|
|
118
|
+
function useStatusOrderData() {
|
|
119
|
+
return useAtom(statusOfOrder);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function useSelectedConfirmLoc() {
|
|
123
|
+
return useAtom(selectedLocationConfirm);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function useSelectAll() {
|
|
127
|
+
return useAtom(selectAll);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function usePostLoading() {
|
|
131
|
+
return useAtom(postLoading);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function useFinalPayload() {
|
|
135
|
+
return useAtom(final);
|
|
136
|
+
}
|
|
137
|
+
|
|
108
138
|
export {
|
|
109
139
|
useAtom,
|
|
110
140
|
useFilter,
|
|
@@ -122,4 +152,9 @@ export {
|
|
|
122
152
|
useReturnPayload,
|
|
123
153
|
useNewReturnPayload,
|
|
124
154
|
useGroupedPayload,
|
|
155
|
+
useStatusOrderData,
|
|
156
|
+
useSelectedConfirmLoc,
|
|
157
|
+
useSelectAll,
|
|
158
|
+
usePostLoading,
|
|
159
|
+
useFinalPayload,
|
|
125
160
|
};
|