@bjsdistribution/dms-client-return 0.0.26 → 0.0.28
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/store.d.ts +2 -1
- package/dist/dms-client-return.cjs.development.js +47 -14
- 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 +47 -14
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +29 -5
- package/src/components/order-daily-overview/header-filters/filterStore.ts +7 -7
- package/src/components/order-view/modalsPopup/ModalManager.tsx +7 -1
- package/src/components/store.ts +7 -0
- package/src/index.tsx +2 -5
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import { atom, useAtom } from 'jotai';
|
|
12
12
|
import {
|
|
13
13
|
useActionType,
|
|
14
|
+
useClearState,
|
|
14
15
|
useCustomerData,
|
|
15
16
|
useGroupedPayload,
|
|
16
17
|
useLocationData,
|
|
@@ -57,6 +58,7 @@ function SelectionFilter() {
|
|
|
57
58
|
const [, setSelectedReturnOrder] = useSelectedOrders();
|
|
58
59
|
const [, setSelectAll] = useSelectAll();
|
|
59
60
|
const [, setCheck] = useSelectedConfirmLoc();
|
|
61
|
+
const [clearState, setClear] = useClearState();
|
|
60
62
|
|
|
61
63
|
//client options
|
|
62
64
|
const clientOptions = customers?.map((option: any) => ({
|
|
@@ -81,9 +83,8 @@ function SelectionFilter() {
|
|
|
81
83
|
}));
|
|
82
84
|
|
|
83
85
|
//client change
|
|
84
|
-
const handleSelectChange = (
|
|
86
|
+
const handleSelectChange = (_value: unknown, option: DefaultOptionType) => {
|
|
85
87
|
setNewPayload([]);
|
|
86
|
-
console.log(value, 'value');
|
|
87
88
|
const selectedLabel = option?.label as string;
|
|
88
89
|
const selectedValue = option?.id as number;
|
|
89
90
|
const selectedUuids = option?.uuid as string;
|
|
@@ -91,6 +92,8 @@ function SelectionFilter() {
|
|
|
91
92
|
const selectedCustomerId = option.gsit_customer_id as number;
|
|
92
93
|
setSelectedClient(selectedValue);
|
|
93
94
|
setName(selectedLabel);
|
|
95
|
+
// storedName(selectedLabel);
|
|
96
|
+
//set items in local storage
|
|
94
97
|
localStorage.setItem('clientName', selectedLabel);
|
|
95
98
|
localStorage.setItem('clientId', selectedValue.toString());
|
|
96
99
|
localStorage.setItem('account_number', selectAccountNumber);
|
|
@@ -100,11 +103,15 @@ function SelectionFilter() {
|
|
|
100
103
|
const storedCustomerId = localStorage.getItem('customer_id');
|
|
101
104
|
const storedUuid = localStorage.getItem('uuid');
|
|
102
105
|
setUuid(storedUuid);
|
|
106
|
+
|
|
107
|
+
//set payload
|
|
103
108
|
setReturnPayload((prevState: any) => ({
|
|
104
109
|
...prevState,
|
|
105
110
|
account_number: storedAccNo,
|
|
106
111
|
customer_id: storedCustomerId,
|
|
107
112
|
}));
|
|
113
|
+
|
|
114
|
+
//filtering locations
|
|
108
115
|
const filteredSubLocations = locationData
|
|
109
116
|
?.filter((subCat: any) => subCat?.customer_id === storedUuid)
|
|
110
117
|
.map((subCat: any) => ({
|
|
@@ -113,6 +120,8 @@ function SelectionFilter() {
|
|
|
113
120
|
}));
|
|
114
121
|
|
|
115
122
|
setFilteredLocationOptions(filteredSubLocations);
|
|
123
|
+
|
|
124
|
+
//clearing states
|
|
116
125
|
setUuid('');
|
|
117
126
|
setSelectedReturnOrder([]);
|
|
118
127
|
setNewPayload([]);
|
|
@@ -163,8 +172,6 @@ function SelectionFilter() {
|
|
|
163
172
|
const handleActionClick = (value: any) => {
|
|
164
173
|
setSelectedFilterValue(value);
|
|
165
174
|
};
|
|
166
|
-
const storedName = localStorage.getItem('clientName');
|
|
167
|
-
const storedClientId = localStorage.getItem('clientId');
|
|
168
175
|
|
|
169
176
|
//Apply filters
|
|
170
177
|
const applyFilters = () => {
|
|
@@ -211,6 +218,9 @@ function SelectionFilter() {
|
|
|
211
218
|
}
|
|
212
219
|
};
|
|
213
220
|
|
|
221
|
+
const storedName = localStorage.getItem('clientName');
|
|
222
|
+
const storedClientId = localStorage.getItem('clientId');
|
|
223
|
+
|
|
214
224
|
useEffect(() => {
|
|
215
225
|
if (storedClientId) {
|
|
216
226
|
dispatch({
|
|
@@ -243,7 +253,19 @@ function SelectionFilter() {
|
|
|
243
253
|
}
|
|
244
254
|
}, [selectedFilterValue, selectedLocationValue]);
|
|
245
255
|
|
|
246
|
-
|
|
256
|
+
const handleClear = () => {
|
|
257
|
+
setClear(false);
|
|
258
|
+
localStorage.removeItem('clientName');
|
|
259
|
+
localStorage.removeItem('clientId');
|
|
260
|
+
setClear(true);
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
useEffect(() => {
|
|
264
|
+
if (clearState) {
|
|
265
|
+
dispatch({ type: 'CLEAR_CLIENT' });
|
|
266
|
+
window.location.href = '/returnclient';
|
|
267
|
+
}
|
|
268
|
+
}, [clearState]);
|
|
247
269
|
|
|
248
270
|
return (
|
|
249
271
|
<Wrapper>
|
|
@@ -257,6 +279,8 @@ function SelectionFilter() {
|
|
|
257
279
|
onChange={handleSelectChange}
|
|
258
280
|
style={{ minWidth: '14vw' }}
|
|
259
281
|
value={storedName}
|
|
282
|
+
allowClear
|
|
283
|
+
onClear={handleClear}
|
|
260
284
|
/>
|
|
261
285
|
</FilterColumn>
|
|
262
286
|
|
|
@@ -98,13 +98,13 @@ const filterReducer = (state: FilterState, action: any): FilterState => {
|
|
|
98
98
|
],
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
101
|
+
case 'CLEAR_CLIENT':
|
|
102
|
+
return {
|
|
103
|
+
...state,
|
|
104
|
+
'x-filters': state['x-filters'].filter(
|
|
105
|
+
f => f.field !== 'order.customer_id'
|
|
106
|
+
),
|
|
107
|
+
};
|
|
108
108
|
|
|
109
109
|
case 'CLEAR_ACTION':
|
|
110
110
|
return {
|
|
@@ -219,7 +219,13 @@ const ModalManager = () => {
|
|
|
219
219
|
setShouldPerformAction(false);
|
|
220
220
|
setSelectAll(false);
|
|
221
221
|
setError(null);
|
|
222
|
-
|
|
222
|
+
|
|
223
|
+
// for local
|
|
224
|
+
// navigate('/order-return');
|
|
225
|
+
|
|
226
|
+
// for dev
|
|
227
|
+
// navigate('returnclient/order-return');
|
|
228
|
+
navigate('returnclient/order-return', { replace: true });
|
|
223
229
|
}
|
|
224
230
|
}, [response, apiError, postLoading]);
|
|
225
231
|
|
package/src/components/store.ts
CHANGED
|
@@ -51,6 +51,8 @@ const postLoading = atom<boolean>(false);
|
|
|
51
51
|
|
|
52
52
|
const final = atom<any[]>([]);
|
|
53
53
|
|
|
54
|
+
const clearState = atom<boolean>(false);
|
|
55
|
+
|
|
54
56
|
function useReminderData() {
|
|
55
57
|
return useAtom(reminderTableData);
|
|
56
58
|
}
|
|
@@ -135,6 +137,10 @@ function useFinalPayload() {
|
|
|
135
137
|
return useAtom(final);
|
|
136
138
|
}
|
|
137
139
|
|
|
140
|
+
function useClearState() {
|
|
141
|
+
return useAtom(clearState);
|
|
142
|
+
}
|
|
143
|
+
|
|
138
144
|
export {
|
|
139
145
|
useAtom,
|
|
140
146
|
useFilter,
|
|
@@ -157,4 +163,5 @@ export {
|
|
|
157
163
|
useSelectAll,
|
|
158
164
|
usePostLoading,
|
|
159
165
|
useFinalPayload,
|
|
166
|
+
useClearState,
|
|
160
167
|
};
|
package/src/index.tsx
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import React, { Suspense, useEffect } from 'react';
|
|
2
2
|
import { Route, Routes, useNavigate } from 'react-router-dom';
|
|
3
|
-
// import AddOrder from './components/add-order';
|
|
4
3
|
import OrderView from './components/order-view';
|
|
5
|
-
// import AllReminder from './components/order-view/all-reminder/AllReminder';
|
|
6
4
|
import ReturnTable from './components/order-daily-overview/return-order-table/ReturnTable';
|
|
7
5
|
import ReturnAfterTable from './components/order-daily-overview/return-after-table/ReturnAfterTable';
|
|
8
6
|
import { useTableName } from './components/order-daily-overview/store/store';
|
|
9
|
-
// import ReturnOrderTable from './components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable';
|
|
10
7
|
import ReturnMainTable from './components/order-daily-overview';
|
|
11
8
|
import { notification } from 'antd';
|
|
12
9
|
import RouterHeader from './components/order-daily-overview/header/route-header/RouterHeader';
|
|
13
10
|
import {
|
|
14
11
|
useActionType,
|
|
15
12
|
// useAtom,
|
|
16
|
-
// useAtom,
|
|
17
13
|
useCustomerData,
|
|
18
14
|
useLocationData,
|
|
19
15
|
useStatusOrderData,
|
|
@@ -35,18 +31,19 @@ function ReturnClient() {
|
|
|
35
31
|
const [, setActionType] = useActionType();
|
|
36
32
|
const [, setLocationData] = useLocationData();
|
|
37
33
|
const [, setStatusOfOrders] = useStatusOrderData();
|
|
34
|
+
// const [dispatchvalue] = useAtom(filtersReducerAtom);
|
|
38
35
|
|
|
39
36
|
const splitPath = (str: any) => {
|
|
40
37
|
const parts = str?.split('/')?.filter((part: any) => part !== ''); // Filter out empty parts
|
|
41
38
|
return parts;
|
|
42
39
|
};
|
|
43
40
|
const paths = splitPath(location.pathname);
|
|
44
|
-
|
|
45
41
|
useEffect(() => {
|
|
46
42
|
if (paths[paths.length - 1] === 'returnclient') {
|
|
47
43
|
localStorage.removeItem('clientName');
|
|
48
44
|
localStorage.removeItem('clientId');
|
|
49
45
|
localStorage.removeItem('uuid');
|
|
46
|
+
// dispatch({ type: 'CLEAR_CLIENT' });
|
|
50
47
|
}
|
|
51
48
|
}, [location.pathname]);
|
|
52
49
|
|