@bjsdistribution/dms-client-return 0.1.16-prod → 0.1.17-prod
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/common/date-picker/header/ClearDate.d.ts +1 -1
- package/dist/components/client-portal/DateFilterStore.d.ts +15 -0
- package/dist/components/client-portal/ReturnRTFilters.d.ts +3 -0
- package/dist/components/order-daily-overview/header/route-header/ClientRouterHeader.d.ts +11 -0
- package/dist/components/order-daily-overview/table-view/TableStyle.d.ts +4 -4
- package/dist/components/order-view/order-actions/types.d.ts +2 -2
- package/dist/components/order-view/types.d.ts +6 -0
- package/dist/components/order-view/utils.d.ts +8 -2
- package/dist/components/order-view/view-reminder/ViewReminder.d.ts +2 -0
- package/dist/dms-client-return.cjs.development.js +1780 -2272
- 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 +1838 -2330
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/client-portal/DateFilterStore.ts +139 -0
- package/src/components/client-portal/OutstandingTable.tsx +16 -72
- package/src/components/client-portal/ReturnAfterSearchBar.tsx +42 -87
- package/src/components/client-portal/ReturnOverview.tsx +11 -2
- package/src/components/client-portal/ReturnRTFilters.tsx +140 -43
- package/src/components/client-portal/ReturnSearchBar.tsx +42 -153
- package/src/components/client-portal/ReturnStatus.tsx +30 -66
- package/src/components/client-portal/return-confirm/ConfirmedMain.tsx +12 -23
- package/src/components/client-portal/return-confirm/ReturnConfirmedTable.tsx +9 -86
- package/src/components/order-daily-overview/header/route-header/ClientRouterHeader.tsx +166 -0
- package/src/components/order-daily-overview/header/route-header/RouterHeader.tsx +2 -86
- package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +5 -2
- package/src/components/order-daily-overview/index.tsx +16 -4
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.ts +36 -36
- package/src/components/order-view/notification/ReminderTemplate.tsx +13 -5
- package/src/components/order-view/order-actions/actions/confirm-order/index.tsx +0 -29
- package/src/components/order-view/order-actions/actions/create-task-reminder/CreateReminderModal.tsx +86 -28
- package/src/components/order-view/order-actions/actions/force-debrief/ForceDebriefModal.tsx +35 -20
- package/src/components/order-view/order-actions/actions/force-debrief/order-info/RadioButtons.tsx +11 -62
- package/src/components/order-view/order-actions/index.tsx +1 -5
- package/src/components/order-view/order-actions/types.ts +2 -2
- package/src/components/order-view/order-details/expanded-content/footer/index.tsx +55 -80
- package/src/components/order-view/order-details/expanded-content/services-section/AssemblyType.tsx +9 -91
- package/src/components/order-view/order-details/expanded-content/services-section/OrderServices.tsx +10 -182
- package/src/components/order-view/store.ts +6 -0
- package/src/components/order-view/types.ts +6 -0
- package/src/components/order-view/utils.ts +0 -33
- package/src/components/order-view/view-reminder/AssigneeDropdown.tsx +85 -26
- package/src/components/order-view/view-reminder/ViewReminder.tsx +33 -14
- package/src/components/store.ts +1 -1
- package/src/index.tsx +17 -2
- package/dist/components/order-view/order-actions/actions/log-service-refusal/DeliveryPoint.d.ts +0 -7
- package/dist/components/order-view/order-actions/actions/log-service-refusal/Notes.d.ts +0 -7
- package/dist/components/order-view/order-actions/actions/log-service-refusal/OrderServices.d.ts +0 -7
- package/dist/components/order-view/order-actions/actions/log-service-refusal/helper.d.ts +0 -3
- package/dist/components/order-view/order-actions/actions/log-service-refusal/index.d.ts +0 -3
- package/src/components/order-view/order-actions/actions/log-service-refusal/DeliveryPoint.tsx +0 -50
- package/src/components/order-view/order-actions/actions/log-service-refusal/Notes.tsx +0 -50
- package/src/components/order-view/order-actions/actions/log-service-refusal/OrderServices.tsx +0 -57
- package/src/components/order-view/order-actions/actions/log-service-refusal/helper.ts +0 -26
- package/src/components/order-view/order-actions/actions/log-service-refusal/index.tsx +0 -130
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.1.
|
|
2
|
+
"version": "0.1.17-prod",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"testEnvironment": "jest-environment-jsdom-sixteen"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@bjsdistribution/dms-component-library": "0.3.
|
|
62
|
+
"@bjsdistribution/dms-component-library": "0.3.50-staging",
|
|
63
63
|
"@size-limit/preset-small-lib": "^11.0.1",
|
|
64
64
|
"@tippyjs/react": "^4.2.6",
|
|
65
65
|
"@types/react": "^18.2.47",
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { atom } from 'jotai';
|
|
2
|
+
|
|
3
|
+
interface Filter {
|
|
4
|
+
field: string;
|
|
5
|
+
op: string;
|
|
6
|
+
value: any;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface Pagination {
|
|
10
|
+
page: number;
|
|
11
|
+
per_page: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface FilterState {
|
|
15
|
+
'x-filters': Filter[];
|
|
16
|
+
'x-pagination': Pagination;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const initialState: FilterState = {
|
|
20
|
+
'x-filters': [],
|
|
21
|
+
'x-pagination': { page: 1, per_page: 50 },
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const overviewFilterReducer = (
|
|
25
|
+
state: FilterState,
|
|
26
|
+
action: any
|
|
27
|
+
): FilterState => {
|
|
28
|
+
switch (action.type) {
|
|
29
|
+
case 'SET_CP_DATE_FILTER': {
|
|
30
|
+
const { startDate, endDate } = action.payload;
|
|
31
|
+
|
|
32
|
+
const filters: Filter[] = [];
|
|
33
|
+
|
|
34
|
+
if (startDate) {
|
|
35
|
+
filters.push({
|
|
36
|
+
field: 'created_at',
|
|
37
|
+
op: '>=',
|
|
38
|
+
value: `${startDate}T00:00:00+00:00`,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (endDate) {
|
|
43
|
+
filters.push({
|
|
44
|
+
field: 'created_at',
|
|
45
|
+
op: '<=',
|
|
46
|
+
value: `${endDate}T23:59:59+00:00`,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
...state,
|
|
52
|
+
'x-filters': [
|
|
53
|
+
...state['x-filters'].filter(f => f.field !== 'created_at'),
|
|
54
|
+
...filters,
|
|
55
|
+
],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//client portal
|
|
60
|
+
case 'SET_SCHEDULED_RETURN_FILTER':
|
|
61
|
+
if (action.payload) {
|
|
62
|
+
return {
|
|
63
|
+
...state,
|
|
64
|
+
'x-filters': [
|
|
65
|
+
...state['x-filters'].filter(f => f.field !== 'order_status'),
|
|
66
|
+
{
|
|
67
|
+
field: 'order_status',
|
|
68
|
+
op: '=',
|
|
69
|
+
value: action.payload,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
};
|
|
73
|
+
} else {
|
|
74
|
+
return {
|
|
75
|
+
...state,
|
|
76
|
+
'x-filters': state['x-filters'].filter(
|
|
77
|
+
f => f.field !== 'order_status'
|
|
78
|
+
),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
case 'SET_RETURN_COMPLETED_FILTER':
|
|
83
|
+
if (action.payload) {
|
|
84
|
+
return {
|
|
85
|
+
...state,
|
|
86
|
+
'x-filters': [
|
|
87
|
+
...state['x-filters'].filter(f => f.field !== 'order_status'),
|
|
88
|
+
{
|
|
89
|
+
field: 'order_status',
|
|
90
|
+
op: '=',
|
|
91
|
+
value: action.payload,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
};
|
|
95
|
+
} else {
|
|
96
|
+
return {
|
|
97
|
+
...state,
|
|
98
|
+
'x-filters': state['x-filters'].filter(
|
|
99
|
+
f => f.field !== 'order_status'
|
|
100
|
+
),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
case 'SET_PAGE':
|
|
105
|
+
return {
|
|
106
|
+
...state,
|
|
107
|
+
'x-pagination': {
|
|
108
|
+
...state['x-pagination'],
|
|
109
|
+
page: action.payload,
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
case 'SET_PERPAGE':
|
|
114
|
+
return {
|
|
115
|
+
...state,
|
|
116
|
+
'x-pagination': {
|
|
117
|
+
...state['x-pagination'],
|
|
118
|
+
per_page: action.payload,
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
case 'CLEAR_FILTERS':
|
|
122
|
+
return {
|
|
123
|
+
...state,
|
|
124
|
+
};
|
|
125
|
+
default:
|
|
126
|
+
return state;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const overviewfiltersStateAtom = atom(initialState);
|
|
131
|
+
|
|
132
|
+
export const dateFilterCPReducer = atom(
|
|
133
|
+
get => get(overviewfiltersStateAtom),
|
|
134
|
+
(get, set, action) =>
|
|
135
|
+
set(
|
|
136
|
+
overviewfiltersStateAtom,
|
|
137
|
+
overviewFilterReducer(get(overviewfiltersStateAtom), action)
|
|
138
|
+
)
|
|
139
|
+
);
|
|
@@ -7,17 +7,14 @@ import { Empty, notification, Skeleton } from 'antd';
|
|
|
7
7
|
import { format } from 'date-fns';
|
|
8
8
|
import { useAtom } from 'jotai';
|
|
9
9
|
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
10
|
-
import { NavLink
|
|
11
|
-
import dayjs from 'dayjs';
|
|
10
|
+
import { NavLink } from 'react-router-dom';
|
|
12
11
|
import { filtersReducerAtom } from '../order-daily-overview/header-filters/filterStore';
|
|
13
12
|
import {
|
|
14
13
|
useClientOutstandingReturnData,
|
|
15
14
|
useClientPortal,
|
|
16
|
-
useEndDate,
|
|
17
15
|
useLocationData,
|
|
18
16
|
useSearchText,
|
|
19
17
|
useSelectedClientPortOrders,
|
|
20
|
-
useStartDate,
|
|
21
18
|
} from '../store';
|
|
22
19
|
import { usefetchAgain } from '../order-view/store';
|
|
23
20
|
import {
|
|
@@ -37,10 +34,11 @@ import {
|
|
|
37
34
|
import PrinterIcon from '../../assets/icons/PrinterIcon';
|
|
38
35
|
import DownIcon from '../../assets/icons/DownIcon';
|
|
39
36
|
import PrintDropDownReturn from '../order-view/details-filters/left-side-filters/dropdowns/PrintDropDownReturn';
|
|
37
|
+
import { dateFilterCPReducer } from './DateFilterStore';
|
|
40
38
|
|
|
41
39
|
const OutstandingTable = () => {
|
|
42
|
-
const [
|
|
43
|
-
const { 'x-pagination': pagination } =
|
|
40
|
+
const [statePagination] = useAtom(filtersReducerAtom);
|
|
41
|
+
const { 'x-pagination': pagination } = statePagination;
|
|
44
42
|
const [
|
|
45
43
|
outstandingReturnData,
|
|
46
44
|
setOutstandingReturnData,
|
|
@@ -53,11 +51,13 @@ const OutstandingTable = () => {
|
|
|
53
51
|
const [, setPaginationObject] = UsePaginationData();
|
|
54
52
|
const [callForFetch] = usefetchAgain();
|
|
55
53
|
const [clientPortal] = useClientPortal();
|
|
56
|
-
const { status } = useParams();
|
|
57
54
|
const [selectedOrderIds, setSelectedOrderIds] = useSelectedClientPortOrders();
|
|
58
55
|
const [selectClientAll, setSelectClientAll] = useState(false);
|
|
59
56
|
const [debouncedSearchText] = useSearchText();
|
|
60
57
|
|
|
58
|
+
const [state] = useAtom(dateFilterCPReducer);
|
|
59
|
+
const { 'x-filters': filters } = state;
|
|
60
|
+
|
|
61
61
|
//sorting
|
|
62
62
|
const [sortConfig, setSortConfig] = useState<{
|
|
63
63
|
key: string;
|
|
@@ -123,56 +123,13 @@ const OutstandingTable = () => {
|
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (!clientPortal) return [];
|
|
132
|
-
|
|
133
|
-
const stored = JSON.parse(localStorage.getItem('returnDate') || '{}');
|
|
134
|
-
|
|
135
|
-
const sDate = startDate?.isValid?.() ? startDate : dayjs(stored?.startDate);
|
|
136
|
-
const eDate = endDate?.isValid?.()
|
|
137
|
-
? endDate
|
|
138
|
-
: stored?.endDate
|
|
139
|
-
? dayjs(stored?.endDate)
|
|
140
|
-
: null;
|
|
141
|
-
|
|
142
|
-
if (!sDate?.isValid?.()) return [];
|
|
143
|
-
|
|
144
|
-
let dateFilters: any[] = [];
|
|
145
|
-
|
|
146
|
-
if (eDate && eDate.isValid()) {
|
|
147
|
-
dateFilters = [
|
|
148
|
-
{ field: 'created_at', op: '>=', value: sDate.format('YYYY-MM-DD') },
|
|
149
|
-
{
|
|
150
|
-
field: 'created_at',
|
|
151
|
-
op: '<=',
|
|
152
|
-
value: eDate.add(1, 'day').format('YYYY-MM-DD'),
|
|
153
|
-
},
|
|
154
|
-
];
|
|
155
|
-
} else {
|
|
156
|
-
dateFilters = [
|
|
157
|
-
{
|
|
158
|
-
field: 'created_at',
|
|
159
|
-
op: '=',
|
|
160
|
-
value: sDate.format('YYYY-MM-DD'),
|
|
161
|
-
},
|
|
162
|
-
];
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const baseFilters: any[] =
|
|
166
|
-
status === 'outstanding_return'
|
|
167
|
-
? [
|
|
168
|
-
{ field: 'isdeleted', op: '=', value: 0 },
|
|
169
|
-
{ field: 'product_return_action_id', op: '=', value: 'RTS' },
|
|
170
|
-
]
|
|
171
|
-
: [];
|
|
172
|
-
|
|
173
|
-
return [...baseFilters, ...dateFilters];
|
|
174
|
-
}, [startDate, endDate, status]);
|
|
126
|
+
const cleanedFilters = filters.filter(f => f.field !== 'order_status');
|
|
127
|
+
const baseFilters = [
|
|
128
|
+
{ field: 'isdeleted', op: '=', value: 0 },
|
|
129
|
+
{ field: 'product_return_action_id', op: '=', value: 'RTS' },
|
|
130
|
+
];
|
|
175
131
|
|
|
132
|
+
const modifiedFilters = [...baseFilters, ...cleanedFilters];
|
|
176
133
|
const {
|
|
177
134
|
data: fetchedOrderData,
|
|
178
135
|
loading: returnDataLoad,
|
|
@@ -181,27 +138,15 @@ const OutstandingTable = () => {
|
|
|
181
138
|
} = useAxios<ApiResponse>({
|
|
182
139
|
endpoint: '/v1/return/product/pending/',
|
|
183
140
|
method: 'GET',
|
|
184
|
-
filters:
|
|
141
|
+
filters: modifiedFilters,
|
|
185
142
|
pagination: pagination,
|
|
186
143
|
});
|
|
187
|
-
console.log(filters, 'outstanding filters');
|
|
188
|
-
const hasFetchedRef = useRef(false);
|
|
189
144
|
|
|
190
145
|
useEffect(() => {
|
|
191
|
-
|
|
192
|
-
clientPortal &&
|
|
193
|
-
debouncedSearchText === '' &&
|
|
194
|
-
filters?.length > 0 &&
|
|
195
|
-
!hasFetchedRef.current;
|
|
196
|
-
|
|
197
|
-
if (shouldFetch) {
|
|
146
|
+
if (clientPortal && debouncedSearchText === '') {
|
|
198
147
|
fetchData();
|
|
199
|
-
hasFetchedRef.current = true;
|
|
200
148
|
}
|
|
201
|
-
}, [
|
|
202
|
-
useEffect(() => {
|
|
203
|
-
hasFetchedRef.current = false;
|
|
204
|
-
}, [debouncedSearchText, filters]);
|
|
149
|
+
}, [JSON.stringify(modifiedFilters), debouncedSearchText]);
|
|
205
150
|
|
|
206
151
|
useEffect(() => {
|
|
207
152
|
setLoading(returnDataLoad);
|
|
@@ -227,7 +172,6 @@ const OutstandingTable = () => {
|
|
|
227
172
|
}
|
|
228
173
|
}, [fetchedOrderData, returnDataLoad]);
|
|
229
174
|
|
|
230
|
-
// console.log(modifiedFilters, 'modifiedFilters');
|
|
231
175
|
useEffect(() => {
|
|
232
176
|
setLoading(returnDataLoad);
|
|
233
177
|
if (fetchedOrderData && fetchedOrderData?.data && locationData) {
|
|
@@ -8,10 +8,8 @@ import styled from 'styled-components';
|
|
|
8
8
|
import {
|
|
9
9
|
useAtom,
|
|
10
10
|
useClientPortal,
|
|
11
|
-
useEndDate,
|
|
12
11
|
useReturnConfirmedOrderData,
|
|
13
12
|
useSearchAfterText,
|
|
14
|
-
useStartDate,
|
|
15
13
|
useStatsCPCount,
|
|
16
14
|
} from '../store';
|
|
17
15
|
|
|
@@ -20,38 +18,37 @@ import { javascriptStringDumpToJSON } from '../utils';
|
|
|
20
18
|
import { UsePaginationData } from '../order-daily-overview/store/store';
|
|
21
19
|
import { notification } from 'antd';
|
|
22
20
|
import { filtersReducerReturnAtom } from '../order-daily-overview/return-after-table/table-filters/ReturnFilterStore';
|
|
23
|
-
import dayjs from 'dayjs';
|
|
24
21
|
import { returnCountType } from './ReturnStatus';
|
|
25
22
|
import { useParams } from 'react-router-dom';
|
|
23
|
+
import { dateFilterCPReducer } from './DateFilterStore';
|
|
26
24
|
|
|
27
25
|
function ReturnAfterSearchBar() {
|
|
28
26
|
const [searchText, setSearchText] = useState('');
|
|
29
27
|
const [debouncedSearchText, setDebouncedSearchText] = useSearchAfterText();
|
|
30
28
|
const [, setReturnConfirmedData] = useReturnConfirmedOrderData();
|
|
31
|
-
//condition on client view
|
|
32
29
|
const [, setPaginationObject] = UsePaginationData();
|
|
30
|
+
|
|
31
|
+
const [statePagination] = useAtom(filtersReducerReturnAtom);
|
|
32
|
+
const { 'x-pagination': pagination } = statePagination;
|
|
33
|
+
const [, setCount] = useStatsCPCount();
|
|
34
|
+
const [clientPortal] = useClientPortal();
|
|
35
|
+
const [state] = useAtom(dateFilterCPReducer);
|
|
36
|
+
const { 'x-filters': filters } = state;
|
|
37
|
+
const { status } = useParams();
|
|
38
|
+
|
|
33
39
|
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
34
40
|
setSearchText(event.target.value);
|
|
35
41
|
};
|
|
36
|
-
//CP
|
|
37
|
-
const [modifiedStatsFilters, setModifiedStatsFilters] = useState<any[]>([]);
|
|
38
|
-
const [startDate] = useStartDate();
|
|
39
|
-
const [endDate] = useEndDate();
|
|
40
|
-
const [state] = useAtom(filtersReducerReturnAtom);
|
|
41
|
-
const { 'x-filters': filters, 'x-pagination': pagination } = state;
|
|
42
|
-
const [count, setCount] = useStatsCPCount();
|
|
43
|
-
const [clientPortal] = useClientPortal();
|
|
44
|
-
const { status } = useParams();
|
|
45
42
|
|
|
46
43
|
const { paginationData, fetchData: returnAfterCall } = useAxios<ApiResponse>({
|
|
47
44
|
endpoint: '/v1/return/orders/',
|
|
48
45
|
method: 'GET',
|
|
49
|
-
filters: filters
|
|
46
|
+
filters: filters,
|
|
50
47
|
pagination: pagination,
|
|
51
48
|
});
|
|
52
49
|
|
|
53
50
|
useEffect(() => {
|
|
54
|
-
if (debouncedSearchText?.length >
|
|
51
|
+
if (debouncedSearchText?.length > 2) {
|
|
55
52
|
returnAfterCall({
|
|
56
53
|
endPointQuery: `?search_term=${debouncedSearchText}`,
|
|
57
54
|
}).then((response: any) => {
|
|
@@ -76,7 +73,8 @@ function ReturnAfterSearchBar() {
|
|
|
76
73
|
message: 'Search Phrase cannot be less than 3 characters',
|
|
77
74
|
});
|
|
78
75
|
}
|
|
79
|
-
}, [debouncedSearchText]);
|
|
76
|
+
}, [debouncedSearchText, JSON.stringify(filters)]);
|
|
77
|
+
|
|
80
78
|
// Debouncing effect
|
|
81
79
|
useEffect(() => {
|
|
82
80
|
const handler = setTimeout(() => {
|
|
@@ -92,70 +90,31 @@ function ReturnAfterSearchBar() {
|
|
|
92
90
|
setSearchText('');
|
|
93
91
|
}
|
|
94
92
|
}, [debouncedSearchText]);
|
|
93
|
+
const cleanedFilters = filters.filter(f => f.field !== 'order_status');
|
|
95
94
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const getDateFilters = (
|
|
99
|
-
startDate: dayjs.Dayjs | null,
|
|
100
|
-
endDate: dayjs.Dayjs | null
|
|
101
|
-
) => {
|
|
102
|
-
const stored = JSON.parse(localStorage.getItem('returnDate') || '{}');
|
|
103
|
-
|
|
104
|
-
const sDate = startDate?.isValid?.() ? startDate : dayjs(stored?.startDate);
|
|
105
|
-
const eDate = endDate?.isValid?.()
|
|
106
|
-
? endDate
|
|
107
|
-
: stored?.endDate
|
|
108
|
-
? dayjs(stored?.endDate)
|
|
109
|
-
: null;
|
|
110
|
-
|
|
111
|
-
if (!sDate?.isValid?.()) return [];
|
|
112
|
-
|
|
113
|
-
let dateFilters = [];
|
|
114
|
-
|
|
115
|
-
if (eDate && eDate.isValid()) {
|
|
116
|
-
dateFilters = [
|
|
117
|
-
{ field: 'created_at', op: '>=', value: sDate.format('YYYY-MM-DD') },
|
|
118
|
-
{
|
|
119
|
-
field: 'created_at',
|
|
120
|
-
op: '<=',
|
|
121
|
-
value: eDate.add(1, 'day').format('YYYY-MM-DD'),
|
|
122
|
-
},
|
|
123
|
-
];
|
|
124
|
-
} else {
|
|
125
|
-
dateFilters = [
|
|
126
|
-
{
|
|
127
|
-
field: 'created_at',
|
|
128
|
-
op: '=',
|
|
129
|
-
value: sDate.format('YYYY-MM-DD'),
|
|
130
|
-
},
|
|
131
|
-
];
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return dateFilters;
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
useEffect(() => {
|
|
138
|
-
if (!clientPortal) return;
|
|
139
|
-
|
|
140
|
-
const dateFilters = getDateFilters(startDate, endDate);
|
|
141
|
-
setModifiedStatsFilters(dateFilters);
|
|
142
|
-
}, [startDate, endDate]);
|
|
143
|
-
|
|
144
|
-
const { data: statsData, fetchData: fetchStatsData } = useAxios<{
|
|
95
|
+
const { fetchData: fetchStatsData } = useAxios<{
|
|
145
96
|
data: returnCountType[];
|
|
146
97
|
}>({
|
|
147
98
|
endpoint: `v1/portal/return/stats/`,
|
|
148
99
|
method: 'GET',
|
|
149
100
|
pagination: { is_pagination: false },
|
|
150
|
-
filters:
|
|
101
|
+
filters: [...cleanedFilters],
|
|
151
102
|
});
|
|
152
103
|
|
|
153
104
|
useEffect(() => {
|
|
154
105
|
const validStatuses = ['scheduled_for_return', 'return_completed'];
|
|
155
106
|
const isClientView = clientPortal && validStatuses.includes(status || '');
|
|
156
107
|
|
|
157
|
-
if (!isClientView
|
|
158
|
-
|
|
108
|
+
if (!isClientView) return;
|
|
109
|
+
|
|
110
|
+
const trimmedText = debouncedSearchText?.trim() || '';
|
|
111
|
+
if (trimmedText.length > 0 && trimmedText.length <= 2) {
|
|
112
|
+
notification.warning({
|
|
113
|
+
message: 'Search phrase cannot be less than 2 characters',
|
|
114
|
+
});
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (trimmedText.length === 0) return;
|
|
159
118
|
const statusTypeMap: Record<string, string> = {
|
|
160
119
|
scheduled_for_return: 'scheduled',
|
|
161
120
|
return_completed: 'complete',
|
|
@@ -163,26 +122,22 @@ function ReturnAfterSearchBar() {
|
|
|
163
122
|
|
|
164
123
|
const type = statusTypeMap[status as keyof typeof statusTypeMap];
|
|
165
124
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
125
|
+
fetchStatsData({
|
|
126
|
+
endPointQuery: `?search_term=${trimmedText}&type=${type}`,
|
|
127
|
+
})
|
|
128
|
+
.then((response: any) => {
|
|
129
|
+
if (response?.data) {
|
|
130
|
+
console.log('inside response', response);
|
|
131
|
+
setCount(response.data);
|
|
132
|
+
} else {
|
|
133
|
+
setCount(null);
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
.catch((error: any) => {
|
|
137
|
+
console.error('Error fetching stats:', error);
|
|
176
138
|
setCount(null);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
fetchStats();
|
|
181
|
-
}, [debouncedSearchText, status, clientPortal]);
|
|
182
|
-
|
|
183
|
-
console.log(statsData, 'statsData');
|
|
184
|
-
|
|
185
|
-
console.log(count, 'new count');
|
|
139
|
+
});
|
|
140
|
+
}, [debouncedSearchText, status]);
|
|
186
141
|
|
|
187
142
|
const handleClear = () => {
|
|
188
143
|
setSearchText('');
|
|
@@ -9,9 +9,9 @@ import {
|
|
|
9
9
|
} from '../order-daily-overview/store/store';
|
|
10
10
|
import { useClientPortal } from '../store';
|
|
11
11
|
import { useParams } from 'react-router-dom';
|
|
12
|
-
import RouterHeader from '../order-daily-overview/header/route-header/RouterHeader';
|
|
13
12
|
import OutstandingTable from './OutstandingTable';
|
|
14
13
|
import ConfirmedMain from './return-confirm/ConfirmedMain';
|
|
14
|
+
import ClientRouterHeader from '../order-daily-overview/header/route-header/ClientRouterHeader';
|
|
15
15
|
|
|
16
16
|
const ReturnOverview = () => {
|
|
17
17
|
const [paginationObj] = UsePaginationData();
|
|
@@ -32,9 +32,18 @@ const ReturnOverview = () => {
|
|
|
32
32
|
const shouldShowReturnAfterTable =
|
|
33
33
|
(clientPortal && status === 'scheduled_for_return') ||
|
|
34
34
|
(clientPortal && status === 'return_completed');
|
|
35
|
+
|
|
36
|
+
const validStatuses = [
|
|
37
|
+
'outstanding_return',
|
|
38
|
+
'scheduled_for_return',
|
|
39
|
+
'return_completed',
|
|
40
|
+
];
|
|
41
|
+
|
|
35
42
|
return (
|
|
36
43
|
<>
|
|
37
|
-
|
|
44
|
+
{clientPortal &&
|
|
45
|
+
typeof status === 'string' &&
|
|
46
|
+
validStatuses.includes(status) && <ClientRouterHeader />}
|
|
38
47
|
<div>
|
|
39
48
|
<DashBoardWrapper>
|
|
40
49
|
<div className="Tableconatiner">
|