@bjsdistribution/dms-client-return 0.0.11 → 0.0.13
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/css/TableStyle.d.ts +13 -30
- 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/order-view/store.d.ts +77 -28
- package/dist/components/order-view/types.d.ts +61 -11
- package/dist/components/order-view/utils.d.ts +4 -0
- package/dist/components/store.d.ts +6 -1
- package/dist/dms-client-return.cjs.development.js +1777 -1078
- 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 +1780 -1081
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/common/expand-collapse/index.tsx +4 -4
- package/src/components/order-daily-overview/common/css/TableStyle.tsx +42 -342
- 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 +3 -3
- package/src/components/order-daily-overview/return-after-table/ReturnAfterTable.tsx +2 -2
- 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/ReturnTable.tsx +2 -2
- 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 +5 -2
- package/src/components/order-daily-overview/table/table-data/styles.ts +1 -1
- package/src/components/order-daily-overview/table-view/Pagination.tsx +15 -14
- package/src/components/order-view/DynamicTable.tsx +12 -3
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/{PrintDropDown.tsx → PrintDropDownReturn.tsx} +4 -4
- package/src/components/order-view/flags-action-modal/Actions.tsx +1 -2
- package/src/components/order-view/general-information/Status.tsx +13 -17
- package/src/components/order-view/generic-table/AuditLogs.tsx +81 -19
- package/src/components/order-view/index.tsx +192 -192
- package/src/components/order-view/modalsPopup/CreateReturnModal.tsx +74 -36
- package/src/components/order-view/modalsPopup/ModalManager.tsx +49 -14
- package/src/components/order-view/modalsPopup/ProductAction.tsx +1 -1
- package/src/components/order-view/notes/AddNote.tsx +2 -3
- package/src/components/order-view/notes/index.tsx +9 -22
- package/src/components/order-view/order-details/expanded-content/footer/index.tsx +90 -73
- package/src/components/order-view/order-details/expanded-content/instruction-section/DeliveryInstructions.tsx +2 -9
- package/src/components/order-view/order-details/expanded-content/orders-section/Droptime.tsx +2 -10
- package/src/components/order-view/order-details/expanded-content/orders-section/VehicleType.tsx +16 -15
- package/src/components/order-view/order-details/expanded-content/services-section/AssemblyType.tsx +88 -15
- package/src/components/order-view/order-details/expanded-content/services-section/DeliveryPoint.tsx +1 -13
- package/src/components/order-view/order-details/expanded-content/services-section/OrderServices.tsx +141 -16
- package/src/components/order-view/order-details/expanded-content/services-section/ServiceType.tsx +1 -13
- package/src/components/order-view/order-details/expanded-content/services-section/TimedService.tsx +19 -18
- package/src/components/order-view/products-info/expanded-content/products/index.tsx +2 -2
- package/src/components/order-view/return-client-products/ProductTable.tsx +1 -1
- package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +79 -70
- package/src/components/order-view/return-client-products/product-table-footer/ProductDetailsFooter.tsx +5 -5
- package/src/components/order-view/store.ts +215 -53
- package/src/components/order-view/system-event-logs/expanded-content/index.tsx +6 -10
- package/src/components/order-view/toolbox-resources/expanded-content/index.tsx +68 -6
- package/src/components/order-view/types.ts +89 -33
- package/src/components/order-view/utils.ts +20 -17
- package/src/components/store.ts +35 -0
- package/src/index.tsx +13 -9
|
@@ -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
|
|
|
@@ -3,7 +3,7 @@ import { AntModal, useApiHook } from '@bjsdistribution/dms-component-library';
|
|
|
3
3
|
import { useAtom } from 'jotai';
|
|
4
4
|
import {
|
|
5
5
|
countReducerAtom,
|
|
6
|
-
|
|
6
|
+
letselectedProductIdAtom,
|
|
7
7
|
selectedTabKeyAtom,
|
|
8
8
|
useCreateOrderProducts,
|
|
9
9
|
useDeleteProdsID,
|
|
@@ -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();
|
|
@@ -30,10 +39,16 @@ const ModalManager = () => {
|
|
|
30
39
|
const [selectedRows] = useDeleteProdsID();
|
|
31
40
|
const [unRecieve, setUnRecieve] = useRecieveOrderProducts();
|
|
32
41
|
const [updateOrderProduct, setUpdateOrderProduct] = useUpdateOrderProducts();
|
|
33
|
-
const [selectedProductId] = useAtom(
|
|
42
|
+
const [selectedProductId] = useAtom(letselectedProductIdAtom);
|
|
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
|
|
|
@@ -2,10 +2,10 @@ import React from 'react';
|
|
|
2
2
|
import { Tabs } from 'antd';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { useAtom } from 'jotai';
|
|
5
|
-
import { selectedTabKeyAtom } from '../store';
|
|
6
5
|
import QCLogs from './qclogs';
|
|
7
6
|
import UpdateProduct from './UpdateProducts';
|
|
8
7
|
import UnReceiveProduct from './UnReceiveProduct';
|
|
8
|
+
import { selectedTabKeyAtom } from '../store';
|
|
9
9
|
|
|
10
10
|
const ProductAction = () => {
|
|
11
11
|
const [, setSelectedTabKey] = useAtom(selectedTabKeyAtom);
|
|
@@ -26,10 +26,8 @@ function AddNote() {
|
|
|
26
26
|
const pathname = location.pathname;
|
|
27
27
|
const orderIdLocaation = pathname.split('/')[1];
|
|
28
28
|
|
|
29
|
-
// const [note, setNote] = useState('');
|
|
30
29
|
const [, CallAPi] = useCallAPi();
|
|
31
30
|
const ssoToken = getCookie('id_token');
|
|
32
|
-
|
|
33
31
|
const [moduleIds] = usemoduleIds();
|
|
34
32
|
|
|
35
33
|
// Save New Note
|
|
@@ -56,6 +54,7 @@ function AddNote() {
|
|
|
56
54
|
action: 'create',
|
|
57
55
|
description: noteText,
|
|
58
56
|
data_dump: '{}',
|
|
57
|
+
manual: 1,
|
|
59
58
|
},
|
|
60
59
|
],
|
|
61
60
|
};
|
|
@@ -81,7 +80,7 @@ function AddNote() {
|
|
|
81
80
|
});
|
|
82
81
|
setNoteLoadingStore(true);
|
|
83
82
|
setNoteText('');
|
|
84
|
-
setNoteLoadingStore(false);
|
|
83
|
+
// setNoteLoadingStore(false);
|
|
85
84
|
CallAPi(true);
|
|
86
85
|
} else if (error) {
|
|
87
86
|
// Error: Set error notification
|
|
@@ -4,6 +4,7 @@ import AddNote from './AddNote';
|
|
|
4
4
|
import AuditLogs from './logs';
|
|
5
5
|
import { useApiHook } from '@bjsdistribution/dms-component-library';
|
|
6
6
|
import {
|
|
7
|
+
SeteauditLogToggle,
|
|
7
8
|
useCallAPi,
|
|
8
9
|
usegetNotes,
|
|
9
10
|
usemoduleIds,
|
|
@@ -20,9 +21,7 @@ function Notes() {
|
|
|
20
21
|
const [, setNoteLoadingStore] = UseNotesLoading();
|
|
21
22
|
const [, setNotes] = usegetNotes();
|
|
22
23
|
const [loderStatus] = useCallAPi();
|
|
23
|
-
|
|
24
|
-
// Declare `allIds` state to store the comma-separated IDs
|
|
25
|
-
// const [allIds, setAllIds] = useState<string | null>(null);
|
|
24
|
+
const [auditState] = SeteauditLogToggle();
|
|
26
25
|
|
|
27
26
|
// Fetch module IDs
|
|
28
27
|
const { data: fetchedData, loading: apiLoading } = useApiHook<{ data: any }>({
|
|
@@ -44,13 +43,6 @@ function Notes() {
|
|
|
44
43
|
}))
|
|
45
44
|
) || [];
|
|
46
45
|
|
|
47
|
-
// console.log(modules, 'modulesmodules');
|
|
48
|
-
|
|
49
|
-
// const ids = modules?.map((module: any) => module.id).join(',');
|
|
50
|
-
// setAllIds(ids);
|
|
51
|
-
|
|
52
|
-
// console.log(ids, 'allIds');
|
|
53
|
-
|
|
54
46
|
const orderNoteModule = modules?.find(
|
|
55
47
|
(module: any) => module?.name === 'ORDER-NOTE'
|
|
56
48
|
);
|
|
@@ -59,48 +51,43 @@ function Notes() {
|
|
|
59
51
|
}
|
|
60
52
|
}, [apiLoading, fetchedData]);
|
|
61
53
|
|
|
62
|
-
// Fetch Notes Data when `allIds` is available
|
|
63
54
|
const {
|
|
64
55
|
data: NotesData,
|
|
65
56
|
loading: NotesLoading,
|
|
66
57
|
setShouldPerformAction,
|
|
67
58
|
} = useApiHook<{ data: any }>({
|
|
68
|
-
// Use `allIds` in the endpoint if it's set
|
|
69
59
|
endpoint: `audit_logs/?module_id=${
|
|
70
60
|
moduleIds?.parentId
|
|
71
|
-
}&module_object_id=${orderId || orderIdLocaation}
|
|
72
|
-
`,
|
|
61
|
+
}&module_object_id=${orderId || orderIdLocaation}`,
|
|
73
62
|
method: 'GET',
|
|
74
63
|
performAction: false,
|
|
75
64
|
});
|
|
76
65
|
|
|
77
|
-
// &sub_module_ids=${allIds}
|
|
78
|
-
|
|
79
66
|
useEffect(() => {
|
|
80
67
|
setNoteLoadingStore(true);
|
|
68
|
+
|
|
81
69
|
if (moduleIds) {
|
|
82
|
-
|
|
83
|
-
setShouldPerformAction(true);
|
|
70
|
+
setShouldPerformAction(auditState);
|
|
84
71
|
}
|
|
85
72
|
if (!NotesLoading && NotesData?.data) {
|
|
86
73
|
const updatedData = NotesData?.data
|
|
87
|
-
|
|
88
|
-
|
|
74
|
+
.filter((item: any) => item['ORDER-NOTE'] || item['ORDER'])
|
|
75
|
+
.map((item: any) => [item['ORDER-NOTE'], item['ORDER']])
|
|
89
76
|
.flat()
|
|
90
77
|
.filter(Boolean);
|
|
91
|
-
|
|
92
78
|
const combinedArray = updatedData.flat();
|
|
93
79
|
combinedArray.sort(
|
|
94
80
|
(a: any, b: any) =>
|
|
95
81
|
new Date(b.created_at).getTime() - new Date(a.created_at).getTime()
|
|
96
82
|
);
|
|
97
83
|
setNotes(combinedArray);
|
|
84
|
+
setNotes(combinedArray);
|
|
98
85
|
setNoteLoadingStore(NotesLoading);
|
|
99
86
|
loderStatus
|
|
100
87
|
? setShouldPerformAction(true)
|
|
101
88
|
: setShouldPerformAction(false);
|
|
102
89
|
}
|
|
103
|
-
}, [moduleIds, NotesLoading,
|
|
90
|
+
}, [moduleIds, NotesLoading, auditState]);
|
|
104
91
|
|
|
105
92
|
return (
|
|
106
93
|
<Container>
|
|
@@ -2,87 +2,108 @@ import React from 'react';
|
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import AllowTracking from './AllowTracking';
|
|
4
4
|
import { Button } from '@bjsdistribution/dms-component-library';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
import {
|
|
6
|
+
useAtom,
|
|
7
|
+
useOrderDetails,
|
|
8
|
+
usePrevOrderDetails,
|
|
9
|
+
errorAtom,
|
|
10
|
+
useCustomerInfo,
|
|
11
|
+
useLogsCallAPi,
|
|
12
|
+
useApiCalling,
|
|
13
|
+
} from '../../../store';
|
|
14
|
+
import useUpdateOrder from '../../../hooks/useUpdateOrder';
|
|
15
|
+
import { compareOrderDetailsStates, filterObject } from '../../../utils';
|
|
16
|
+
import { OrderServiceType } from '../../../types';
|
|
14
17
|
|
|
15
18
|
function OrderDetailsFooter() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
const [orderDetails, setOrderDetails] = useOrderDetails();
|
|
20
|
+
const [prevOrderDetails, setPrevOrderDetails] = usePrevOrderDetails();
|
|
21
|
+
const [, setCustomerInfo] = useCustomerInfo();
|
|
22
|
+
const updateOrder = useUpdateOrder();
|
|
23
|
+
const [errorState] = useAtom(errorAtom);
|
|
24
|
+
const [, setLogsCallAPi] = useLogsCallAPi();
|
|
25
|
+
const [, setCallApi] = useApiCalling(); //single detail
|
|
20
26
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
const errorFound = () => {
|
|
28
|
+
const isError =
|
|
29
|
+
errorState.w3wError.length > 0 ||
|
|
30
|
+
errorState.emailError.length > 0 ||
|
|
31
|
+
errorState.homeContactError.length > 0 ||
|
|
32
|
+
errorState.workCOntanctError.length > 0 ||
|
|
33
|
+
errorState.mobileError.length > 0 ||
|
|
34
|
+
errorState.postCodeError.length > 0;
|
|
26
35
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
return isError;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const isDifferent = () => {
|
|
40
|
+
const keysToRemovefromOrders = [
|
|
41
|
+
'order_locked',
|
|
42
|
+
'order_communications',
|
|
43
|
+
'updated_at',
|
|
44
|
+
'updated_by',
|
|
45
|
+
'order_services',
|
|
46
|
+
];
|
|
47
|
+
const filteredOrderDetails = filterObject(
|
|
48
|
+
orderDetails,
|
|
49
|
+
keysToRemovefromOrders
|
|
50
|
+
);
|
|
51
|
+
const filteredPrevOrderDetails = filterObject(
|
|
52
|
+
prevOrderDetails,
|
|
53
|
+
keysToRemovefromOrders
|
|
54
|
+
);
|
|
43
55
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
56
|
+
const newOrderServices =
|
|
57
|
+
orderDetails?.order_services?.length > 0 &&
|
|
58
|
+
orderDetails.order_services.sort(
|
|
59
|
+
(a: OrderServiceType, b: OrderServiceType) => a.id! - b.id!
|
|
60
|
+
);
|
|
49
61
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
62
|
+
const prevOrderServices =
|
|
63
|
+
prevOrderDetails?.order_services?.length > 0 &&
|
|
64
|
+
prevOrderDetails.order_services.sort(
|
|
65
|
+
(a: OrderServiceType, b: OrderServiceType) => a.id! - b.id!
|
|
66
|
+
);
|
|
55
67
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
const newOrderServicesSorted = JSON.stringify(newOrderServices);
|
|
69
|
+
const prevOrderServicesSorted = JSON.stringify(prevOrderServices);
|
|
70
|
+
const orderDetailsSorted = JSON.stringify(filteredOrderDetails);
|
|
71
|
+
const prevOrderDetailsSorted = JSON.stringify(filteredPrevOrderDetails);
|
|
72
|
+
const isSame =
|
|
73
|
+
orderDetailsSorted === prevOrderDetailsSorted &&
|
|
74
|
+
newOrderServicesSorted === prevOrderServicesSorted;
|
|
75
|
+
return !isSame;
|
|
76
|
+
};
|
|
65
77
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
78
|
+
const onSave = async () => {
|
|
79
|
+
const payload = compareOrderDetailsStates(prevOrderDetails, orderDetails);
|
|
80
|
+
const response = await updateOrder([payload]);
|
|
69
81
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
82
|
+
setLogsCallAPi(prev => !prev);
|
|
83
|
+
setCallApi(false);
|
|
84
|
+
|
|
85
|
+
if (response && response?.data?.length > 0) {
|
|
86
|
+
setOrderDetails(response?.data[0]);
|
|
87
|
+
setPrevOrderDetails(response?.data[0]);
|
|
88
|
+
setCustomerInfo({
|
|
89
|
+
recipient_name: response?.data[0]?.order_recipient?.recipient_name,
|
|
90
|
+
postcode: response?.data[0]?.order_recipient?.postcode,
|
|
91
|
+
});
|
|
92
|
+
setTimeout(() => {
|
|
93
|
+
setLogsCallAPi(true);
|
|
94
|
+
setCallApi(true);
|
|
95
|
+
}, 2000);
|
|
96
|
+
} else {
|
|
97
|
+
setLogsCallAPi(false);
|
|
98
|
+
setCallApi(false);
|
|
99
|
+
setOrderDetails(prevOrderDetails);
|
|
100
|
+
}
|
|
77
101
|
};
|
|
102
|
+
|
|
78
103
|
return (
|
|
79
104
|
<Container>
|
|
80
105
|
<AllowTracking />
|
|
81
|
-
<Button
|
|
82
|
-
style={{ borderRadius: '20px' }}
|
|
83
|
-
onClick={onSave}
|
|
84
|
-
// disabled={!isDifferent() || errorFound()}
|
|
85
|
-
>
|
|
106
|
+
<Button onClick={onSave} disabled={!isDifferent() || errorFound()}>
|
|
86
107
|
Save Details
|
|
87
108
|
</Button>
|
|
88
109
|
</Container>
|
|
@@ -96,12 +117,8 @@ const Container = styled.div`
|
|
|
96
117
|
align-items: flex-start;
|
|
97
118
|
border-top: 1px solid #edebe8;
|
|
98
119
|
background: #f8fafc;
|
|
99
|
-
|
|
120
|
+
margin: 0px -15px -15px -15px;
|
|
100
121
|
border-radius: 0px 0px 8px 8px;
|
|
101
|
-
/* margin-bottom: 22px; */
|
|
102
|
-
position: relative;
|
|
103
|
-
align-items: center;
|
|
104
|
-
/* top: 21px; */
|
|
105
122
|
`;
|
|
106
123
|
|
|
107
124
|
export default OrderDetailsFooter;
|
|
@@ -5,19 +5,12 @@ import { useOrderDetails } from '../../../store';
|
|
|
5
5
|
|
|
6
6
|
function DeliveryInstructions() {
|
|
7
7
|
const [orderDetails, setOrderDetails] = useOrderDetails();
|
|
8
|
-
const orderRoutes = orderDetails?.order_routes;
|
|
9
8
|
|
|
10
9
|
const onChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
11
|
-
const val = e.target.value;
|
|
12
|
-
const updatedOrderRoutes = {
|
|
13
|
-
...(orderRoutes === null
|
|
14
|
-
? { delivery_instructions: val }
|
|
15
|
-
: { ...orderRoutes, delivery_instructions: val }),
|
|
16
|
-
};
|
|
17
10
|
setOrderDetails(prev => {
|
|
18
11
|
return {
|
|
19
12
|
...prev,
|
|
20
|
-
|
|
13
|
+
delivery_instructions: e.target.value,
|
|
21
14
|
};
|
|
22
15
|
});
|
|
23
16
|
};
|
|
@@ -26,7 +19,7 @@ function DeliveryInstructions() {
|
|
|
26
19
|
<Container>
|
|
27
20
|
<Label label="Delivery Instructions" />
|
|
28
21
|
<CustomTextArea
|
|
29
|
-
value={
|
|
22
|
+
value={orderDetails?.delivery_instructions || ''}
|
|
30
23
|
placeholder="add delivery instructions"
|
|
31
24
|
onChange={onChange}
|
|
32
25
|
/>
|
package/src/components/order-view/order-details/expanded-content/orders-section/Droptime.tsx
CHANGED
|
@@ -6,19 +6,12 @@ import { handleKeyDown } from '../../../utils';
|
|
|
6
6
|
|
|
7
7
|
function Droptime() {
|
|
8
8
|
const [orderDetails, setOrderDetails] = useOrderDetails();
|
|
9
|
-
const orderRoutes = orderDetails?.order_routes;
|
|
10
9
|
|
|
11
10
|
const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
12
|
-
const val = parseFloat(e.target.value);
|
|
13
|
-
const updatedOrderRoutes = {
|
|
14
|
-
...(orderRoutes === null
|
|
15
|
-
? { drop_time: val }
|
|
16
|
-
: { ...orderRoutes, drop_time: val }),
|
|
17
|
-
};
|
|
18
11
|
setOrderDetails(prev => {
|
|
19
12
|
return {
|
|
20
13
|
...prev,
|
|
21
|
-
|
|
14
|
+
drop_time: e.target.value,
|
|
22
15
|
};
|
|
23
16
|
});
|
|
24
17
|
};
|
|
@@ -31,7 +24,7 @@ function Droptime() {
|
|
|
31
24
|
type="number"
|
|
32
25
|
placeholder="0"
|
|
33
26
|
onKeyDown={handleKeyDown}
|
|
34
|
-
value={
|
|
27
|
+
value={orderDetails?.drop_time || ''}
|
|
35
28
|
onChange={onChange}
|
|
36
29
|
/>
|
|
37
30
|
</Container>
|
|
@@ -39,7 +32,6 @@ function Droptime() {
|
|
|
39
32
|
}
|
|
40
33
|
|
|
41
34
|
const CustomInput = styled(Input)`
|
|
42
|
-
border-radius: 25px;
|
|
43
35
|
&::-webkit-outer-spin-button,
|
|
44
36
|
&::-webkit-inner-spin-button {
|
|
45
37
|
-webkit-appearance: none;
|
package/src/components/order-view/order-details/expanded-content/orders-section/VehicleType.tsx
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Label,
|
|
3
|
-
SelectDropdown,
|
|
4
|
-
dropdownStyles,
|
|
5
|
-
} from '@bjsdistribution/dms-component-library';
|
|
1
|
+
import { Label, SelectDropdown } from '@bjsdistribution/dms-component-library';
|
|
6
2
|
import React from 'react';
|
|
7
3
|
import styled from 'styled-components';
|
|
8
4
|
import { vehicleTypeOptions } from '../../helper';
|
|
5
|
+
import { useOrderDetails } from '../../../store';
|
|
9
6
|
|
|
10
7
|
function VehicleTypeDropdown() {
|
|
8
|
+
const [orderDetails, setOrderDetails] = useOrderDetails();
|
|
9
|
+
const onChange = (e: any) => {
|
|
10
|
+
setOrderDetails(prev => {
|
|
11
|
+
return {
|
|
12
|
+
...prev,
|
|
13
|
+
vehicle_type: e.label,
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
|
|
11
18
|
return (
|
|
12
19
|
<FormContainer>
|
|
13
20
|
<Label label="Vehicle Type" htmlFor="vehicleType" />
|
|
@@ -16,16 +23,10 @@ function VehicleTypeDropdown() {
|
|
|
16
23
|
options={vehicleTypeOptions}
|
|
17
24
|
inputId="vehicleType"
|
|
18
25
|
openMenuOnFocus
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
control: styles => ({
|
|
24
|
-
...styles,
|
|
25
|
-
borderRadius: '25px',
|
|
26
|
-
cursor: 'pointer',
|
|
27
|
-
}),
|
|
28
|
-
}}
|
|
26
|
+
value={vehicleTypeOptions?.filter(
|
|
27
|
+
(x: any) => x.label === orderDetails?.vehicle_type
|
|
28
|
+
)}
|
|
29
|
+
onChange={onChange}
|
|
29
30
|
/>
|
|
30
31
|
</FormContainer>
|
|
31
32
|
);
|