@bjsdistribution/dms-client-return 0.0.17 → 0.0.19
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/assets/icons/DustbinIcon.d.ts +3 -0
- package/dist/common/date-picker/header/ClearDate.d.ts +1 -1
- package/dist/components/order-daily-overview/header-filters/overViewFilter.d.ts +16 -0
- package/dist/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.d.ts +1 -1
- package/dist/components/order-daily-overview/store/store.d.ts +2 -0
- package/dist/components/order-daily-overview/table-view/ReturnPagination.d.ts +3 -0
- package/dist/components/order-daily-overview/table-view/TableStyle.d.ts +4 -4
- package/dist/components/order-view/fakedata.d.ts +1 -1
- package/dist/components/order-view/order-actions/Dropdown.d.ts +6 -2
- package/dist/components/order-view/order-actions/actions/confirm-order/customer-info/ContactWith.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/confirm-order/tables/NotesTable.d.ts +1 -1
- package/dist/components/order-view/order-actions/actions/confirm-order/tables/ProductTable.d.ts +1 -1
- package/dist/components/order-view/order-actions/actions/confirm-order/tables/ReminderStyles.d.ts +9 -0
- package/dist/components/order-view/order-actions/store.d.ts +34 -1
- package/dist/components/order-view/order-actions/types.d.ts +5 -0
- package/dist/components/order-view/store.d.ts +1 -0
- package/dist/components/order-view/types.d.ts +5 -2
- package/dist/dms-client-return.cjs.development.js +2371 -1678
- 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 +2374 -1681
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/assets/icons/DustbinIcon.tsx +20 -0
- package/src/common/modals/order-action-modal/OrderActionModal.tsx +4 -2
- package/src/components/order-daily-overview/header-filters/filterStore.ts +19 -18
- package/src/components/order-daily-overview/header-filters/overViewFilter.ts +80 -0
- package/src/components/order-daily-overview/index.tsx +27 -33
- package/src/components/order-daily-overview/return-after-table/ReturnAfterTable.tsx +47 -5
- package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +9 -5
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.ts +1 -1
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx +2 -2
- package/src/components/order-daily-overview/return-order-table/ReturnTable.tsx +25 -1
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +29 -11
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/returnstyles.ts +1 -0
- package/src/components/order-daily-overview/store/store.ts +11 -1
- package/src/components/order-daily-overview/table-view/Pagination.tsx +2 -1
- package/src/components/order-daily-overview/table-view/ReturnPagination.tsx +136 -0
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/OptionsDropDown.tsx +26 -12
- package/src/components/order-view/details-filters/right-side-filters/Details.tsx +8 -1
- package/src/components/order-view/fakedata.ts +5 -9
- package/src/components/order-view/general-information/dropdowns/BjsMenu.tsx +15 -4
- package/src/components/order-view/general-information/dropdowns/Print.tsx +79 -39
- package/src/components/order-view/general-information/dropdowns/index.tsx +0 -13
- package/src/components/order-view/general-information/index.tsx +3 -19
- package/src/components/order-view/generic-table/AuditLogs.tsx +7 -5
- package/src/components/order-view/index.tsx +1 -2
- package/src/components/order-view/modalsPopup/ModalManager.tsx +45 -199
- package/src/components/order-view/notes/AddNote.tsx +4 -14
- package/src/components/order-view/notes/index.tsx +8 -13
- package/src/components/order-view/order-actions/Dropdown.tsx +8 -3
- package/src/components/order-view/order-actions/actions/cancel-order/index.tsx +146 -12
- package/src/components/order-view/order-actions/actions/charge-log/index.tsx +126 -79
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ActionDropdown.tsx +21 -9
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactMobile.tsx +64 -1
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactPhone.tsx +67 -1
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactTypeDropdown.tsx +19 -7
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactWith.tsx +28 -0
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactWork.tsx +65 -1
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/DeliveryDate.tsx +40 -3
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/EmailAddress.tsx +47 -2
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/TimedServiceDropdown.tsx +38 -9
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/index.tsx +4 -1
- package/src/components/order-view/order-actions/actions/confirm-order/index.tsx +196 -6
- package/src/components/order-view/order-actions/actions/confirm-order/slot-and-instructions/index.tsx +5 -1
- package/src/components/order-view/order-actions/actions/confirm-order/tables/NotesTable.tsx +121 -20
- package/src/components/order-view/order-actions/actions/confirm-order/tables/ProductTable.tsx +54 -32
- package/src/components/order-view/order-actions/actions/confirm-order/tables/ReminderStyles.tsx +289 -0
- package/src/components/order-view/order-actions/actions/create-task-reminder/CreateReminderModal.tsx +41 -8
- package/src/components/order-view/order-actions/actions/create-task-reminder/index.tsx +11 -83
- package/src/components/order-view/order-actions/actions/hold-order/HoldOrderModal.tsx +61 -14
- package/src/components/order-view/order-actions/actions/release-order/ReleaseOrder.tsx +93 -25
- package/src/components/order-view/order-actions/actions/split-order/SplitOrderTable.tsx +102 -247
- package/src/components/order-view/order-actions/actions/split-order/index.tsx +57 -9
- package/src/components/order-view/order-actions/index.tsx +7 -2
- package/src/components/order-view/order-actions/store.ts +45 -0
- package/src/components/order-view/order-actions/types.ts +5 -0
- package/src/components/order-view/order-details/expanded-content/footer/index.tsx +15 -12
- package/src/components/order-view/store.ts +7 -0
- package/src/components/order-view/types.ts +5 -2
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
selectedTabKeyAtom,
|
|
8
8
|
useCreateOrderProducts,
|
|
9
9
|
useDeleteProdsID,
|
|
10
|
+
usefetchAgain,
|
|
11
|
+
// usefetchAgain,
|
|
10
12
|
useOrderId,
|
|
11
13
|
useProductDetails,
|
|
12
14
|
useRecieveOrderProducts,
|
|
@@ -23,13 +25,14 @@ import { ApiResponse } from '../types';
|
|
|
23
25
|
import CreateReturnModal from './CreateReturnModal';
|
|
24
26
|
import {
|
|
25
27
|
useFinalPayload,
|
|
26
|
-
useGroupedPayload,
|
|
28
|
+
// useGroupedPayload,
|
|
27
29
|
useNewReturnPayload,
|
|
28
30
|
usePostLoading,
|
|
29
31
|
useSelectAll,
|
|
30
32
|
useSelectedConfirmLoc,
|
|
31
33
|
useSelectedOrders,
|
|
32
34
|
} from '../../store';
|
|
35
|
+
import { notification } from 'antd';
|
|
33
36
|
|
|
34
37
|
const ModalManager = () => {
|
|
35
38
|
const [popupName, dispatch] = useAtom(countReducerAtom);
|
|
@@ -42,14 +45,14 @@ const ModalManager = () => {
|
|
|
42
45
|
const [selectedProductId] = useAtom(letselectedProductIdAtom);
|
|
43
46
|
const [selectedTab] = useAtom(selectedTabKeyAtom);
|
|
44
47
|
const [, setIsFormValid] = useState(false);
|
|
45
|
-
const [newGrouped
|
|
48
|
+
const [newGrouped] = useFinalPayload();
|
|
46
49
|
const [, SetPostLoading] = usePostLoading();
|
|
47
50
|
const [, setSelectedReturnOrder] = useSelectedOrders();
|
|
48
|
-
const [, setCheck] = useSelectedConfirmLoc();
|
|
51
|
+
const [forDisabledCheck, setCheck] = useSelectedConfirmLoc();
|
|
49
52
|
const [, setNewPayload] = useNewReturnPayload();
|
|
50
|
-
const [, setGrouped] = useGroupedPayload();
|
|
53
|
+
// const [, setGrouped] = useGroupedPayload();
|
|
51
54
|
const [, setSelectAll] = useSelectAll();
|
|
52
|
-
const [
|
|
55
|
+
const [, setCallForFetch] = usefetchAgain();
|
|
53
56
|
|
|
54
57
|
console.log(orderProduct, 'abcabcabcabcabcabcabcabcabcabcabc');
|
|
55
58
|
|
|
@@ -66,113 +69,6 @@ const ModalManager = () => {
|
|
|
66
69
|
setIsFormValid(validateForm());
|
|
67
70
|
}, [selectedRows]);
|
|
68
71
|
|
|
69
|
-
// const payloads: DeleteProds[] = selectedRows?.map(row => ({
|
|
70
|
-
// id: row.id,
|
|
71
|
-
// order_id: row.order_id,
|
|
72
|
-
// }));
|
|
73
|
-
|
|
74
|
-
// const { data: isresponse, setShouldPerformAction: setaction } = useApiHook<{
|
|
75
|
-
// data: ApiResponse[];
|
|
76
|
-
// }>({
|
|
77
|
-
// endpoint: `order/order_products/delete/`,
|
|
78
|
-
// method: 'DELETE',
|
|
79
|
-
// body: payloads,
|
|
80
|
-
// performAction: false,
|
|
81
|
-
// });
|
|
82
|
-
|
|
83
|
-
// Effect to handle API response
|
|
84
|
-
// useEffect(() => {
|
|
85
|
-
// if (isresponse && isresponse?.data) {
|
|
86
|
-
// handleRemoveRow();
|
|
87
|
-
// dispatch({ type: 'close' });
|
|
88
|
-
// }
|
|
89
|
-
// }, [isresponse]);
|
|
90
|
-
// const onDeleteProducts = () => {
|
|
91
|
-
// if (isFormValid) {
|
|
92
|
-
// setaction(true);
|
|
93
|
-
// } else {
|
|
94
|
-
// console.log('Please fill in all required fields before proceeding.');
|
|
95
|
-
// }
|
|
96
|
-
// };
|
|
97
|
-
|
|
98
|
-
// const handleRemoveRow = () => {
|
|
99
|
-
// if (selectedRows.length > 0) {
|
|
100
|
-
// setProductData((prevProductData: any) =>
|
|
101
|
-
// prevProductData.filter(
|
|
102
|
-
// (item: any) => !selectedRows.some(row => row.id === item.id)
|
|
103
|
-
// )
|
|
104
|
-
// );
|
|
105
|
-
// setSelectedRows([]);
|
|
106
|
-
// }
|
|
107
|
-
// };
|
|
108
|
-
|
|
109
|
-
// API block for creating product order
|
|
110
|
-
// const {
|
|
111
|
-
// data: response,
|
|
112
|
-
// setShouldPerformAction: setOrderAction,
|
|
113
|
-
// } = useApiHook<{
|
|
114
|
-
// data: ApiResponse[];
|
|
115
|
-
// }>({
|
|
116
|
-
// endpoint: `order/order_products/create/`,
|
|
117
|
-
// method: 'POST',
|
|
118
|
-
// body: [orderProduct],
|
|
119
|
-
// performAction: false,
|
|
120
|
-
// });
|
|
121
|
-
|
|
122
|
-
// const validateAddForm = () => {
|
|
123
|
-
// if (!Array.isArray(orderProduct)) return false;
|
|
124
|
-
|
|
125
|
-
// return orderProduct.every(
|
|
126
|
-
// (product: any) =>
|
|
127
|
-
// product.code !== '' &&
|
|
128
|
-
// product.description !== '' &&
|
|
129
|
-
// product.weight !== 0 &&
|
|
130
|
-
// product.cube !== 0 &&
|
|
131
|
-
// product.order_product_type_id !== 0 &&
|
|
132
|
-
// product.sku !== ''
|
|
133
|
-
// );
|
|
134
|
-
// };
|
|
135
|
-
|
|
136
|
-
// useEffect(() => {
|
|
137
|
-
// setAddIsFormValid(validateAddForm());
|
|
138
|
-
// }, [orderProduct]);
|
|
139
|
-
|
|
140
|
-
// const onAddOrderProduct = () => {
|
|
141
|
-
// if (isAddFormValid) {
|
|
142
|
-
// setOrderProduct((prev: any) =>
|
|
143
|
-
// prev.map((product: any) => ({
|
|
144
|
-
// ...product,
|
|
145
|
-
// order_id: orderId,
|
|
146
|
-
// }))
|
|
147
|
-
// );
|
|
148
|
-
// setOrderAction(true);
|
|
149
|
-
// } else {
|
|
150
|
-
// console.log('Please fill in all required fields before proceeding.');
|
|
151
|
-
// }
|
|
152
|
-
// };
|
|
153
|
-
|
|
154
|
-
// useEffect(() => {
|
|
155
|
-
// if (response && response?.data) {
|
|
156
|
-
// dispatch({ type: 'close' });
|
|
157
|
-
// }
|
|
158
|
-
// }, [response]);
|
|
159
|
-
|
|
160
|
-
// const [isAddFormValid, setAddIsFormValid] = useState(false);
|
|
161
|
-
|
|
162
|
-
// const AddMore = () => {
|
|
163
|
-
// setOrderProduct((prevProducts: any) => [
|
|
164
|
-
// ...prevProducts,
|
|
165
|
-
// {
|
|
166
|
-
// code: '',
|
|
167
|
-
// description: '',
|
|
168
|
-
// sku: '',
|
|
169
|
-
// weight: '',
|
|
170
|
-
// cube: '',
|
|
171
|
-
// order_product_type_id: '',
|
|
172
|
-
// },
|
|
173
|
-
// ]);
|
|
174
|
-
// };
|
|
175
|
-
|
|
176
72
|
// api block for the create product order
|
|
177
73
|
const {
|
|
178
74
|
data: actionResponse,
|
|
@@ -205,15 +101,6 @@ const ModalManager = () => {
|
|
|
205
101
|
performAction: false,
|
|
206
102
|
});
|
|
207
103
|
|
|
208
|
-
// const onUnrecieveProductOrder = () => {
|
|
209
|
-
// setUnRecieve((prev: any) => ({
|
|
210
|
-
// ...prev,
|
|
211
|
-
// order_id: orderId,
|
|
212
|
-
// id: selectedProductId,
|
|
213
|
-
// }));
|
|
214
|
-
// setUnrecieveaction(true);
|
|
215
|
-
// };
|
|
216
|
-
|
|
217
104
|
const onSubmit = () => {
|
|
218
105
|
if (selectedTab === '1') {
|
|
219
106
|
setUpdateOrderProduct((prev: any) => ({
|
|
@@ -242,11 +129,13 @@ const ModalManager = () => {
|
|
|
242
129
|
}
|
|
243
130
|
}, [updateResponse]);
|
|
244
131
|
|
|
245
|
-
//Confirm return popup
|
|
132
|
+
// Confirm return popup
|
|
246
133
|
const {
|
|
247
134
|
data: response,
|
|
248
135
|
setShouldPerformAction,
|
|
249
136
|
loading: confirmLoading,
|
|
137
|
+
error,
|
|
138
|
+
setError,
|
|
250
139
|
} = useApiHook<{
|
|
251
140
|
data: ApiResponse[];
|
|
252
141
|
}>({
|
|
@@ -255,34 +144,48 @@ const ModalManager = () => {
|
|
|
255
144
|
body: newGrouped,
|
|
256
145
|
performAction: false,
|
|
257
146
|
});
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
console.log(response, 'response');
|
|
147
|
+
console.log(response, 'data'),
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
SetPostLoading(confirmLoading);
|
|
150
|
+
}, [confirmLoading]);
|
|
264
151
|
|
|
265
152
|
const handleConfirmReturn = () => {
|
|
266
|
-
|
|
267
|
-
setStateCheck(!forCheck);
|
|
153
|
+
// setStateCheck(!forCheck);
|
|
268
154
|
if (newGrouped.length > 0) {
|
|
269
155
|
setShouldPerformAction(true);
|
|
270
|
-
|
|
271
|
-
setShouldPerformAction(false);
|
|
156
|
+
setCallForFetch(true);
|
|
272
157
|
}
|
|
273
158
|
dispatch({ type: 'close' });
|
|
274
159
|
};
|
|
275
160
|
|
|
276
161
|
useEffect(() => {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
162
|
+
console.log(error, 'error');
|
|
163
|
+
//@ts-ignore
|
|
164
|
+
if (!confirmLoading) {
|
|
165
|
+
if (error && error.errorStatus !== 200) {
|
|
166
|
+
console.log(error, 'errorINsodeofIFFFFFF');
|
|
167
|
+
notification.error({
|
|
168
|
+
message: error.errorStatus || 'Error',
|
|
169
|
+
description: error.errorMessage || 'Something went wrong',
|
|
170
|
+
});
|
|
171
|
+
setError(null);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
//@ts-ignore
|
|
175
|
+
if (error === null && response && response?.code === 200) {
|
|
176
|
+
notification.success({
|
|
177
|
+
message: 'Success',
|
|
178
|
+
// @ts-ignore
|
|
179
|
+
description: `${response?.message}`,
|
|
180
|
+
});
|
|
181
|
+
dispatch({ type: 'close' });
|
|
182
|
+
setSelectedReturnOrder([]);
|
|
183
|
+
setCheck([]);
|
|
184
|
+
setNewPayload([]);
|
|
185
|
+
setSelectAll(false);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}, [confirmLoading]); //forCheck
|
|
286
189
|
|
|
287
190
|
return (
|
|
288
191
|
<>
|
|
@@ -301,7 +204,7 @@ const ModalManager = () => {
|
|
|
301
204
|
btnStyle: 'rounded',
|
|
302
205
|
onClick: handleConfirmReturn,
|
|
303
206
|
type: 'button',
|
|
304
|
-
|
|
207
|
+
disabled: forDisabledCheck.length === 0,
|
|
305
208
|
},
|
|
306
209
|
],
|
|
307
210
|
|
|
@@ -312,63 +215,6 @@ const ModalManager = () => {
|
|
|
312
215
|
classNameAdd={'globalPopup'}
|
|
313
216
|
/>
|
|
314
217
|
)}
|
|
315
|
-
|
|
316
|
-
{/* {popupName?.state === 'deleteProduct' && (
|
|
317
|
-
<AntModal
|
|
318
|
-
openStatus={popupName?.state === 'deleteProduct'}
|
|
319
|
-
closeModal={closeModal}
|
|
320
|
-
PopupHeader={{
|
|
321
|
-
heading: 'Delete Product(s) From Order',
|
|
322
|
-
subHeading: 'TOM LEWIS, CW11 4ZP',
|
|
323
|
-
}}
|
|
324
|
-
PopupFooter={{
|
|
325
|
-
btns: [
|
|
326
|
-
{
|
|
327
|
-
name: 'CONFIRM DELETE',
|
|
328
|
-
type: 'button',
|
|
329
|
-
btnStyle: 'rounded',
|
|
330
|
-
onClick: onDeleteProducts,
|
|
331
|
-
disabled: !isFormValid,
|
|
332
|
-
},
|
|
333
|
-
],
|
|
334
|
-
btnAlign: 'justifyEnd',
|
|
335
|
-
}}
|
|
336
|
-
BodyComponent={DeleteProduct}
|
|
337
|
-
width={1104}
|
|
338
|
-
classNameAdd={'globalPopup'}
|
|
339
|
-
/>
|
|
340
|
-
)} */}
|
|
341
|
-
|
|
342
|
-
{/* {popupName?.state === 'addProduct' && (
|
|
343
|
-
<AntModal
|
|
344
|
-
openStatus={popupName?.state === 'addProduct'}
|
|
345
|
-
closeModal={closeModal}
|
|
346
|
-
PopupHeader={{
|
|
347
|
-
heading: 'Add Product(s) to Order',
|
|
348
|
-
subHeading: 'Full Stock Control',
|
|
349
|
-
}}
|
|
350
|
-
PopupFooter={{
|
|
351
|
-
btns: [
|
|
352
|
-
{
|
|
353
|
-
name: 'Add More Product',
|
|
354
|
-
btnStyle: 'normalLink',
|
|
355
|
-
icon: 'addIcon',
|
|
356
|
-
onClick: AddMore,
|
|
357
|
-
},
|
|
358
|
-
{
|
|
359
|
-
name: 'Save Details',
|
|
360
|
-
btnStyle: 'rounded',
|
|
361
|
-
onClick: onAddOrderProduct,
|
|
362
|
-
disabled: !isAddFormValid,
|
|
363
|
-
},
|
|
364
|
-
],
|
|
365
|
-
btnAlign: 'justifySpaceBetween',
|
|
366
|
-
}}
|
|
367
|
-
BodyComponent={AddProduct}
|
|
368
|
-
width={1104}
|
|
369
|
-
classNameAdd={'globalPopup'}
|
|
370
|
-
/>
|
|
371
|
-
)} */}
|
|
372
218
|
{popupName?.state === 'qclog' && (
|
|
373
219
|
<AntModal
|
|
374
220
|
openStatus={popupName?.state === 'qclog'}
|
|
@@ -9,16 +9,10 @@ import styled from 'styled-components';
|
|
|
9
9
|
import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
|
|
10
10
|
import { getCookie } from '../utils';
|
|
11
11
|
import { useLocation } from 'react-router-dom';
|
|
12
|
-
import {
|
|
13
|
-
useCallAPi,
|
|
14
|
-
usemoduleIds,
|
|
15
|
-
UseNotesLoading,
|
|
16
|
-
useOrderId,
|
|
17
|
-
} from '../store';
|
|
12
|
+
import { usemoduleIds, UseNotesLoading, useOrderId } from '../store';
|
|
18
13
|
import { notification } from 'antd';
|
|
19
14
|
|
|
20
15
|
function AddNote() {
|
|
21
|
-
const [, setNoteLoadingStore] = UseNotesLoading();
|
|
22
16
|
const [noteText, setNoteText] = useState('');
|
|
23
17
|
const [orderId] = useOrderId();
|
|
24
18
|
|
|
@@ -26,10 +20,11 @@ function AddNote() {
|
|
|
26
20
|
const pathname = location.pathname;
|
|
27
21
|
const orderIdLocaation = pathname.split('/')[1];
|
|
28
22
|
|
|
29
|
-
const [, CallAPi] = useCallAPi();
|
|
30
23
|
const ssoToken = getCookie('id_token');
|
|
31
24
|
const [moduleIds] = usemoduleIds();
|
|
32
25
|
|
|
26
|
+
const [NoteLoadingStore, setNoteLoadingStore] = UseNotesLoading();
|
|
27
|
+
|
|
33
28
|
// Save New Note
|
|
34
29
|
|
|
35
30
|
const [notificationData, setNotificationData] = useState<{
|
|
@@ -39,9 +34,6 @@ function AddNote() {
|
|
|
39
34
|
} | null>(null);
|
|
40
35
|
|
|
41
36
|
const saveNote = async () => {
|
|
42
|
-
setNoteLoadingStore(true);
|
|
43
|
-
CallAPi(false);
|
|
44
|
-
|
|
45
37
|
if (!noteText) return;
|
|
46
38
|
const endpoint = `${getBaseEndpoint()}/audit_logs/orders/`;
|
|
47
39
|
const payload = {
|
|
@@ -78,10 +70,8 @@ function AddNote() {
|
|
|
78
70
|
message: 'Success',
|
|
79
71
|
description: message || 'Successfully Created Note.',
|
|
80
72
|
});
|
|
81
|
-
setNoteLoadingStore(
|
|
73
|
+
setNoteLoadingStore(!NoteLoadingStore);
|
|
82
74
|
setNoteText('');
|
|
83
|
-
// setNoteLoadingStore(false);
|
|
84
|
-
CallAPi(true);
|
|
85
75
|
} else if (error) {
|
|
86
76
|
// Error: Set error notification
|
|
87
77
|
setNotificationData({
|
|
@@ -5,7 +5,7 @@ import AuditLogs from './logs';
|
|
|
5
5
|
import { useApiHook } from '@bjsdistribution/dms-component-library';
|
|
6
6
|
import {
|
|
7
7
|
SeteauditLogToggle,
|
|
8
|
-
useCallAPi,
|
|
8
|
+
// useCallAPi,
|
|
9
9
|
usegetNotes,
|
|
10
10
|
usemoduleIds,
|
|
11
11
|
UseNotesLoading,
|
|
@@ -18,9 +18,9 @@ function Notes() {
|
|
|
18
18
|
const location = useLocation();
|
|
19
19
|
const pathname = location.pathname;
|
|
20
20
|
const orderIdLocaation = pathname.split('/')[1];
|
|
21
|
-
const [
|
|
21
|
+
const [apiBaseLoading] = UseNotesLoading();
|
|
22
22
|
const [, setNotes] = usegetNotes();
|
|
23
|
-
const [loderStatus] = useCallAPi();
|
|
23
|
+
// const [loderStatus] = useCallAPi();
|
|
24
24
|
const [auditState] = SeteauditLogToggle();
|
|
25
25
|
|
|
26
26
|
// Fetch module IDs
|
|
@@ -64,10 +64,10 @@ function Notes() {
|
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
useEffect(() => {
|
|
67
|
-
|
|
67
|
+
let combinedArray = [];
|
|
68
68
|
|
|
69
69
|
if (moduleIds) {
|
|
70
|
-
setShouldPerformAction(
|
|
70
|
+
setShouldPerformAction(true);
|
|
71
71
|
}
|
|
72
72
|
if (!NotesLoading && NotesData?.data) {
|
|
73
73
|
const updatedData = NotesData?.data
|
|
@@ -75,19 +75,14 @@ function Notes() {
|
|
|
75
75
|
.map((item: any) => [item['ORDER-NOTE'], item['ORDER']])
|
|
76
76
|
.flat()
|
|
77
77
|
.filter(Boolean);
|
|
78
|
-
|
|
78
|
+
combinedArray = updatedData.flat();
|
|
79
79
|
combinedArray.sort(
|
|
80
80
|
(a: any, b: any) =>
|
|
81
81
|
new Date(b.created_at).getTime() - new Date(a.created_at).getTime()
|
|
82
82
|
);
|
|
83
|
-
setNotes(combinedArray);
|
|
84
|
-
setNotes(combinedArray);
|
|
85
|
-
setNoteLoadingStore(NotesLoading);
|
|
86
|
-
loderStatus
|
|
87
|
-
? setShouldPerformAction(true)
|
|
88
|
-
: setShouldPerformAction(false);
|
|
89
83
|
}
|
|
90
|
-
|
|
84
|
+
setNotes({ data: combinedArray, loading: NotesLoading });
|
|
85
|
+
}, [moduleIds, NotesLoading, auditState, apiBaseLoading]);
|
|
91
86
|
|
|
92
87
|
return (
|
|
93
88
|
<Container>
|
|
@@ -9,9 +9,13 @@ interface ActionsDropdownProps {
|
|
|
9
9
|
label: string;
|
|
10
10
|
placeholder: string;
|
|
11
11
|
options: StandardOptionsType[];
|
|
12
|
-
onSelect: () => void;
|
|
13
|
-
onSearch
|
|
12
|
+
onSelect: (value: string) => void;
|
|
13
|
+
onSearch?: () => void;
|
|
14
14
|
className?: string;
|
|
15
|
+
value?: string;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
defaultValue?: any;
|
|
18
|
+
onChange?: any;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
function OrderActionsDropdown(props: ActionsDropdownProps) {
|
|
@@ -22,12 +26,13 @@ function OrderActionsDropdown(props: ActionsDropdownProps) {
|
|
|
22
26
|
options={props.options}
|
|
23
27
|
placeholder={props.placeholder}
|
|
24
28
|
onChange={props.onSelect}
|
|
25
|
-
disabled={
|
|
29
|
+
disabled={props.disabled}
|
|
26
30
|
style={{ width: '100%' }}
|
|
27
31
|
onSearch={props.onSearch}
|
|
28
32
|
showSearch={true}
|
|
29
33
|
popupClassName={'dropDownStyle'}
|
|
30
34
|
selectWrapperClass={'rounded'}
|
|
35
|
+
defaultValue={props.value}
|
|
31
36
|
/>
|
|
32
37
|
</Container>
|
|
33
38
|
);
|
|
@@ -1,48 +1,182 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
3
|
import OrderActionModal from '../../../../../common/modals/order-action-modal/OrderActionModal';
|
|
4
|
-
import CancelationNote from './CancelationNote';
|
|
5
|
-
import CancelationReason from './CancelationReason';
|
|
6
4
|
import ReturnAction from './ReturnAction';
|
|
7
5
|
import ReturnReason from './ReturnReason';
|
|
8
|
-
import CancelOrderTable from './CancelOrderTable';
|
|
9
|
-
import {
|
|
6
|
+
// import CancelOrderTable from './CancelOrderTable';
|
|
7
|
+
import {
|
|
8
|
+
useCurrentAction,
|
|
9
|
+
useCustomerInfo,
|
|
10
|
+
useOrderDetails,
|
|
11
|
+
useOrderId,
|
|
12
|
+
useOrderStaticData,
|
|
13
|
+
usePrevOrderDetails,
|
|
14
|
+
} from '../../../store';
|
|
15
|
+
import OrderActionsDropdown from '../../Dropdown';
|
|
16
|
+
import { TextArea, useApiHook } from '@bjsdistribution/dms-component-library';
|
|
17
|
+
import { ApiResponse, OrdersType } from '../../../types';
|
|
18
|
+
import { useLoading } from '../../../../order-daily-overview/store/store';
|
|
19
|
+
import { notification } from 'antd';
|
|
10
20
|
|
|
11
21
|
function CancelOrder() {
|
|
22
|
+
const [orderId] = useOrderId();
|
|
23
|
+
const [, setOrderDetails] = useOrderDetails();
|
|
24
|
+
const [, setPrevOrderDetails] = usePrevOrderDetails();
|
|
25
|
+
const [, setLoading] = useLoading();
|
|
12
26
|
const [, setCurrentAction] = useCurrentAction();
|
|
27
|
+
const [customerInfo] = useCustomerInfo();
|
|
28
|
+
const infoText = `${customerInfo?.recipient_name}, ${customerInfo?.postcode}`;
|
|
29
|
+
|
|
30
|
+
const [orderStaticData] = useOrderStaticData();
|
|
31
|
+
|
|
32
|
+
const [cancelReason, setCancelReason] = useState<string | undefined>(
|
|
33
|
+
undefined
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const [cancelNotes, setCancelNotes] = useState<string>('');
|
|
37
|
+
|
|
38
|
+
const cancelReasonOptions = orderStaticData?.cancellation_reasons?.map(
|
|
39
|
+
(item: any) => {
|
|
40
|
+
return {
|
|
41
|
+
label: item?.reason,
|
|
42
|
+
value: item?.reason,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const {
|
|
48
|
+
data: response,
|
|
49
|
+
setShouldPerformAction: setPerformAction,
|
|
50
|
+
} = useApiHook<{
|
|
51
|
+
data: ApiResponse[];
|
|
52
|
+
}>({
|
|
53
|
+
endpoint: `orders/${orderId}/cancel/?cancelled_reason=${cancelReason}&cancelled_notes=${cancelNotes}`,
|
|
54
|
+
method: 'POST',
|
|
55
|
+
performAction: false,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const { data: fetchedData, loading, setShouldPerformAction } = useApiHook<{
|
|
59
|
+
data: OrdersType[];
|
|
60
|
+
}>({
|
|
61
|
+
endpoint: `orders/${orderId}`,
|
|
62
|
+
method: 'GET',
|
|
63
|
+
performAction: false,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
setLoading(loading);
|
|
68
|
+
if (fetchedData && fetchedData.data) {
|
|
69
|
+
const requiredData = fetchedData?.data;
|
|
70
|
+
setOrderDetails(requiredData[0]);
|
|
71
|
+
setPrevOrderDetails(requiredData[0]);
|
|
72
|
+
setCurrentAction(undefined);
|
|
73
|
+
}
|
|
74
|
+
if (
|
|
75
|
+
(fetchedData && fetchedData?.data === null) ||
|
|
76
|
+
fetchedData?.data?.length === 0
|
|
77
|
+
) {
|
|
78
|
+
setCurrentAction(undefined);
|
|
79
|
+
}
|
|
80
|
+
}, [loading]);
|
|
81
|
+
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (response) {
|
|
84
|
+
//@ts-ignore
|
|
85
|
+
if (response?.data && response?.code === 200) {
|
|
86
|
+
setShouldPerformAction(true);
|
|
87
|
+
} else {
|
|
88
|
+
// alert(response?.error_traceback);
|
|
89
|
+
notification.error({
|
|
90
|
+
message: 'Error',
|
|
91
|
+
description:
|
|
92
|
+
//@ts-ignore
|
|
93
|
+
response?.error_traceback ||
|
|
94
|
+
'An error has occurred. Please try again later.',
|
|
95
|
+
});
|
|
96
|
+
setCurrentAction(undefined);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}, [response]);
|
|
13
100
|
|
|
14
101
|
const onClose = () => {
|
|
15
102
|
setCurrentAction(undefined);
|
|
16
103
|
};
|
|
104
|
+
|
|
105
|
+
const onSelectCancelReason = (value: string) => {
|
|
106
|
+
setCancelReason(value);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const onChangeNotes = (event: any) => {
|
|
110
|
+
setCancelNotes(event.target.value);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const onSubmitCancel = () => {
|
|
114
|
+
if (orderId) {
|
|
115
|
+
setPerformAction(true);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const showSubmitBtn = cancelReason !== undefined && cancelNotes?.length > 0;
|
|
120
|
+
|
|
17
121
|
return (
|
|
18
122
|
<OrderActionModal
|
|
19
123
|
headerTitle="Cancel Order"
|
|
20
124
|
showAdditionalInfo
|
|
21
|
-
infoText=
|
|
125
|
+
infoText={infoText}
|
|
22
126
|
onCloseHeader={onClose}
|
|
23
|
-
onSubmit={
|
|
127
|
+
onSubmit={onSubmitCancel}
|
|
128
|
+
submitBtnTitle="Save Details"
|
|
129
|
+
isSubmitDisabled={!showSubmitBtn}
|
|
24
130
|
>
|
|
25
131
|
<ContentContainer>
|
|
26
132
|
<Top>
|
|
27
133
|
<TopLeft>
|
|
28
|
-
<
|
|
134
|
+
<OrderActionsDropdown
|
|
135
|
+
label="Cancelation Reason"
|
|
136
|
+
placeholder="Select Cancelation Reason"
|
|
137
|
+
options={cancelReasonOptions || []}
|
|
138
|
+
onSelect={onSelectCancelReason}
|
|
139
|
+
value={cancelReason}
|
|
140
|
+
/>
|
|
29
141
|
<Wrapper>
|
|
30
142
|
<ReturnAction />
|
|
31
143
|
<ReturnReason />
|
|
32
144
|
</Wrapper>
|
|
33
145
|
</TopLeft>
|
|
34
146
|
<TopRight>
|
|
35
|
-
<
|
|
147
|
+
<Container>
|
|
148
|
+
<Label>Cancelation Note</Label>
|
|
149
|
+
<TextArea
|
|
150
|
+
rows={5}
|
|
151
|
+
onChange={onChangeNotes}
|
|
152
|
+
value={cancelNotes}
|
|
153
|
+
placeholder="Reason for Cancel Order"
|
|
154
|
+
/>
|
|
155
|
+
</Container>
|
|
36
156
|
</TopRight>
|
|
37
157
|
</Top>
|
|
38
|
-
<Bottom>
|
|
158
|
+
{/* <Bottom>
|
|
39
159
|
<CancelOrderTable />
|
|
40
|
-
</Bottom>
|
|
160
|
+
</Bottom> */}
|
|
41
161
|
</ContentContainer>
|
|
42
162
|
</OrderActionModal>
|
|
43
163
|
);
|
|
44
164
|
}
|
|
45
165
|
|
|
166
|
+
const Label = styled.label`
|
|
167
|
+
color: #6a7378;
|
|
168
|
+
font-family: 'Lato', sans-serif;
|
|
169
|
+
font-size: 14px;
|
|
170
|
+
font-style: normal;
|
|
171
|
+
font-weight: 500;
|
|
172
|
+
`;
|
|
173
|
+
|
|
174
|
+
const Container = styled.div`
|
|
175
|
+
display: flex;
|
|
176
|
+
flex-direction: column;
|
|
177
|
+
gap: 6px;
|
|
178
|
+
`;
|
|
179
|
+
|
|
46
180
|
const Wrapper = styled.div`
|
|
47
181
|
display: flex;
|
|
48
182
|
gap: 15px;
|
|
@@ -69,7 +203,7 @@ const Top = styled.div`
|
|
|
69
203
|
width: 100%;
|
|
70
204
|
`;
|
|
71
205
|
|
|
72
|
-
const Bottom = styled.div``;
|
|
206
|
+
// const Bottom = styled.div``;
|
|
73
207
|
|
|
74
208
|
const ContentContainer = styled.div`
|
|
75
209
|
display: flex;
|