@bjsdistribution/dms-client-return 0.1.18-dev → 0.1.20-dev
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/client-portal/OutstandingTable.d.ts +3 -0
- package/dist/components/client-portal/ReturnStatus.d.ts +5 -0
- package/dist/components/client-portal/return-confirm/ConfirmedMain.d.ts +3 -0
- package/dist/components/client-portal/return-confirm/ReturnConfirmedTable.d.ts +3 -0
- package/dist/components/store.d.ts +5 -1
- package/dist/dms-client-return.cjs.development.js +1105 -298
- 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 +1106 -299
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/client-portal/OutstandingTable.tsx +412 -0
- package/src/components/client-portal/ReturnAfterSearchBar.tsx +116 -11
- package/src/components/client-portal/ReturnOverview.tsx +4 -4
- package/src/components/client-portal/ReturnRTFilters.tsx +59 -40
- package/src/components/client-portal/ReturnSearchBar.tsx +93 -12
- package/src/components/client-portal/ReturnStatus.tsx +36 -3
- package/src/components/client-portal/return-confirm/ConfirmedMain.tsx +235 -0
- package/src/components/client-portal/return-confirm/ReturnConfirmedTable.tsx +404 -0
- package/src/components/order-daily-overview/return-after-table/ReturnAfterTable.tsx +18 -38
- package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +18 -24
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +35 -146
- package/src/components/store.ts +23 -0
|
@@ -10,15 +10,26 @@ import { ExportButton, useAxios } from '@bjsdistribution/dms-component-library';
|
|
|
10
10
|
import { useParams } from 'react-router-dom';
|
|
11
11
|
import { filtersReducerReturnAtom } from '../order-daily-overview/return-after-table/table-filters/ReturnFilterStore';
|
|
12
12
|
import { notification } from 'antd';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
useSelectedClientAfterOrders,
|
|
15
|
+
useSelectedClientPortOrders,
|
|
16
|
+
// useSelectedClientPortOrders,
|
|
17
|
+
} from '../store';
|
|
14
18
|
|
|
15
19
|
const ReturnRTFilters = () => {
|
|
16
20
|
const [returnData] = useReturnData();
|
|
17
21
|
const [pendingState] = useAtom(filtersReducerAtom);
|
|
18
22
|
const [state] = useAtom(filtersReducerReturnAtom);
|
|
19
23
|
const [returnAfterOrder] = useReturnAfterOrderData();
|
|
20
|
-
const [selectedReturnOrder] = useSelectedClientPortOrders();
|
|
21
|
-
|
|
24
|
+
// const [selectedReturnOrder] = useSelectedClientPortOrders();
|
|
25
|
+
const [
|
|
26
|
+
selectedOrderIds,
|
|
27
|
+
setSelectedOrderIds,
|
|
28
|
+
] = useSelectedClientAfterOrders();
|
|
29
|
+
const [
|
|
30
|
+
selectedPendingOrderIds,
|
|
31
|
+
setSelectedPendingOrderIds,
|
|
32
|
+
] = useSelectedClientPortOrders();
|
|
22
33
|
const { status } = useParams<{ status: any }>();
|
|
23
34
|
const { 'x-filters': pendingFilters } = pendingState;
|
|
24
35
|
|
|
@@ -46,10 +57,13 @@ const ReturnRTFilters = () => {
|
|
|
46
57
|
feature_name: 'return',
|
|
47
58
|
};
|
|
48
59
|
}
|
|
49
|
-
// console.log(selectedReturnOrder, 'selectedReturnOrder');
|
|
50
60
|
//Export Manifest
|
|
51
|
-
const
|
|
52
|
-
|
|
61
|
+
const isExportEnabled =
|
|
62
|
+
status === 'outstanding_return'
|
|
63
|
+
? selectedPendingOrderIds?.length > 0
|
|
64
|
+
: status === 'scheduled_for_return' || status === 'return_completed'
|
|
65
|
+
? selectedOrderIds?.length > 0
|
|
66
|
+
: false;
|
|
53
67
|
const { fetchData: callExportApi } = useAxios<{
|
|
54
68
|
data: any[];
|
|
55
69
|
message: string;
|
|
@@ -58,12 +72,19 @@ const ReturnRTFilters = () => {
|
|
|
58
72
|
method: 'POST',
|
|
59
73
|
});
|
|
60
74
|
|
|
61
|
-
const
|
|
75
|
+
const handleExportManifest = async () => {
|
|
62
76
|
if (!isExportEnabled) return;
|
|
63
77
|
|
|
78
|
+
const exportOrderIds =
|
|
79
|
+
status === 'outstanding_return'
|
|
80
|
+
? selectedPendingOrderIds
|
|
81
|
+
: status === 'scheduled_for_return' || status === 'return_completed'
|
|
82
|
+
? selectedOrderIds
|
|
83
|
+
: [];
|
|
84
|
+
|
|
64
85
|
try {
|
|
65
86
|
const response = (await callExportApi({
|
|
66
|
-
payload: { order_ids:
|
|
87
|
+
payload: { order_ids: exportOrderIds },
|
|
67
88
|
})) as {
|
|
68
89
|
code: number | null;
|
|
69
90
|
error?: string | null;
|
|
@@ -78,38 +99,16 @@ const ReturnRTFilters = () => {
|
|
|
78
99
|
message: 'Success',
|
|
79
100
|
description: response?.message || 'Export completed.',
|
|
80
101
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
102
|
+
window.open(response?.data?.url, '_blank');
|
|
103
|
+
|
|
104
|
+
if (status === 'outstanding_return') {
|
|
105
|
+
setSelectedPendingOrderIds([]);
|
|
106
|
+
} else if (
|
|
107
|
+
status === 'scheduled_for_return' ||
|
|
108
|
+
status === 'return_completed'
|
|
109
|
+
) {
|
|
110
|
+
setSelectedOrderIds([]);
|
|
88
111
|
}
|
|
89
|
-
|
|
90
|
-
const blob = await downloadResponse.blob();
|
|
91
|
-
|
|
92
|
-
const urlObject = window.URL.createObjectURL(blob);
|
|
93
|
-
const link = document.createElement('a');
|
|
94
|
-
link.href = urlObject;
|
|
95
|
-
|
|
96
|
-
// You can customize the filename or extract it from headers
|
|
97
|
-
const contentDisposition = downloadResponse.headers.get(
|
|
98
|
-
'Content-Disposition'
|
|
99
|
-
);
|
|
100
|
-
const filenameMatch = contentDisposition?.match(/filename="?(.+)"?/);
|
|
101
|
-
const filename = filenameMatch?.[1] || 'download.csv';
|
|
102
|
-
|
|
103
|
-
link.download = filename;
|
|
104
|
-
document.body.appendChild(link);
|
|
105
|
-
link.click();
|
|
106
|
-
document.body.removeChild(link);
|
|
107
|
-
window.URL.revokeObjectURL(urlObject);
|
|
108
|
-
|
|
109
|
-
notification.success({
|
|
110
|
-
message: 'Downloaded',
|
|
111
|
-
description: 'File downloaded successfully.',
|
|
112
|
-
});
|
|
113
112
|
} else {
|
|
114
113
|
notification.error({
|
|
115
114
|
message: 'No File URL',
|
|
@@ -122,13 +121,28 @@ const ReturnRTFilters = () => {
|
|
|
122
121
|
message: 'Export Failed',
|
|
123
122
|
description: 'Something went wrong during export.',
|
|
124
123
|
});
|
|
124
|
+
|
|
125
|
+
if (status === 'outstanding_return') {
|
|
126
|
+
setSelectedPendingOrderIds([]);
|
|
127
|
+
} else if (
|
|
128
|
+
status === 'scheduled_for_return' ||
|
|
129
|
+
status === 'return_completed'
|
|
130
|
+
) {
|
|
131
|
+
setSelectedOrderIds([]);
|
|
132
|
+
}
|
|
125
133
|
}
|
|
126
134
|
};
|
|
127
135
|
|
|
128
136
|
return (
|
|
129
137
|
<StyledBulkFilterCover className="dmsBulkFilter">
|
|
130
138
|
<ExportButton moduleInfoModule={moduleInfo} />
|
|
131
|
-
<StyledBulkItem
|
|
139
|
+
<StyledBulkItem
|
|
140
|
+
onClick={handleExportManifest}
|
|
141
|
+
style={{
|
|
142
|
+
pointerEvents: isExportEnabled ? 'auto' : 'none',
|
|
143
|
+
opacity: isExportEnabled ? 1 : 0.5,
|
|
144
|
+
}}
|
|
145
|
+
>
|
|
132
146
|
<Text>Export Manifest</Text>
|
|
133
147
|
</StyledBulkItem>
|
|
134
148
|
</StyledBulkFilterCover>
|
|
@@ -174,6 +188,11 @@ export const StyledBulkItem = styled.div`
|
|
|
174
188
|
}
|
|
175
189
|
}
|
|
176
190
|
}
|
|
191
|
+
&:hover:not(:disabled) {
|
|
192
|
+
background: #f0f0f0;
|
|
193
|
+
cursor: pointer;
|
|
194
|
+
}
|
|
195
|
+
|
|
177
196
|
@media screen and (max-width: 1030px) {
|
|
178
197
|
padding: 6px 4px;
|
|
179
198
|
}
|
|
@@ -7,10 +7,12 @@ import React, { useEffect, useState } from 'react';
|
|
|
7
7
|
import styled from 'styled-components';
|
|
8
8
|
import {
|
|
9
9
|
useAtom,
|
|
10
|
+
useClientOutstandingReturnData,
|
|
10
11
|
useClientPortal,
|
|
11
12
|
useEndDate,
|
|
12
13
|
useSearchText,
|
|
13
14
|
useStartDate,
|
|
15
|
+
useStatsCPCount,
|
|
14
16
|
} from '../store';
|
|
15
17
|
import dayjs from 'dayjs';
|
|
16
18
|
import { filtersReducerAtom } from '../order-daily-overview/header-filters/filterStore';
|
|
@@ -18,14 +20,14 @@ import { ApiResponse } from '../types';
|
|
|
18
20
|
import { javascriptStringDumpToJSON } from '../utils';
|
|
19
21
|
import { UsePaginationData } from '../order-daily-overview/store/store';
|
|
20
22
|
import { notification } from 'antd';
|
|
21
|
-
import { useReturnData } from '../order-view/store';
|
|
22
23
|
import { useParams } from 'react-router-dom';
|
|
24
|
+
import { returnCountType } from './ReturnStatus';
|
|
23
25
|
|
|
24
26
|
function ReturnSearchBar() {
|
|
25
27
|
const [searchText, setSearchText] = useState('');
|
|
26
28
|
const [debouncedSearchText, setDebouncedSearchText] = useSearchText();
|
|
27
29
|
const [modifiedFilters, setModifiedFilters] = useState<any[]>([]);
|
|
28
|
-
const [,
|
|
30
|
+
const [, setOutstandingData] = useClientOutstandingReturnData();
|
|
29
31
|
const { status } = useParams();
|
|
30
32
|
//condition on client view
|
|
31
33
|
const [clientPortal] = useClientPortal();
|
|
@@ -37,6 +39,8 @@ function ReturnSearchBar() {
|
|
|
37
39
|
const [startDate] = useStartDate();
|
|
38
40
|
const [endDate] = useEndDate();
|
|
39
41
|
const [state] = useAtom(filtersReducerAtom);
|
|
42
|
+
const [, setCount] = useStatsCPCount();
|
|
43
|
+
const [modifiedStatsFilters, setModifiedStatsFilters] = useState<any[]>([]);
|
|
40
44
|
|
|
41
45
|
const { 'x-pagination': pagination } = state;
|
|
42
46
|
|
|
@@ -97,11 +101,59 @@ function ReturnSearchBar() {
|
|
|
97
101
|
setModifiedFilters(updatedFilters);
|
|
98
102
|
}, [startDate, endDate, status]);
|
|
99
103
|
|
|
104
|
+
//For stats
|
|
105
|
+
|
|
106
|
+
const getDateFilters = (
|
|
107
|
+
startDate: dayjs.Dayjs | null,
|
|
108
|
+
endDate: dayjs.Dayjs | null
|
|
109
|
+
) => {
|
|
110
|
+
const stored = JSON.parse(localStorage.getItem('returnDate') || '{}');
|
|
111
|
+
|
|
112
|
+
const sDate = startDate?.isValid?.() ? startDate : dayjs(stored?.startDate);
|
|
113
|
+
const eDate = endDate?.isValid?.()
|
|
114
|
+
? endDate
|
|
115
|
+
: stored?.endDate
|
|
116
|
+
? dayjs(stored?.endDate)
|
|
117
|
+
: null;
|
|
118
|
+
|
|
119
|
+
if (!sDate?.isValid?.()) return [];
|
|
120
|
+
|
|
121
|
+
let dateFilters = [];
|
|
122
|
+
|
|
123
|
+
if (eDate && eDate.isValid()) {
|
|
124
|
+
dateFilters = [
|
|
125
|
+
{ field: 'created_at', op: '>=', value: sDate.format('YYYY-MM-DD') },
|
|
126
|
+
{
|
|
127
|
+
field: 'created_at',
|
|
128
|
+
op: '<=',
|
|
129
|
+
value: eDate.add(1, 'day').format('YYYY-MM-DD'),
|
|
130
|
+
},
|
|
131
|
+
];
|
|
132
|
+
} else {
|
|
133
|
+
dateFilters = [
|
|
134
|
+
{
|
|
135
|
+
field: 'created_at',
|
|
136
|
+
op: '=',
|
|
137
|
+
value: sDate.format('YYYY-MM-DD'),
|
|
138
|
+
},
|
|
139
|
+
];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return dateFilters;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
if (!clientPortal) return;
|
|
147
|
+
|
|
148
|
+
const dateFilters = getDateFilters(startDate, endDate);
|
|
149
|
+
setModifiedStatsFilters(dateFilters);
|
|
150
|
+
}, [startDate, endDate]);
|
|
151
|
+
|
|
100
152
|
const {
|
|
101
|
-
loading,
|
|
153
|
+
// loading,
|
|
102
154
|
paginationData,
|
|
103
155
|
fetchData: getPendingData,
|
|
104
|
-
data: fetchedReturnOrderData,
|
|
156
|
+
// data: fetchedReturnOrderData,
|
|
105
157
|
} = useAxios<ApiResponse>({
|
|
106
158
|
endpoint: '/v1/return/product/pending/',
|
|
107
159
|
method: 'GET',
|
|
@@ -110,7 +162,7 @@ function ReturnSearchBar() {
|
|
|
110
162
|
});
|
|
111
163
|
|
|
112
164
|
useEffect(() => {
|
|
113
|
-
if (debouncedSearchText
|
|
165
|
+
if (debouncedSearchText?.length > 1) {
|
|
114
166
|
getPendingData({
|
|
115
167
|
endPointQuery: `?search_term=${debouncedSearchText}`,
|
|
116
168
|
}).then((response: any) => {
|
|
@@ -123,20 +175,20 @@ function ReturnSearchBar() {
|
|
|
123
175
|
}
|
|
124
176
|
|
|
125
177
|
if (response?.data?.length > 0) {
|
|
126
|
-
|
|
178
|
+
setOutstandingData(response?.data);
|
|
127
179
|
} else {
|
|
128
|
-
|
|
180
|
+
setOutstandingData([]);
|
|
129
181
|
}
|
|
130
182
|
});
|
|
131
183
|
} else if (
|
|
132
|
-
debouncedSearchText
|
|
133
|
-
debouncedSearchText
|
|
184
|
+
debouncedSearchText?.length > 0 &&
|
|
185
|
+
debouncedSearchText?.length <= 2
|
|
134
186
|
) {
|
|
135
187
|
notification.warning({
|
|
136
188
|
message: 'Search Phrase cannot be less than 3 characters',
|
|
137
189
|
});
|
|
138
190
|
}
|
|
139
|
-
}, [debouncedSearchText
|
|
191
|
+
}, [debouncedSearchText]);
|
|
140
192
|
|
|
141
193
|
// Debouncing effect
|
|
142
194
|
useEffect(() => {
|
|
@@ -149,14 +201,43 @@ function ReturnSearchBar() {
|
|
|
149
201
|
}, [searchText]);
|
|
150
202
|
|
|
151
203
|
useEffect(() => {
|
|
152
|
-
if (debouncedSearchText
|
|
204
|
+
if (debouncedSearchText?.length === 0) {
|
|
153
205
|
setSearchText('');
|
|
154
206
|
}
|
|
155
207
|
}, [debouncedSearchText]);
|
|
156
208
|
|
|
209
|
+
//
|
|
210
|
+
const { fetchData: fetchStatsData } = useAxios<{
|
|
211
|
+
data: returnCountType[];
|
|
212
|
+
}>({
|
|
213
|
+
endpoint: `v1/portal/return/stats/`,
|
|
214
|
+
method: 'GET',
|
|
215
|
+
pagination: { is_pagination: false },
|
|
216
|
+
filters: modifiedStatsFilters,
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
useEffect(() => {
|
|
220
|
+
const isClientOutstanding = clientPortal && status === 'outstanding_return';
|
|
221
|
+
if (!isClientOutstanding || debouncedSearchText?.length < 3) return;
|
|
222
|
+
|
|
223
|
+
const fetchStats = async () => {
|
|
224
|
+
const response = await fetchStatsData({
|
|
225
|
+
endPointQuery: `?search_term=${debouncedSearchText}&type=outstanding`,
|
|
226
|
+
});
|
|
227
|
+
//@ts-ignore
|
|
228
|
+
if (response?.data) {
|
|
229
|
+
//@ts-ignore
|
|
230
|
+
setCount(response?.data); // Set the count here
|
|
231
|
+
} else {
|
|
232
|
+
setCount(null); // fallback if no data
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
fetchStats();
|
|
237
|
+
}, [debouncedSearchText, status, clientPortal]);
|
|
238
|
+
|
|
157
239
|
const handleClear = () => {
|
|
158
240
|
setSearchText('');
|
|
159
|
-
setDebouncedSearchText('');
|
|
160
241
|
};
|
|
161
242
|
return (
|
|
162
243
|
<Search>
|
|
@@ -3,19 +3,26 @@ import {
|
|
|
3
3
|
device,
|
|
4
4
|
useAxios,
|
|
5
5
|
} from '@bjsdistribution/dms-component-library';
|
|
6
|
-
import React, { useEffect, useState } from 'react';
|
|
6
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
7
7
|
import styled from 'styled-components';
|
|
8
8
|
import {
|
|
9
9
|
useActiveCardId,
|
|
10
10
|
useAtom,
|
|
11
11
|
useClientPortal,
|
|
12
12
|
useEndDate,
|
|
13
|
+
useSearchAfterText,
|
|
14
|
+
useSearchText,
|
|
13
15
|
useStartDate,
|
|
16
|
+
useStatsCPCount,
|
|
14
17
|
} from '../store';
|
|
15
18
|
import { useNavigate, useParams } from 'react-router-dom';
|
|
16
19
|
import { filtersReducerReturnAtom } from '../order-daily-overview/return-after-table/table-filters/ReturnFilterStore';
|
|
17
20
|
import dayjs from 'dayjs';
|
|
18
|
-
|
|
21
|
+
export type returnCountType = {
|
|
22
|
+
outstanding_count: number | null;
|
|
23
|
+
scheduled_count: number;
|
|
24
|
+
completed_count: number;
|
|
25
|
+
};
|
|
19
26
|
const ReturnStatus = () => {
|
|
20
27
|
//CP
|
|
21
28
|
type returnCountType = {
|
|
@@ -28,11 +35,13 @@ const ReturnStatus = () => {
|
|
|
28
35
|
const [activeCardId, setActiveCardId] = useActiveCardId();
|
|
29
36
|
const [, dispatch] = useAtom(filtersReducerReturnAtom);
|
|
30
37
|
const { status } = useParams();
|
|
31
|
-
const [count, setCount] =
|
|
38
|
+
const [count, setCount] = useStatsCPCount();
|
|
32
39
|
const [startDate] = useStartDate();
|
|
33
40
|
const [endDate] = useEndDate();
|
|
34
41
|
const [clientPortal] = useClientPortal();
|
|
35
42
|
const [modifiedFilters, setModifiedFilters] = useState<any[]>([]);
|
|
43
|
+
const [debouncedSearchText] = useSearchText();
|
|
44
|
+
const [debouncedSearchAfterText] = useSearchAfterText();
|
|
36
45
|
|
|
37
46
|
const getDateFilters = (
|
|
38
47
|
startDate: dayjs.Dayjs | null,
|
|
@@ -92,6 +101,27 @@ const ReturnStatus = () => {
|
|
|
92
101
|
filters: modifiedFilters,
|
|
93
102
|
});
|
|
94
103
|
|
|
104
|
+
const prevSearchTextRef = useRef('');
|
|
105
|
+
const prevSearchAfterTextRef = useRef('');
|
|
106
|
+
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
const prev = prevSearchTextRef.current;
|
|
109
|
+
if (clientPortal && prev && debouncedSearchText === '') {
|
|
110
|
+
fetchData();
|
|
111
|
+
}
|
|
112
|
+
prevSearchTextRef.current = debouncedSearchText;
|
|
113
|
+
}, [debouncedSearchText, startDate, endDate]);
|
|
114
|
+
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
const prev = prevSearchAfterTextRef.current;
|
|
117
|
+
if (clientPortal && prev && debouncedSearchAfterText === '') {
|
|
118
|
+
fetchData();
|
|
119
|
+
}
|
|
120
|
+
prevSearchAfterTextRef.current = debouncedSearchAfterText;
|
|
121
|
+
}, [debouncedSearchAfterText, startDate, endDate]);
|
|
122
|
+
|
|
123
|
+
console.log(debouncedSearchText, 'debouncedSearchText');
|
|
124
|
+
console.log(debouncedSearchAfterText, 'debouncedSearchAfterText');
|
|
95
125
|
useEffect(() => {
|
|
96
126
|
fetchData();
|
|
97
127
|
}, [startDate, endDate]);
|
|
@@ -127,12 +157,15 @@ const ReturnStatus = () => {
|
|
|
127
157
|
},
|
|
128
158
|
];
|
|
129
159
|
const navigate = useNavigate();
|
|
160
|
+
const [, setDebouncedSearchText] = useSearchAfterText();
|
|
161
|
+
|
|
130
162
|
const handleCardClick = (item: any) => {
|
|
131
163
|
if (activeCardId === item?.id) {
|
|
132
164
|
return;
|
|
133
165
|
}
|
|
134
166
|
setActiveCardId(item?.id);
|
|
135
167
|
navigate(`/return/${item?.status}`);
|
|
168
|
+
setDebouncedSearchText('');
|
|
136
169
|
if (item?.status == 'scheduled_for_return') {
|
|
137
170
|
dispatch({
|
|
138
171
|
type: 'SET_SCHEDULED_RETURN_FILTER',
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
// import OrderTable from './table/OrderTable';
|
|
4
|
+
// import ReturnOrderFilter from './table-filters/ReturnOrderFilter';
|
|
5
|
+
// import { useAtom, useReturnAfterOrderData } from '../../order-view/store';
|
|
6
|
+
// import {
|
|
7
|
+
// useItemsPerReturnPage,
|
|
8
|
+
// useLoading,
|
|
9
|
+
// UsePaginationData,
|
|
10
|
+
// UsePaginationReturnData,
|
|
11
|
+
// } from '../store/store';
|
|
12
|
+
// import { ApiResponse } from '../common/interface';
|
|
13
|
+
// import { useAxios } from '@bjsdistribution/dms-component-library';
|
|
14
|
+
// import { filtersReducerReturnAtom } from './table-filters/ReturnFilterStore';
|
|
15
|
+
// import { notification } from 'antd';
|
|
16
|
+
// import ReturnPagination from '../table-view/ReturnPagination';
|
|
17
|
+
import {
|
|
18
|
+
useAtom,
|
|
19
|
+
// useCallApiAgain,
|
|
20
|
+
useReturnConfirmedOrderData,
|
|
21
|
+
useSearchAfterText,
|
|
22
|
+
} from '../../store';
|
|
23
|
+
import ReturnConfirmedTable from './ReturnConfirmedTable';
|
|
24
|
+
import {
|
|
25
|
+
useItemsPerReturnPage,
|
|
26
|
+
useLoading,
|
|
27
|
+
UsePaginationData,
|
|
28
|
+
UsePaginationReturnData,
|
|
29
|
+
} from '../../order-daily-overview/store/store';
|
|
30
|
+
import { filtersReducerReturnAtom } from '../../order-daily-overview/return-after-table/table-filters/ReturnFilterStore';
|
|
31
|
+
import { useAxios } from '@bjsdistribution/dms-component-library';
|
|
32
|
+
import { ApiResponse } from '../../types';
|
|
33
|
+
import { notification } from 'antd';
|
|
34
|
+
import ReturnPagination from '../../order-daily-overview/table-view/ReturnPagination';
|
|
35
|
+
import { useParams } from 'react-router-dom';
|
|
36
|
+
|
|
37
|
+
const ConfirmedMain = () => {
|
|
38
|
+
const [, setReturnConfirmedData] = useReturnConfirmedOrderData();
|
|
39
|
+
const [, setLoading] = useLoading();
|
|
40
|
+
const [state] = useAtom(filtersReducerReturnAtom);
|
|
41
|
+
// const [callApi] = useCallApiAgain();
|
|
42
|
+
const { 'x-filters': filters, 'x-pagination': pagination } = state;
|
|
43
|
+
const [paginationObj] = UsePaginationReturnData();
|
|
44
|
+
const [, setCurrentPage] = useState(1);
|
|
45
|
+
const [itemsPerPage, setItemsPerPage] = useItemsPerReturnPage();
|
|
46
|
+
const [, setPaginationObject] = UsePaginationData();
|
|
47
|
+
const { page, total } = paginationObj;
|
|
48
|
+
const [debouncedSearchText] = useSearchAfterText();
|
|
49
|
+
const handlePageChange = (page: number) => {
|
|
50
|
+
setCurrentPage(page);
|
|
51
|
+
};
|
|
52
|
+
const handleItemsPerPageChange = (itemsPerPage: number) => {
|
|
53
|
+
setItemsPerPage(itemsPerPage);
|
|
54
|
+
};
|
|
55
|
+
const { status } = useParams();
|
|
56
|
+
|
|
57
|
+
const {
|
|
58
|
+
data: fetchedReturnOrderData,
|
|
59
|
+
loading,
|
|
60
|
+
paginationData,
|
|
61
|
+
fetchData,
|
|
62
|
+
} = useAxios<ApiResponse>({
|
|
63
|
+
endpoint: '/v1/return/orders/',
|
|
64
|
+
method: 'GET',
|
|
65
|
+
filters: filters && filters?.length > 0 ? filters : undefined,
|
|
66
|
+
pagination: pagination,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
const shouldFetch = debouncedSearchText === '' && filters?.length > 0;
|
|
71
|
+
|
|
72
|
+
if (shouldFetch) {
|
|
73
|
+
fetchData();
|
|
74
|
+
}
|
|
75
|
+
}, [debouncedSearchText, status, JSON.stringify(filters)]);
|
|
76
|
+
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
setLoading(loading);
|
|
79
|
+
|
|
80
|
+
if (fetchedReturnOrderData?.data) {
|
|
81
|
+
setReturnConfirmedData(fetchedReturnOrderData?.data);
|
|
82
|
+
|
|
83
|
+
if (paginationData) {
|
|
84
|
+
try {
|
|
85
|
+
const { count, ...rest } = JSON.parse(paginationData);
|
|
86
|
+
setPaginationObject(rest);
|
|
87
|
+
} catch (error) {
|
|
88
|
+
notification.error({
|
|
89
|
+
message: 'Error',
|
|
90
|
+
description: 'Failed to parse pagination data',
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}, [fetchedReturnOrderData, loading]);
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<div>
|
|
99
|
+
<DashBoardWrapper>
|
|
100
|
+
{/* <RouterHeader /> */}
|
|
101
|
+
<div className="Tableconatiner">
|
|
102
|
+
{/* <HeaderFilter /> */}
|
|
103
|
+
<Container>
|
|
104
|
+
<ReturnConfirmedTable />
|
|
105
|
+
{total > 0 && (
|
|
106
|
+
<ReturnPagination
|
|
107
|
+
currentPage={page}
|
|
108
|
+
totalItems={total}
|
|
109
|
+
itemsPerPage={itemsPerPage}
|
|
110
|
+
onPageChange={handlePageChange}
|
|
111
|
+
onItemsPerPageChange={handleItemsPerPageChange}
|
|
112
|
+
></ReturnPagination>
|
|
113
|
+
)}
|
|
114
|
+
</Container>
|
|
115
|
+
</div>
|
|
116
|
+
</DashBoardWrapper>
|
|
117
|
+
</div>
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
const Container = styled.div`
|
|
121
|
+
position: relative;
|
|
122
|
+
/* top: -30px; */
|
|
123
|
+
`;
|
|
124
|
+
const DashBoardWrapper = styled.section`
|
|
125
|
+
.Tableconatiner {
|
|
126
|
+
border-radius: 12px;
|
|
127
|
+
background: #fff;
|
|
128
|
+
box-shadow: -2px 0px 12px 0px rgba(56, 71, 109, 0.1);
|
|
129
|
+
display: block;
|
|
130
|
+
padding: 15px 20px;
|
|
131
|
+
}
|
|
132
|
+
.headerWrap,
|
|
133
|
+
.tableData,
|
|
134
|
+
.styleCovered {
|
|
135
|
+
transition: all ease 0.5s;
|
|
136
|
+
}
|
|
137
|
+
&.stickyTableHead {
|
|
138
|
+
h2 {
|
|
139
|
+
font-size: 21px;
|
|
140
|
+
}
|
|
141
|
+
.headerWrap {
|
|
142
|
+
height: 84px;
|
|
143
|
+
padding: 10px;
|
|
144
|
+
border-radius: 0px 0px 15px 15px;
|
|
145
|
+
> div {
|
|
146
|
+
position: relative;
|
|
147
|
+
z-index: 10;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
.styleCovered {
|
|
151
|
+
margin-top: -32px;
|
|
152
|
+
width: 67%;
|
|
153
|
+
float: right;
|
|
154
|
+
gap: 5px;
|
|
155
|
+
padding-right: 11px;
|
|
156
|
+
|
|
157
|
+
li {
|
|
158
|
+
padding: 4px 10px 5px 5px;
|
|
159
|
+
gap: 5px;
|
|
160
|
+
.svgCover {
|
|
161
|
+
width: 30px;
|
|
162
|
+
height: 30px;
|
|
163
|
+
svg {
|
|
164
|
+
height: auto;
|
|
165
|
+
width: 58%;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
.countDigit {
|
|
169
|
+
font-size: 19px;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
.countMess {
|
|
173
|
+
font-size: 13px;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
.dmsBulkFilter {
|
|
177
|
+
min-height: unset;
|
|
178
|
+
gap: 4px;
|
|
179
|
+
> div {
|
|
180
|
+
padding: 4px 12px;
|
|
181
|
+
label {
|
|
182
|
+
font-size: 11px;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.StyledFilterList {
|
|
188
|
+
gap: 4px;
|
|
189
|
+
li {
|
|
190
|
+
height: 29px;
|
|
191
|
+
padding: 3px 8px;
|
|
192
|
+
gap: 4px;
|
|
193
|
+
.StyledFilterBtnIcon {
|
|
194
|
+
width: 20px;
|
|
195
|
+
height: 20px;
|
|
196
|
+
svh {
|
|
197
|
+
width: 10px;
|
|
198
|
+
height: auto;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
.StyledFilterBtnLabel {
|
|
202
|
+
font-size: 13px;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
.StyledFilterLabel {
|
|
207
|
+
padding-left: 10px;
|
|
208
|
+
span {
|
|
209
|
+
font-size: 13px;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
.cardcontainer.tableData {
|
|
213
|
+
max-height: calc(100vh - 310px);
|
|
214
|
+
min-height: calc(100vh - 310px);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.tableData {
|
|
218
|
+
max-height: calc(100vh - 320px);
|
|
219
|
+
min-height: calc(100vh - 320px);
|
|
220
|
+
|
|
221
|
+
margin-top: 8px;
|
|
222
|
+
thead {
|
|
223
|
+
position: sticky;
|
|
224
|
+
top: 0;
|
|
225
|
+
z-index: 9;
|
|
226
|
+
th {
|
|
227
|
+
font-size: 13px;
|
|
228
|
+
padding: 2px 15px;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
`;
|
|
234
|
+
|
|
235
|
+
export default ConfirmedMain;
|