@bjsdistribution/dms-client-return 0.0.80 → 0.0.82
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/header-filters/overViewFilter.d.ts +1 -0
- package/dist/components/order-view/DynamicTable.d.ts +4 -1
- package/dist/components/order-view/order-actions/Dropdown.d.ts +1 -0
- package/dist/components/order-view/order-actions/actions/uncancel-order/UncancelOrder.d.ts +3 -0
- package/dist/dms-client-return.cjs.development.js +609 -391
- 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 +609 -391
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/order-daily-overview/header/route-header/search/SearchType.tsx +58 -2
- package/src/components/order-daily-overview/header-filters/overViewFilter.ts +37 -14
- package/src/components/order-daily-overview/index.tsx +2 -1
- package/src/components/order-view/DynamicTable.tsx +115 -90
- package/src/components/order-view/fakedata.ts +4 -2
- package/src/components/order-view/generic-table/AuditLogs.tsx +23 -81
- package/src/components/order-view/index.tsx +6 -7
- package/src/components/order-view/notes/NoteType.tsx +12 -1
- package/src/components/order-view/notes/index.tsx +46 -33
- package/src/components/order-view/order-actions/Dropdown.tsx +10 -1
- package/src/components/order-view/order-actions/actions/cancel-order/index.tsx +21 -2
- package/src/components/order-view/order-actions/actions/confirm-order/tables/NotesTable.tsx +51 -48
- package/src/components/order-view/order-actions/actions/split-order/SplitOrderTable.tsx +28 -19
- package/src/components/order-view/order-actions/actions/split-order/index.tsx +24 -2
- package/src/components/order-view/order-actions/actions/uncancel-order/UncancelOrder.tsx +166 -0
- package/src/components/order-view/order-actions/index.tsx +3 -2
- package/src/components/order-view/order-details/expanded-content/footer/index.tsx +9 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
2
|
import { RadioButtonGroup } from '@bjsdistribution/dms-component-library';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { useSelectedData, useVisibilityData } from '../../store';
|
|
@@ -7,6 +7,17 @@ function NoteType() {
|
|
|
7
7
|
const [visibilityData] = useVisibilityData();
|
|
8
8
|
const [selected, setSelected] = useSelectedData();
|
|
9
9
|
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (visibilityData && !selected) {
|
|
12
|
+
const defaultOption = visibilityData?.find(
|
|
13
|
+
(option: any) => option.type === 'Private'
|
|
14
|
+
);
|
|
15
|
+
if (defaultOption) {
|
|
16
|
+
setSelected(defaultOption.value);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}, [visibilityData, selected, setSelected]);
|
|
20
|
+
|
|
10
21
|
const handleRadioButtonChange = (
|
|
11
22
|
event: React.ChangeEvent<HTMLInputElement>
|
|
12
23
|
) => {
|
|
@@ -15,16 +15,9 @@ import {
|
|
|
15
15
|
function Notes() {
|
|
16
16
|
const [moduleIds, setModuleIds] = usemoduleIds();
|
|
17
17
|
const [orderId] = useOrderId();
|
|
18
|
-
// const location = useLocation();
|
|
19
|
-
// const pathname = location.pathname;
|
|
20
|
-
// const orderIdLocaation = pathname.split('/')[1];
|
|
21
|
-
|
|
22
|
-
const [recallAuditLog] = useGlobalStateHitAuditLog();
|
|
23
|
-
|
|
24
|
-
const [, setAuditLogLoading] = useAuditLogLoadingState();
|
|
25
|
-
|
|
26
18
|
const [, setNotes] = usegetNotes();
|
|
27
|
-
|
|
19
|
+
const [, setAuditLogLoading] = useAuditLogLoadingState();
|
|
20
|
+
const [recallAuditLog, setAuditLogs] = useGlobalStateHitAuditLog();
|
|
28
21
|
|
|
29
22
|
// Fetch module IDs
|
|
30
23
|
const { data: fetchedData, loading: apiLoading } = useApiHook<{ data: any }>({
|
|
@@ -38,22 +31,21 @@ function Notes() {
|
|
|
38
31
|
fetchedData?.data
|
|
39
32
|
.filter((item: any) => item?.name === 'ORDER')
|
|
40
33
|
.flatMap((item: any) =>
|
|
41
|
-
item?.static_child_mappings
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
item?.static_child_mappings
|
|
35
|
+
?.filter(
|
|
36
|
+
(child: any) => child?.child_module?.name === 'ORDER-NOTE'
|
|
37
|
+
)
|
|
38
|
+
.map((child: any) => ({
|
|
39
|
+
id: child?.child_module?.id,
|
|
40
|
+
parentId: child?.parent_module?.id,
|
|
41
|
+
}))
|
|
47
42
|
) || [];
|
|
48
43
|
|
|
49
|
-
|
|
50
|
-
(module: any) => module?.name === 'ORDER-NOTE'
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
setModuleIds(orderNoteModule || modules[0] || null);
|
|
44
|
+
setModuleIds(modules[0] || null);
|
|
54
45
|
}
|
|
55
46
|
}, [apiLoading, fetchedData]);
|
|
56
47
|
|
|
48
|
+
// Fetch Notes Data
|
|
57
49
|
const {
|
|
58
50
|
data: NotesData,
|
|
59
51
|
loading: NotesLoading,
|
|
@@ -69,13 +61,7 @@ function Notes() {
|
|
|
69
61
|
setShouldPerformAction(true);
|
|
70
62
|
}
|
|
71
63
|
if (!NotesLoading && NotesData?.data) {
|
|
72
|
-
|
|
73
|
-
// .filter((item: any) => item['ORDER-NOTE'] || item['ORDER'])
|
|
74
|
-
// .map((item: any) => [item['ORDER-NOTE'], item['ORDER']])
|
|
75
|
-
// .flat()
|
|
76
|
-
// .filter(Boolean);
|
|
77
|
-
|
|
78
|
-
const updatedData = NotesData.data
|
|
64
|
+
const updatedData = NotesData?.data
|
|
79
65
|
.filter(
|
|
80
66
|
(item: any) =>
|
|
81
67
|
item['ORDER-NOTE'] || item['ORDER'] || item['ORDER-RETURN']
|
|
@@ -84,12 +70,11 @@ function Notes() {
|
|
|
84
70
|
item['ORDER-NOTE'],
|
|
85
71
|
item['ORDER'],
|
|
86
72
|
item['ORDER-RETURN'],
|
|
87
|
-
])
|
|
73
|
+
])
|
|
74
|
+
.flat()
|
|
75
|
+
.filter(Boolean);
|
|
88
76
|
|
|
89
|
-
|
|
90
|
-
// const orderNotesData = NotesData?.data[1]?.['ORDER-NOTE'] || [];
|
|
91
|
-
// const allNotes = [...orderData, ...orderNotesData];
|
|
92
|
-
const combinedArray = updatedData.flat();
|
|
77
|
+
const combinedArray = updatedData?.flat();
|
|
93
78
|
combinedArray.sort(
|
|
94
79
|
(a: any, b: any) =>
|
|
95
80
|
new Date(b.created_at).getTime() - new Date(a.created_at).getTime()
|
|
@@ -102,9 +87,19 @@ function Notes() {
|
|
|
102
87
|
setAuditLogLoading(NotesLoading);
|
|
103
88
|
}, [moduleIds, orderId, NotesLoading, recallAuditLog]);
|
|
104
89
|
|
|
90
|
+
const handleGetLogs = () => {
|
|
91
|
+
setAuditLogs(true);
|
|
92
|
+
setTimeout(() => {
|
|
93
|
+
setAuditLogs(false);
|
|
94
|
+
}, 1000);
|
|
95
|
+
};
|
|
96
|
+
|
|
105
97
|
return (
|
|
106
98
|
<Container>
|
|
107
|
-
<CardHeader>
|
|
99
|
+
<CardHeader>
|
|
100
|
+
NOTES
|
|
101
|
+
<SmallButton onClick={handleGetLogs}>UPDATE LOGS</SmallButton>
|
|
102
|
+
</CardHeader>
|
|
108
103
|
<CustomizedFormSection>
|
|
109
104
|
<AddNote />
|
|
110
105
|
<AuditLogs />
|
|
@@ -129,6 +124,9 @@ const CardHeader = styled.div`
|
|
|
129
124
|
text-transform: uppercase;
|
|
130
125
|
font-family: 'Roboto', sans-serif;
|
|
131
126
|
font-weight: 600;
|
|
127
|
+
display: flex;
|
|
128
|
+
justify-content: space-between;
|
|
129
|
+
align-items: center;
|
|
132
130
|
`;
|
|
133
131
|
|
|
134
132
|
const CustomizedFormSection = styled.div`
|
|
@@ -142,4 +140,19 @@ const CustomizedFormSection = styled.div`
|
|
|
142
140
|
border-bottom-left-radius: 8px;
|
|
143
141
|
box-shadow: 0px 4px 30px 0px rgba(46, 45, 116, 0.05);
|
|
144
142
|
`;
|
|
143
|
+
|
|
144
|
+
const SmallButton = styled.button`
|
|
145
|
+
background-color: #363a30;
|
|
146
|
+
color: #ffffff;
|
|
147
|
+
font-size: 12px;
|
|
148
|
+
padding: 4px 8px;
|
|
149
|
+
border: none;
|
|
150
|
+
border-radius: 4px;
|
|
151
|
+
cursor: pointer;
|
|
152
|
+
transition: background-color 0.3s;
|
|
153
|
+
|
|
154
|
+
&:hover {
|
|
155
|
+
background-color: #feba30;
|
|
156
|
+
}
|
|
157
|
+
`;
|
|
145
158
|
export default Notes;
|
|
@@ -16,12 +16,16 @@ interface ActionsDropdownProps {
|
|
|
16
16
|
disabled?: boolean;
|
|
17
17
|
defaultValue?: any;
|
|
18
18
|
onChange?: any;
|
|
19
|
+
required?: boolean;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
function OrderActionsDropdown(props: ActionsDropdownProps) {
|
|
22
23
|
return (
|
|
23
24
|
<Container className={props.className}>
|
|
24
|
-
<Label>
|
|
25
|
+
<Label>
|
|
26
|
+
{props.label}
|
|
27
|
+
{props.required && <RequiredAsterisk>*</RequiredAsterisk>}
|
|
28
|
+
</Label>
|
|
25
29
|
<AntSelect
|
|
26
30
|
options={props.options}
|
|
27
31
|
placeholder={props.placeholder}
|
|
@@ -38,6 +42,11 @@ function OrderActionsDropdown(props: ActionsDropdownProps) {
|
|
|
38
42
|
);
|
|
39
43
|
}
|
|
40
44
|
|
|
45
|
+
const RequiredAsterisk = styled.span`
|
|
46
|
+
color: red;
|
|
47
|
+
margin-left: 2px;
|
|
48
|
+
`;
|
|
49
|
+
|
|
41
50
|
const Label = styled.label`
|
|
42
51
|
color: #6a7378;
|
|
43
52
|
font-family: 'Lato', sans-serif;
|
|
@@ -84,6 +84,12 @@ function CancelOrder() {
|
|
|
84
84
|
//@ts-ignore
|
|
85
85
|
if (response?.data && response?.code === 200) {
|
|
86
86
|
setShouldPerformAction(true);
|
|
87
|
+
notification.success({
|
|
88
|
+
message: 'Success',
|
|
89
|
+
description:
|
|
90
|
+
//@ts-ignore
|
|
91
|
+
response?.message || 'Sucess',
|
|
92
|
+
});
|
|
87
93
|
} else {
|
|
88
94
|
// alert(response?.error_traceback);
|
|
89
95
|
notification.error({
|
|
@@ -132,6 +138,7 @@ function CancelOrder() {
|
|
|
132
138
|
<Top>
|
|
133
139
|
<TopLeft>
|
|
134
140
|
<OrderActionsDropdown
|
|
141
|
+
required
|
|
135
142
|
label="Cancelation Reason"
|
|
136
143
|
placeholder="Select Cancelation Reason"
|
|
137
144
|
options={cancelReasonOptions || []}
|
|
@@ -145,8 +152,11 @@ function CancelOrder() {
|
|
|
145
152
|
</TopLeft>
|
|
146
153
|
<TopRight>
|
|
147
154
|
<Container>
|
|
148
|
-
<
|
|
149
|
-
|
|
155
|
+
<div style={{ display: 'flex', flexDirection: 'row' }}>
|
|
156
|
+
<Label>Cancelation Note</Label>{' '}
|
|
157
|
+
<RequiredAsterisk>*</RequiredAsterisk>
|
|
158
|
+
</div>
|
|
159
|
+
<TArea
|
|
150
160
|
rows={5}
|
|
151
161
|
onChange={onChangeNotes}
|
|
152
162
|
value={cancelNotes}
|
|
@@ -162,6 +172,15 @@ function CancelOrder() {
|
|
|
162
172
|
</OrderActionModal>
|
|
163
173
|
);
|
|
164
174
|
}
|
|
175
|
+
const RequiredAsterisk = styled.span`
|
|
176
|
+
color: red;
|
|
177
|
+
margin-left: 2px;
|
|
178
|
+
font-size: x-small;
|
|
179
|
+
`;
|
|
180
|
+
|
|
181
|
+
const TArea = styled(TextArea)`
|
|
182
|
+
resize: none;
|
|
183
|
+
`;
|
|
165
184
|
|
|
166
185
|
const Label = styled.label`
|
|
167
186
|
color: #6a7378;
|
|
@@ -5,6 +5,7 @@ import { useOrderId } from '../../../../store';
|
|
|
5
5
|
|
|
6
6
|
import { Empty, Skeleton } from 'antd';
|
|
7
7
|
import { format } from 'date-fns';
|
|
8
|
+
import CustomScrollBar from '../../../../../../common/scrollbar';
|
|
8
9
|
import {
|
|
9
10
|
EmptyDataContainer,
|
|
10
11
|
StyledTable,
|
|
@@ -56,7 +57,7 @@ function NotesTable() {
|
|
|
56
57
|
});
|
|
57
58
|
useEffect(() => {
|
|
58
59
|
setNoteLoadingStore(true);
|
|
59
|
-
if (moduleIds
|
|
60
|
+
if (moduleIds) {
|
|
60
61
|
setShouldPerformAction(true);
|
|
61
62
|
}
|
|
62
63
|
if (!NotesLoading && NotesData?.data) {
|
|
@@ -76,56 +77,58 @@ function NotesTable() {
|
|
|
76
77
|
<Container>
|
|
77
78
|
<Title>Notes ({notes?.length})</Title>
|
|
78
79
|
<StyledTableWrapper>
|
|
79
|
-
<
|
|
80
|
-
<
|
|
81
|
-
<
|
|
82
|
-
<th>Created</th>
|
|
83
|
-
<th>Notes</th>
|
|
84
|
-
</tr>
|
|
85
|
-
</thead>
|
|
86
|
-
<tbody>
|
|
87
|
-
{loading ? (
|
|
80
|
+
<CustomScrollBar>
|
|
81
|
+
<StyledTable className="scrollClass">
|
|
82
|
+
<thead>
|
|
88
83
|
<tr>
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
</td>
|
|
92
|
-
<td colSpan={6}></td>
|
|
84
|
+
<th>Created</th>
|
|
85
|
+
<th>Notes</th>
|
|
93
86
|
</tr>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
notes?.
|
|
104
|
-
<tr
|
|
105
|
-
<td>
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
textTransform: 'capitalize',
|
|
110
|
-
}}
|
|
111
|
-
>
|
|
112
|
-
{order?.created_by}
|
|
113
|
-
</div>
|
|
114
|
-
<div>
|
|
115
|
-
{format(
|
|
116
|
-
new Date(order?.created_at),
|
|
117
|
-
"dd/MM/yyyy '@' HH:mm"
|
|
118
|
-
)}
|
|
119
|
-
</div>
|
|
87
|
+
</thead>
|
|
88
|
+
<tbody>
|
|
89
|
+
{loading ? (
|
|
90
|
+
<tr>
|
|
91
|
+
<td colSpan={6}>
|
|
92
|
+
<Skeleton active />
|
|
93
|
+
</td>
|
|
94
|
+
<td colSpan={6}></td>
|
|
95
|
+
</tr>
|
|
96
|
+
) : notes?.length === 0 ? (
|
|
97
|
+
<tr>
|
|
98
|
+
<td className="emptyTd" colSpan={7}>
|
|
99
|
+
<EmptyDataContainer>
|
|
100
|
+
<Empty />
|
|
101
|
+
</EmptyDataContainer>
|
|
120
102
|
</td>
|
|
121
|
-
<td
|
|
122
|
-
dangerouslySetInnerHTML={{ __html: order?.description }}
|
|
123
|
-
></td>
|
|
124
103
|
</tr>
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
104
|
+
) : (
|
|
105
|
+
notes?.map((order: any) => (
|
|
106
|
+
<tr key={order.id}>
|
|
107
|
+
<td>
|
|
108
|
+
<div
|
|
109
|
+
style={{
|
|
110
|
+
fontWeight: 'bold',
|
|
111
|
+
textTransform: 'capitalize',
|
|
112
|
+
}}
|
|
113
|
+
>
|
|
114
|
+
{order?.created_by}
|
|
115
|
+
</div>
|
|
116
|
+
<div>
|
|
117
|
+
{format(
|
|
118
|
+
new Date(order?.created_at),
|
|
119
|
+
"dd/MM/yyyy '@' HH:mm"
|
|
120
|
+
)}
|
|
121
|
+
</div>
|
|
122
|
+
</td>
|
|
123
|
+
<td
|
|
124
|
+
dangerouslySetInnerHTML={{ __html: order?.description }}
|
|
125
|
+
></td>
|
|
126
|
+
</tr>
|
|
127
|
+
))
|
|
128
|
+
)}
|
|
129
|
+
</tbody>
|
|
130
|
+
</StyledTable>
|
|
131
|
+
</CustomScrollBar>
|
|
129
132
|
</StyledTableWrapper>
|
|
130
133
|
</Container>
|
|
131
134
|
);
|
|
@@ -147,7 +150,7 @@ const Container = styled.div`
|
|
|
147
150
|
flex-direction: column;
|
|
148
151
|
gap: 8px;
|
|
149
152
|
> div {
|
|
150
|
-
min-height:
|
|
153
|
+
min-height: 350px;
|
|
151
154
|
}
|
|
152
155
|
`;
|
|
153
156
|
|
|
@@ -2,8 +2,8 @@ import React, { useEffect, useState } from 'react';
|
|
|
2
2
|
import { useProductDetails } from '../../../store';
|
|
3
3
|
|
|
4
4
|
import { Empty, Skeleton } from 'antd';
|
|
5
|
-
import { useLoading } from '../../../../order-daily-overview/store/store';
|
|
6
5
|
import { Checkbox } from '@bjsdistribution/dms-component-library';
|
|
6
|
+
import { useLoading } from '../../../../order-daily-overview/store/store';
|
|
7
7
|
import { useSelectedSplit, useSplitOrderPayload } from '../../store';
|
|
8
8
|
import {
|
|
9
9
|
EmptyDataContainer,
|
|
@@ -18,13 +18,14 @@ function SplitOrderTable() {
|
|
|
18
18
|
const [selectAll, setSelectAll] = useState(false);
|
|
19
19
|
const [payload, setPayload] = useSplitOrderPayload();
|
|
20
20
|
|
|
21
|
+
// Handle Select All
|
|
21
22
|
const handleSelectAll = (e: any) => {
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
const isChecked = e.target.checked;
|
|
24
|
+
setSelectAll(isChecked);
|
|
25
|
+
|
|
26
|
+
if (isChecked) {
|
|
24
27
|
setSelectedSplit(
|
|
25
|
-
orderProductDetails
|
|
26
|
-
id: order.id,
|
|
27
|
-
}))
|
|
28
|
+
orderProductDetails?.map((order: any) => ({ id: order.id }))
|
|
28
29
|
);
|
|
29
30
|
} else {
|
|
30
31
|
setSelectedSplit([]);
|
|
@@ -32,16 +33,16 @@ function SplitOrderTable() {
|
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
const handleSelectedSplitList = (id: any) => {
|
|
35
|
-
setSelectedSplit(
|
|
36
|
-
const isSelected = prevSelectedOrder?.some(
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
setSelectedSplit(prevSelectedOrder => {
|
|
37
|
+
const isSelected = prevSelectedOrder?.some(order => order.id === id);
|
|
38
|
+
|
|
39
|
+
const updatedSelection = isSelected
|
|
40
|
+
? prevSelectedOrder?.filter(order => order.id !== id)
|
|
41
|
+
: [...prevSelectedOrder, { id }];
|
|
42
|
+
|
|
43
|
+
setSelectAll(updatedSelection?.length === orderProductDetails?.length);
|
|
39
44
|
|
|
40
|
-
|
|
41
|
-
return prevSelectedOrder?.filter((order: any) => order.id !== id);
|
|
42
|
-
} else {
|
|
43
|
-
return [...prevSelectedOrder, { id: id }];
|
|
44
|
-
}
|
|
45
|
+
return updatedSelection;
|
|
45
46
|
});
|
|
46
47
|
};
|
|
47
48
|
|
|
@@ -52,7 +53,7 @@ function SplitOrderTable() {
|
|
|
52
53
|
products: selectedSplits?.map(order => order.id),
|
|
53
54
|
force: true,
|
|
54
55
|
});
|
|
55
|
-
}, [
|
|
56
|
+
}, [selectedSplits, setPayload]);
|
|
56
57
|
|
|
57
58
|
return (
|
|
58
59
|
<StyledTableWrapper id="tableScrolling">
|
|
@@ -60,7 +61,14 @@ function SplitOrderTable() {
|
|
|
60
61
|
<thead>
|
|
61
62
|
<tr>
|
|
62
63
|
<th>
|
|
63
|
-
<Checkbox
|
|
64
|
+
<Checkbox
|
|
65
|
+
checked={selectAll}
|
|
66
|
+
onChange={handleSelectAll}
|
|
67
|
+
disabled={
|
|
68
|
+
orderProductDetails?.length === 0 ||
|
|
69
|
+
orderProductDetails?.length === null
|
|
70
|
+
}
|
|
71
|
+
/>
|
|
64
72
|
</th>
|
|
65
73
|
<th>Type</th>
|
|
66
74
|
<th>Code</th>
|
|
@@ -82,17 +90,18 @@ function SplitOrderTable() {
|
|
|
82
90
|
<tr>
|
|
83
91
|
<td className="emptyTd" colSpan={7}>
|
|
84
92
|
<EmptyDataContainer>
|
|
85
|
-
<Empty />
|
|
93
|
+
<Empty description="No Data Found" />
|
|
86
94
|
</EmptyDataContainer>
|
|
87
95
|
</td>
|
|
88
96
|
</tr>
|
|
89
97
|
) : (
|
|
98
|
+
orderProductDetails?.length > 0 &&
|
|
90
99
|
orderProductDetails?.map((order: any) => (
|
|
91
100
|
<tr key={order.id}>
|
|
92
101
|
<td>
|
|
93
102
|
<Checkbox
|
|
94
103
|
checked={selectedSplits?.some(
|
|
95
|
-
|
|
104
|
+
selectedOrder => selectedOrder.id === order.id
|
|
96
105
|
)}
|
|
97
106
|
onChange={() => handleSelectedSplitList(order.id)}
|
|
98
107
|
/>
|
|
@@ -7,6 +7,7 @@ import { useApiHook } from '@bjsdistribution/dms-component-library';
|
|
|
7
7
|
import { ApiResponse } from '../../../types';
|
|
8
8
|
|
|
9
9
|
import { useSelectedSplit, useSplitOrderPayload } from '../../store';
|
|
10
|
+
import { notification } from 'antd';
|
|
10
11
|
|
|
11
12
|
function SplitOrder() {
|
|
12
13
|
const [, setCurrentAction] = useCurrentAction();
|
|
@@ -21,7 +22,10 @@ function SplitOrder() {
|
|
|
21
22
|
setCurrentAction(undefined);
|
|
22
23
|
};
|
|
23
24
|
|
|
24
|
-
const {
|
|
25
|
+
const {
|
|
26
|
+
data: response,
|
|
27
|
+
setShouldPerformAction: setPerformAction,
|
|
28
|
+
} = useApiHook<{
|
|
25
29
|
data: ApiResponse[];
|
|
26
30
|
}>({
|
|
27
31
|
endpoint: `orders/split_order/${orderId}`,
|
|
@@ -33,8 +37,26 @@ function SplitOrder() {
|
|
|
33
37
|
const onSubmitSplitOrder = () => {
|
|
34
38
|
if (orderId) {
|
|
35
39
|
setPerformAction(true);
|
|
40
|
+
//@ts-ignore
|
|
41
|
+
if (response?.data && response?.code === 200) {
|
|
42
|
+
notification.success({
|
|
43
|
+
message: 'Success',
|
|
44
|
+
description:
|
|
45
|
+
//@ts-ignore
|
|
46
|
+
response?.message || 'Sucess',
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
// alert(response?.error_traceback);
|
|
50
|
+
notification.error({
|
|
51
|
+
message: 'Error',
|
|
52
|
+
description:
|
|
53
|
+
//@ts-ignore
|
|
54
|
+
response?.message ||
|
|
55
|
+
'An error has occurred. Please try again later.',
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
setSelectedSplit([]);
|
|
36
59
|
}
|
|
37
|
-
setSelectedSplit([]);
|
|
38
60
|
};
|
|
39
61
|
|
|
40
62
|
const isSubmitDisabled = () => {
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
AntSelect,
|
|
4
|
+
TextArea,
|
|
5
|
+
useApiHook,
|
|
6
|
+
} from '@bjsdistribution/dms-component-library';
|
|
7
|
+
import {
|
|
8
|
+
useCurrentAction,
|
|
9
|
+
useCustomerInfo,
|
|
10
|
+
useOrderDetails,
|
|
11
|
+
useOrderId,
|
|
12
|
+
useOrderStaticData,
|
|
13
|
+
usePrevOrderDetails,
|
|
14
|
+
} from '../../../store';
|
|
15
|
+
import OrderActionModal from '../../../../../common/modals/order-action-modal/OrderActionModal';
|
|
16
|
+
import { HoldContentContainer, HoldRow, Label, SplitText } from '../modalstyle';
|
|
17
|
+
import { ApiResponse, OrdersType } from '../../../types';
|
|
18
|
+
import styled from 'styled-components';
|
|
19
|
+
import { useLoading } from '../../../../order-daily-overview/store/store';
|
|
20
|
+
import { notification } from 'antd';
|
|
21
|
+
|
|
22
|
+
function UncancelOrder() {
|
|
23
|
+
const [orderId] = useOrderId();
|
|
24
|
+
const [, setCurrentAction] = useCurrentAction();
|
|
25
|
+
|
|
26
|
+
const onClose = () => {
|
|
27
|
+
setCurrentAction(undefined);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const [orderStaticData] = useOrderStaticData();
|
|
31
|
+
const [unCancelReason, setUncancelReason] = useState<string | undefined>(
|
|
32
|
+
undefined
|
|
33
|
+
);
|
|
34
|
+
const [unCancelNotes, setUncancelNotes] = useState<string>('');
|
|
35
|
+
const [, setOrderDetails] = useOrderDetails();
|
|
36
|
+
const [, setPrevOrderDetails] = usePrevOrderDetails();
|
|
37
|
+
const [, setLoading] = useLoading();
|
|
38
|
+
const [customerInfo] = useCustomerInfo();
|
|
39
|
+
const infoText = `${customerInfo?.recipient_name}, ${customerInfo?.postcode}`;
|
|
40
|
+
|
|
41
|
+
const unCancelReasonOptions = orderStaticData?.uncancel_reasons?.map(
|
|
42
|
+
(item: any) => {
|
|
43
|
+
return {
|
|
44
|
+
label: item?.reason,
|
|
45
|
+
value: item?.reason,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const {
|
|
51
|
+
data: response,
|
|
52
|
+
setShouldPerformAction: setPerformAction,
|
|
53
|
+
} = useApiHook<{
|
|
54
|
+
data: ApiResponse[];
|
|
55
|
+
}>({
|
|
56
|
+
endpoint: `orders/${orderId}/uncancel/?uncancelled_reason=${unCancelReason}&uncancelled_notes=${unCancelNotes}`,
|
|
57
|
+
method: 'POST',
|
|
58
|
+
performAction: false,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const { data: fetchedData, loading, setShouldPerformAction } = useApiHook<{
|
|
62
|
+
data: OrdersType[];
|
|
63
|
+
}>({
|
|
64
|
+
endpoint: `orders/${orderId}`,
|
|
65
|
+
method: 'GET',
|
|
66
|
+
performAction: false,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
setLoading(loading);
|
|
71
|
+
if (fetchedData && fetchedData.data) {
|
|
72
|
+
const requiredData = fetchedData?.data;
|
|
73
|
+
setOrderDetails(requiredData[0]);
|
|
74
|
+
setPrevOrderDetails(requiredData[0]);
|
|
75
|
+
setCurrentAction(undefined);
|
|
76
|
+
}
|
|
77
|
+
if (
|
|
78
|
+
(fetchedData && fetchedData?.data === null) ||
|
|
79
|
+
fetchedData?.data?.length === 0
|
|
80
|
+
) {
|
|
81
|
+
setCurrentAction(undefined);
|
|
82
|
+
}
|
|
83
|
+
}, [loading]);
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (response) {
|
|
87
|
+
//@ts-ignore
|
|
88
|
+
if (response?.data && response?.code === 200) {
|
|
89
|
+
setShouldPerformAction(true);
|
|
90
|
+
notification.success({
|
|
91
|
+
message: 'Success',
|
|
92
|
+
description:
|
|
93
|
+
//@ts-ignore
|
|
94
|
+
response?.message || 'Sucess',
|
|
95
|
+
});
|
|
96
|
+
} else {
|
|
97
|
+
notification.error({
|
|
98
|
+
message: 'Error',
|
|
99
|
+
description:
|
|
100
|
+
//@ts-ignore
|
|
101
|
+
response?.error_traceback ||
|
|
102
|
+
'An error has occurred. Please try again later.',
|
|
103
|
+
});
|
|
104
|
+
setCurrentAction(undefined);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}, [response]);
|
|
108
|
+
|
|
109
|
+
const onChange = (event: any) => {
|
|
110
|
+
setUncancelNotes(event.target.value);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const onChangeUnCancelReason = (value: string) => {
|
|
114
|
+
setUncancelReason(value);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const onSubmit = () => {
|
|
118
|
+
if (orderId) {
|
|
119
|
+
setPerformAction(true);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const showSubmitBtn =
|
|
124
|
+
unCancelReason !== undefined && unCancelNotes?.length > 0;
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<OrderActionModal
|
|
128
|
+
headerTitle="Un-Cancel order"
|
|
129
|
+
onCloseHeader={onClose}
|
|
130
|
+
onSubmit={onSubmit}
|
|
131
|
+
showAdditionalInfo
|
|
132
|
+
infoText={infoText}
|
|
133
|
+
submitBtnTitle="Save Details"
|
|
134
|
+
isSubmitDisabled={!showSubmitBtn}
|
|
135
|
+
>
|
|
136
|
+
<HoldContentContainer>
|
|
137
|
+
<SplitText>
|
|
138
|
+
<HoldRow>
|
|
139
|
+
<Label>Un-cancel Reason</Label>
|
|
140
|
+
<AntSelect
|
|
141
|
+
options={unCancelReasonOptions || []}
|
|
142
|
+
placeholder="Select un-cancel Reason"
|
|
143
|
+
onChange={onChangeUnCancelReason}
|
|
144
|
+
disabled={false}
|
|
145
|
+
style={{ width: '346px', height: 40 }}
|
|
146
|
+
showSearch={true}
|
|
147
|
+
popupClassName={'dropDownStyle'}
|
|
148
|
+
selectWrapperClass={'rounded'}
|
|
149
|
+
defaultValue={unCancelReason}
|
|
150
|
+
/>
|
|
151
|
+
</HoldRow>
|
|
152
|
+
<HoldRow>
|
|
153
|
+
<Label>Un-cancel Note</Label>
|
|
154
|
+
<CustomTextArea rows={5} onChange={onChange} />
|
|
155
|
+
</HoldRow>
|
|
156
|
+
</SplitText>
|
|
157
|
+
</HoldContentContainer>
|
|
158
|
+
</OrderActionModal>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const CustomTextArea = styled(TextArea)`
|
|
163
|
+
width: 346px;
|
|
164
|
+
`;
|
|
165
|
+
|
|
166
|
+
export default UncancelOrder;
|