@bjsdistribution/dms-client-return 0.0.32 → 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 +973 -2192
- 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 +981 -2200
- 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/return-order-table/return-orders-filters/returnstyles.ts +4 -3
- 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 +2 -2
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/MenuDropDown.tsx +5 -9
- 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/Status.tsx +1 -1
- package/src/components/order-view/general-information/dropdowns/Print.tsx +1 -1
- package/src/components/order-view/modalsPopup/ModalManager.tsx +4 -151
- package/src/components/order-view/notes/order-dropdown/NewReturnDropdown.tsx +88 -13
- package/src/components/order-view/order-actions/actions/split-order/SplitOrderTable.tsx +2 -2
- package/src/components/order-view/order-actions/index.tsx +0 -9
- package/src/components/order-view/order-details/expanded-content/footer/index.tsx +1 -0
- 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/order-view/store.ts +6 -1
- package/src/components/store.ts +51 -1
- package/src/components/types.ts +5 -0
- package/src/index.tsx +25 -16
|
@@ -3,24 +3,12 @@ import { AntModal, useApiHook } from '@bjsdistribution/dms-component-library';
|
|
|
3
3
|
import { useAtom } from 'jotai';
|
|
4
4
|
import {
|
|
5
5
|
countReducerAtom,
|
|
6
|
-
letselectedProductIdAtom,
|
|
7
|
-
selectedTabKeyAtom,
|
|
8
|
-
useCreateOrderProducts,
|
|
9
6
|
useDeleteProdsID,
|
|
10
7
|
usefetchAgain,
|
|
11
|
-
// usefetchAgain,
|
|
12
|
-
useOrderId,
|
|
13
8
|
useProductDetails,
|
|
14
|
-
useRecieveOrderProducts,
|
|
15
|
-
useUpdateOrderProducts,
|
|
16
9
|
} from '../store';
|
|
17
10
|
|
|
18
|
-
import ProductAction from './ProductAction';
|
|
19
|
-
// import DeleteProduct from './DeleteProduct';
|
|
20
|
-
// import AddProduct from './AddProduct';
|
|
21
|
-
import logsTable from './qclogs/logsTable';
|
|
22
11
|
import DefectsModal from './DefectsModal';
|
|
23
|
-
import repackModal from './RepackModal';
|
|
24
12
|
import { ApiResponse } from '../types';
|
|
25
13
|
import CreateReturnModal from './CreateReturnModal';
|
|
26
14
|
import {
|
|
@@ -38,13 +26,7 @@ import { useNavigate } from 'react-router-dom';
|
|
|
38
26
|
const ModalManager = () => {
|
|
39
27
|
const [popupName, dispatch] = useAtom(countReducerAtom);
|
|
40
28
|
const [,] = useProductDetails();
|
|
41
|
-
const [orderProduct] = useCreateOrderProducts();
|
|
42
|
-
const [orderId] = useOrderId();
|
|
43
29
|
const [selectedRows] = useDeleteProdsID();
|
|
44
|
-
const [unRecieve, setUnRecieve] = useRecieveOrderProducts();
|
|
45
|
-
const [updateOrderProduct, setUpdateOrderProduct] = useUpdateOrderProducts();
|
|
46
|
-
const [selectedProductId] = useAtom(letselectedProductIdAtom);
|
|
47
|
-
const [selectedTab] = useAtom(selectedTabKeyAtom);
|
|
48
30
|
const [, setIsFormValid] = useState(false);
|
|
49
31
|
const [newGrouped] = useFinalPayload();
|
|
50
32
|
const [postLoading, SetPostLoading] = usePostLoading();
|
|
@@ -56,14 +38,11 @@ const ModalManager = () => {
|
|
|
56
38
|
const [, setCallForFetch] = usefetchAgain();
|
|
57
39
|
const navigate = useNavigate();
|
|
58
40
|
|
|
59
|
-
console.log(orderProduct, 'abcabcabcabcabcabcabcabcabcabcabc');
|
|
60
|
-
|
|
61
41
|
const closeModal = () => {
|
|
62
42
|
dispatch({ type: 'close' });
|
|
63
43
|
};
|
|
64
44
|
|
|
65
45
|
const validateForm = () => {
|
|
66
|
-
console.log(selectedRows, 'selectedRowsselectedRowsselectedRows');
|
|
67
46
|
return selectedRows?.length > 0;
|
|
68
47
|
};
|
|
69
48
|
|
|
@@ -71,66 +50,6 @@ const ModalManager = () => {
|
|
|
71
50
|
setIsFormValid(validateForm());
|
|
72
51
|
}, [selectedRows]);
|
|
73
52
|
|
|
74
|
-
// api block for the create product order
|
|
75
|
-
const {
|
|
76
|
-
data: actionResponse,
|
|
77
|
-
setShouldPerformAction: setUnrecieveaction,
|
|
78
|
-
} = useApiHook<{
|
|
79
|
-
data: ApiResponse[];
|
|
80
|
-
}>({
|
|
81
|
-
endpoint: `order/order_products/unrecieve/`,
|
|
82
|
-
method: 'POST',
|
|
83
|
-
body: [unRecieve],
|
|
84
|
-
performAction: false,
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
useEffect(() => {
|
|
88
|
-
if (actionResponse && actionResponse?.data) {
|
|
89
|
-
dispatch({ type: 'close' });
|
|
90
|
-
}
|
|
91
|
-
}, [actionResponse]);
|
|
92
|
-
|
|
93
|
-
// api block for the update product order
|
|
94
|
-
const {
|
|
95
|
-
data: updateResponse,
|
|
96
|
-
setShouldPerformAction: setUpdateSction,
|
|
97
|
-
} = useApiHook<{
|
|
98
|
-
data: ApiResponse[];
|
|
99
|
-
}>({
|
|
100
|
-
endpoint: `order/order_products/type/update/`,
|
|
101
|
-
method: 'PUT',
|
|
102
|
-
body: [updateOrderProduct],
|
|
103
|
-
performAction: false,
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
const onSubmit = () => {
|
|
107
|
-
if (selectedTab === '1') {
|
|
108
|
-
setUpdateOrderProduct((prev: any) => ({
|
|
109
|
-
...prev,
|
|
110
|
-
order_id: orderId,
|
|
111
|
-
id: selectedProductId,
|
|
112
|
-
}));
|
|
113
|
-
setUpdateSction(true);
|
|
114
|
-
console.log('Tab 1 selected');
|
|
115
|
-
} else if (selectedTab === '2') {
|
|
116
|
-
console.log('Tab 2 selected');
|
|
117
|
-
} else if (selectedTab === '3') {
|
|
118
|
-
setUnRecieve((prev: any) => ({
|
|
119
|
-
...prev,
|
|
120
|
-
order_id: orderId,
|
|
121
|
-
id: selectedProductId,
|
|
122
|
-
}));
|
|
123
|
-
setUnrecieveaction(true);
|
|
124
|
-
console.log('Tab 3 selected');
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
useEffect(() => {
|
|
129
|
-
if (updateResponse && updateResponse?.data) {
|
|
130
|
-
dispatch({ type: 'close' });
|
|
131
|
-
}
|
|
132
|
-
}, [updateResponse]);
|
|
133
|
-
|
|
134
53
|
// Confirm return popup
|
|
135
54
|
const {
|
|
136
55
|
data: response,
|
|
@@ -146,10 +65,9 @@ const ModalManager = () => {
|
|
|
146
65
|
body: newGrouped,
|
|
147
66
|
performAction: false,
|
|
148
67
|
});
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}, [confirmLoading]);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
SetPostLoading(confirmLoading);
|
|
70
|
+
}, [confirmLoading]);
|
|
153
71
|
|
|
154
72
|
const handleConfirmReturn = () => {
|
|
155
73
|
if (newGrouped?.length > 0) {
|
|
@@ -258,49 +176,7 @@ const ModalManager = () => {
|
|
|
258
176
|
/>
|
|
259
177
|
</>
|
|
260
178
|
)}
|
|
261
|
-
|
|
262
|
-
<AntModal
|
|
263
|
-
openStatus={popupName?.state === 'qclog'}
|
|
264
|
-
closeModal={closeModal}
|
|
265
|
-
PopupHeader={{
|
|
266
|
-
heading: 'Deliver - STOHOP011GRY-UK - 006064438012831476',
|
|
267
|
-
subHeading: '[Hopkins Highboard, Walnut Effect Grey]',
|
|
268
|
-
}}
|
|
269
|
-
PopupFooter={{
|
|
270
|
-
btns: [
|
|
271
|
-
{
|
|
272
|
-
name: 'Submit',
|
|
273
|
-
btnStyle: 'rounded',
|
|
274
|
-
onClick: onSubmit,
|
|
275
|
-
},
|
|
276
|
-
],
|
|
277
|
-
}}
|
|
278
|
-
BodyComponent={ProductAction}
|
|
279
|
-
width={1104}
|
|
280
|
-
classNameAdd={'globalPopup'}
|
|
281
|
-
/>
|
|
282
|
-
)}
|
|
283
|
-
{popupName?.state == 'qclogtable' && (
|
|
284
|
-
<AntModal
|
|
285
|
-
openStatus={popupName?.state == 'qclogtable' ? true : false}
|
|
286
|
-
closeModal={closeModal}
|
|
287
|
-
PopupHeader={{
|
|
288
|
-
heading: 'Deliver-AI-00030345784968148412',
|
|
289
|
-
subHeading: '[Centralized regional adpated] ',
|
|
290
|
-
}}
|
|
291
|
-
PopupFooter={{
|
|
292
|
-
btns: [
|
|
293
|
-
{
|
|
294
|
-
name: 'Submit',
|
|
295
|
-
btnStyle: 'rounded',
|
|
296
|
-
},
|
|
297
|
-
],
|
|
298
|
-
}}
|
|
299
|
-
BodyComponent={logsTable}
|
|
300
|
-
width={1104}
|
|
301
|
-
classNameAdd={'globalPopup'}
|
|
302
|
-
/>
|
|
303
|
-
)}
|
|
179
|
+
|
|
304
180
|
{popupName?.state == 'defectsModal' && (
|
|
305
181
|
<AntModal
|
|
306
182
|
openStatus={popupName?.state == 'defectsModal' ? true : false}
|
|
@@ -324,29 +200,6 @@ const ModalManager = () => {
|
|
|
324
200
|
classNameAdd={'globalPopup'}
|
|
325
201
|
/>
|
|
326
202
|
)}
|
|
327
|
-
{popupName?.state == 'repackModal' && (
|
|
328
|
-
<AntModal
|
|
329
|
-
openStatus={popupName?.state == 'repackModal' ? true : false}
|
|
330
|
-
closeModal={closeModal}
|
|
331
|
-
PopupHeader={{
|
|
332
|
-
heading: 'DEliver - DWLK1006 - 00605',
|
|
333
|
-
subHeading: 'ALtair TV stand for TVs up to 60',
|
|
334
|
-
}}
|
|
335
|
-
PopupFooter={{
|
|
336
|
-
btns: [
|
|
337
|
-
{
|
|
338
|
-
name: '',
|
|
339
|
-
btnStyle: '',
|
|
340
|
-
type: '',
|
|
341
|
-
},
|
|
342
|
-
],
|
|
343
|
-
btnAlign: '',
|
|
344
|
-
}}
|
|
345
|
-
BodyComponent={repackModal}
|
|
346
|
-
width={1504}
|
|
347
|
-
classNameAdd={'globalPopup'}
|
|
348
|
-
/>
|
|
349
|
-
)}
|
|
350
203
|
</>
|
|
351
204
|
);
|
|
352
205
|
};
|
|
@@ -1,45 +1,120 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
-
import {
|
|
3
|
+
import { useApiHook } from '@bjsdistribution/dms-component-library';
|
|
4
|
+
import { ApiResponse } from '../../types';
|
|
5
|
+
import { useOrderDetails, useProductDetails } from '../../store';
|
|
6
|
+
import { Select } from 'antd';
|
|
7
|
+
import { useSelectedProducts } from '../../../store';
|
|
8
|
+
import { atom, useAtom } from 'jotai';
|
|
9
|
+
|
|
10
|
+
export const payloadAtom = atom<any>(null);
|
|
4
11
|
|
|
5
12
|
const NewReturnDropdown = () => {
|
|
6
13
|
const defaultSelectStyle = { width: '100%' };
|
|
7
14
|
const defaultPopupClassName = 'dropDownStyle';
|
|
8
|
-
const
|
|
15
|
+
const [returnOrderData, setReturnOrderData] = useState<any>([]);
|
|
16
|
+
const [selectedOrderId, setSelectedOrderId] = useState<string | null>(null);
|
|
17
|
+
const [selectedProducts] = useSelectedProducts();
|
|
18
|
+
const [orderData] = useOrderDetails();
|
|
19
|
+
const [, setPayload] = useAtom(payloadAtom);
|
|
20
|
+
const [productData] = useProductDetails();
|
|
21
|
+
const [idProduct, setId] = useState<any>();
|
|
22
|
+
|
|
23
|
+
const id = orderData?.customer_id;
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const allProductIds =
|
|
27
|
+
productData?.map((product: any) => product.return_location) || [];
|
|
28
|
+
setId(allProductIds);
|
|
29
|
+
}, [productData]);
|
|
30
|
+
|
|
31
|
+
const filters = [
|
|
32
|
+
{ field: 'customer_id', op: '=', value: id },
|
|
33
|
+
{ field: 'is_deleted', op: '=', value: 0 },
|
|
34
|
+
{ field: 'status', op: '!=', value: 'SD' },
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
if (idProduct?.length > 0 && idProduct[0]) {
|
|
38
|
+
filters.push({
|
|
39
|
+
field: 'return_order_products.return_location',
|
|
40
|
+
op: '=',
|
|
41
|
+
value: idProduct[0],
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const { data: fetchedReturnOrderData, setShouldPerformAction } = useApiHook<
|
|
46
|
+
ApiResponse
|
|
47
|
+
>({
|
|
48
|
+
endpoint: '/return_orders/?skip_filters=0',
|
|
49
|
+
method: 'GET',
|
|
50
|
+
filters,
|
|
51
|
+
//@ts-ignore
|
|
52
|
+
pagination: { is_pagination: false },
|
|
53
|
+
performAction: false,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (id && idProduct?.length > 0 && idProduct[0]) {
|
|
58
|
+
setShouldPerformAction(true);
|
|
59
|
+
}
|
|
60
|
+
}, [id, idProduct, setShouldPerformAction]);
|
|
61
|
+
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (fetchedReturnOrderData && fetchedReturnOrderData?.data && id !== null) {
|
|
64
|
+
setReturnOrderData(fetchedReturnOrderData?.data);
|
|
65
|
+
}
|
|
66
|
+
}, [fetchedReturnOrderData, id]);
|
|
67
|
+
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (selectedOrderId && selectedProducts?.length > 0) {
|
|
70
|
+
const newPayload = {
|
|
71
|
+
new_return_order: selectedOrderId,
|
|
72
|
+
products: selectedProducts,
|
|
73
|
+
};
|
|
74
|
+
setPayload(newPayload);
|
|
75
|
+
}
|
|
76
|
+
}, [selectedOrderId, selectedProducts, setPayload]);
|
|
77
|
+
|
|
78
|
+
const handleDropdownChange = (value: string) => {
|
|
79
|
+
setSelectedOrderId(value);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const dropdownOptions = returnOrderData?.map((order: any) => ({
|
|
83
|
+
label: `${order.order_recipient.recipient_name} - ${order.order_recipient.postcode}`,
|
|
84
|
+
value: order.id,
|
|
85
|
+
}));
|
|
9
86
|
|
|
10
87
|
return (
|
|
11
88
|
<Container>
|
|
12
89
|
<Text>New Return Order:</Text>
|
|
13
|
-
<
|
|
14
|
-
options={
|
|
90
|
+
<Select
|
|
91
|
+
options={dropdownOptions}
|
|
15
92
|
placeholder="Select"
|
|
16
|
-
onChange={
|
|
17
|
-
defaultValue={'Current Return Order' || ''}
|
|
93
|
+
onChange={handleDropdownChange}
|
|
18
94
|
style={defaultSelectStyle}
|
|
19
95
|
disabled={false}
|
|
20
|
-
// onSearch={handleSearch}
|
|
21
96
|
showSearch
|
|
97
|
+
dropdownStyle={{ width: 'max-content' }}
|
|
22
98
|
popupClassName={defaultPopupClassName}
|
|
23
|
-
selectWrapperClass={defaultSelectWrapperClass}
|
|
24
99
|
/>
|
|
25
100
|
</Container>
|
|
26
101
|
);
|
|
27
102
|
};
|
|
103
|
+
|
|
28
104
|
const Container = styled.div`
|
|
29
105
|
display: flex;
|
|
30
106
|
align-items: center;
|
|
31
107
|
gap: 10px;
|
|
32
108
|
align-self: stretch;
|
|
109
|
+
white-space: nowrap;
|
|
33
110
|
`;
|
|
111
|
+
|
|
34
112
|
const Text = styled.div`
|
|
35
113
|
color: #000;
|
|
36
|
-
|
|
37
|
-
/* body/captions */
|
|
38
114
|
font-family: 'Lato';
|
|
39
115
|
font-size: 13px;
|
|
40
|
-
font-style: normal;
|
|
41
116
|
font-weight: 400;
|
|
42
|
-
line-height: 16px;
|
|
117
|
+
line-height: 16px;
|
|
43
118
|
`;
|
|
44
119
|
|
|
45
120
|
export default NewReturnDropdown;
|
|
@@ -7,9 +7,9 @@ import { Checkbox } from '@bjsdistribution/dms-component-library';
|
|
|
7
7
|
import { useSelectedSplit, useSplitOrderPayload } from '../../store';
|
|
8
8
|
import {
|
|
9
9
|
EmptyDataContainer,
|
|
10
|
+
StyledTable,
|
|
10
11
|
StyledTableWrapper,
|
|
11
12
|
} from '../confirm-order/tables/ReminderStyles';
|
|
12
|
-
import { StyledTable } from '../modalstyle';
|
|
13
13
|
|
|
14
14
|
function SplitOrderTable() {
|
|
15
15
|
const [orderProductDetails] = useProductDetails();
|
|
@@ -48,7 +48,7 @@ function SplitOrderTable() {
|
|
|
48
48
|
useEffect(() => {
|
|
49
49
|
setPayload({
|
|
50
50
|
...payload,
|
|
51
|
-
return_order:
|
|
51
|
+
return_order: 1, // FOR SPLIT ORDER WE ARE ASKED TO SET THIS AS 1
|
|
52
52
|
products: selectedSplits?.map(order => order.id),
|
|
53
53
|
force: true,
|
|
54
54
|
});
|
|
@@ -5,17 +5,14 @@ import { useCurrentAction } from '../store';
|
|
|
5
5
|
import SplitOrder from './actions/split-order';
|
|
6
6
|
import LogServiceRefusal from './actions/log-service-refusal';
|
|
7
7
|
import CancelOrder from './actions/cancel-order';
|
|
8
|
-
import UpdateProductType from './actions/update-product-type/UpdateProductType';
|
|
9
8
|
import ConfirmOrder from './actions/confirm-order';
|
|
10
9
|
import SendSmsModal from './actions/send-sms/SendSmsModal';
|
|
11
10
|
import SendEmailModal from './actions/send-email/SendEmailModal';
|
|
12
11
|
import ChangeCustomerAccModal from './actions/change-customer-account/ChangeCustomerAccModal';
|
|
13
12
|
import HoldOrderModal from './actions/hold-order/HoldOrderModal';
|
|
14
|
-
import EscalationModal from './actions/escalation/EscalationModal';
|
|
15
13
|
import LogFeedback from './actions/log-feedback/LogFeedback';
|
|
16
14
|
import ChargeLog from './actions/charge-log';
|
|
17
15
|
import UnholdOrder from './actions/unhold-order/UnholdOrder';
|
|
18
|
-
import RestoreProducts from './actions/restore-products/RestoreProducts';
|
|
19
16
|
import ViewReminderModal from '../view-reminder/ViewReminder';
|
|
20
17
|
import TaskReminderModal from './actions/create-task-reminder';
|
|
21
18
|
import OrderLock from './actions/order-lock';
|
|
@@ -29,8 +26,6 @@ function OrderActions() {
|
|
|
29
26
|
switch (currentAction) {
|
|
30
27
|
case 'add-resources':
|
|
31
28
|
return <AddResources />;
|
|
32
|
-
case 'bulk-update':
|
|
33
|
-
return <UpdateProductType />;
|
|
34
29
|
case 'split-order':
|
|
35
30
|
return <SplitOrder />;
|
|
36
31
|
case 'release-order':
|
|
@@ -53,8 +48,6 @@ function OrderActions() {
|
|
|
53
48
|
return <ChangeCustomerAccModal />;
|
|
54
49
|
case 'hold-order':
|
|
55
50
|
return <HoldOrderModal />;
|
|
56
|
-
case 'escalations':
|
|
57
|
-
return <EscalationModal />;
|
|
58
51
|
case 'create-task':
|
|
59
52
|
return <TaskReminderModal />;
|
|
60
53
|
case 'log-feedback':
|
|
@@ -63,8 +56,6 @@ function OrderActions() {
|
|
|
63
56
|
return <ChargeLog />;
|
|
64
57
|
case 'unhold-order':
|
|
65
58
|
return <UnholdOrder />;
|
|
66
|
-
case 'restore-products':
|
|
67
|
-
return <RestoreProducts />;
|
|
68
59
|
case 'view-reminder':
|
|
69
60
|
return <ViewReminderModal />;
|
|
70
61
|
case 'order-lock':
|
|
@@ -1,37 +1,111 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import ProductTable from '../../return-client-products/ProductTable';
|
|
4
|
-
import NewReturnDropdown
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import NewReturnDropdown, {
|
|
5
|
+
payloadAtom,
|
|
6
|
+
} from '../../notes/order-dropdown/NewReturnDropdown';
|
|
7
|
+
import { Button, useApiHook } from '@bjsdistribution/dms-component-library';
|
|
8
|
+
import { useAtom } from 'jotai';
|
|
9
|
+
import { ApiResponse } from '../../types';
|
|
10
|
+
import { usePostLoading, useSelectedProducts } from '../../../store';
|
|
11
|
+
import { useOrderId } from '../../store';
|
|
12
|
+
import { useNavigate } from 'react-router-dom';
|
|
13
|
+
import { notification } from 'antd';
|
|
7
14
|
|
|
8
15
|
function ExpandedContent() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
const [payload] = useAtom(payloadAtom);
|
|
17
|
+
const [, setPostLoading] = usePostLoading();
|
|
18
|
+
const [orderId] = useOrderId();
|
|
19
|
+
const [isButtonDisabled, setIsButtonDisabled] = useState(true);
|
|
20
|
+
const navigate = useNavigate();
|
|
21
|
+
const [, setSelectedProducts] = useSelectedProducts();
|
|
22
|
+
|
|
23
|
+
const {
|
|
24
|
+
data: response,
|
|
25
|
+
setShouldPerformAction,
|
|
26
|
+
loading: confirmLoading,
|
|
27
|
+
} = useApiHook<{
|
|
28
|
+
data: ApiResponse[];
|
|
29
|
+
}>({
|
|
30
|
+
endpoint: `return_order_products/move/${orderId}`,
|
|
31
|
+
method: 'POST',
|
|
32
|
+
body: payload,
|
|
33
|
+
performAction: false,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
setPostLoading(confirmLoading);
|
|
38
|
+
}, [confirmLoading, setPostLoading]);
|
|
39
|
+
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (payload?.new_return_order && payload?.products?.length > 0) {
|
|
42
|
+
setIsButtonDisabled(false);
|
|
43
|
+
} else {
|
|
44
|
+
setIsButtonDisabled(true);
|
|
45
|
+
}
|
|
46
|
+
}, [payload]);
|
|
47
|
+
|
|
48
|
+
const handleConfirmReturn = () => {
|
|
49
|
+
if (!isButtonDisabled) {
|
|
50
|
+
setShouldPerformAction(true);
|
|
51
|
+
setPostLoading(confirmLoading);
|
|
52
|
+
} else {
|
|
53
|
+
console.error('Payload is incomplete:', payload);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const newId = Array.isArray(response?.data)
|
|
58
|
+
? //@ts-ignore
|
|
59
|
+
response?.data?.[0]?.id
|
|
60
|
+
: //@ts-ignore
|
|
61
|
+
response?.data?.id;
|
|
62
|
+
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
//@ts-ignore
|
|
65
|
+
if (response?.code === 200) {
|
|
66
|
+
notification.success({
|
|
67
|
+
message: 'Success',
|
|
68
|
+
//@ts-ignore
|
|
69
|
+
|
|
70
|
+
description: response?.message || 'Products moved successfully',
|
|
71
|
+
});
|
|
72
|
+
setSelectedProducts([]);
|
|
73
|
+
} else if (response) {
|
|
74
|
+
notification.error({
|
|
75
|
+
message: 'Error',
|
|
76
|
+
//@ts-ignore
|
|
77
|
+
|
|
78
|
+
description: response?.message || 'Error while moving products',
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
//@ts-ignore
|
|
83
|
+
if (response?.code === 200 && newId) {
|
|
84
|
+
navigate(`details/${newId}`);
|
|
85
|
+
setSelectedProducts([]);
|
|
86
|
+
}
|
|
87
|
+
}, [response, newId, navigate, setSelectedProducts]);
|
|
88
|
+
|
|
16
89
|
return (
|
|
17
90
|
<Container>
|
|
18
91
|
<ProductTable />
|
|
19
|
-
<
|
|
92
|
+
<MidContainer>
|
|
20
93
|
<SaveNoteContainer>
|
|
21
94
|
<Button
|
|
22
95
|
style={{ borderRadius: '20px' }}
|
|
23
|
-
onClick={
|
|
24
|
-
disabled={
|
|
96
|
+
onClick={handleConfirmReturn}
|
|
97
|
+
disabled={isButtonDisabled}
|
|
25
98
|
>
|
|
26
99
|
Move Products
|
|
27
100
|
</Button>
|
|
28
101
|
<NewReturnDropdown />
|
|
29
102
|
</SaveNoteContainer>
|
|
30
|
-
</
|
|
103
|
+
</MidContainer>
|
|
31
104
|
</Container>
|
|
32
105
|
);
|
|
33
106
|
}
|
|
34
|
-
|
|
107
|
+
|
|
108
|
+
const MidContainer = styled.div`
|
|
35
109
|
display: flex;
|
|
36
110
|
justify-content: space-between;
|
|
37
111
|
padding: 10px 15px;
|
|
@@ -47,6 +121,7 @@ const SaveNoteContainer = styled.div`
|
|
|
47
121
|
display: inline-flex;
|
|
48
122
|
gap: 10px;
|
|
49
123
|
`;
|
|
124
|
+
|
|
50
125
|
const Container = styled.div``;
|
|
51
126
|
|
|
52
127
|
export default ExpandedContent;
|
|
@@ -25,7 +25,7 @@ function ProductsInfo() {
|
|
|
25
25
|
const { data: fetchedData, loading, setShouldPerformAction } = useApiHook<{
|
|
26
26
|
data: ApiResponse[];
|
|
27
27
|
}>({
|
|
28
|
-
endpoint:
|
|
28
|
+
endpoint: `return_order_products/${customerData.id}`,
|
|
29
29
|
method: 'GET',
|
|
30
30
|
performAction: false,
|
|
31
31
|
});
|