@bjsdistribution/dms-client-return 0.0.2 → 0.0.4
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/README.md +1 -1
- package/dist/components/order-daily-overview/common/interface.d.ts +22 -0
- package/dist/components/order-daily-overview/header-filters/Styledfilters.d.ts +1 -2
- package/dist/components/order-daily-overview/header-filters/filterStore.d.ts +16 -0
- package/dist/components/order-daily-overview/return-order-table/return-orders-filters/returnstyles.d.ts +1 -0
- package/dist/components/order-daily-overview/shared/utlis.d.ts +2 -2
- package/dist/components/order-daily-overview/store/store.d.ts +4 -0
- package/dist/components/order-daily-overview/table/table-data/styles.d.ts +2 -0
- package/dist/components/order-view/details-filters/left-side-filters/dropdowns/PrintDropDown.d.ts +3 -1
- package/dist/components/order-view/generic-table/AuditLogs.d.ts +4 -0
- package/dist/components/order-view/hooks/useGetEventNotes.d.ts +2 -0
- package/dist/components/order-view/hooks/useGetSystemLogs.d.ts +2 -0
- package/dist/components/order-view/modalsPopup/CreateReturnModal.d.ts +4 -0
- package/dist/components/order-view/notes/logs/fakeData.d.ts +7 -7
- package/dist/components/order-view/store.d.ts +23 -1
- package/dist/components/order-view/system-event-logs/columns/Code.d.ts +3 -0
- package/dist/components/order-view/system-event-logs/columns/Date.d.ts +3 -0
- package/dist/components/order-view/system-event-logs/columns/Event.d.ts +3 -0
- package/dist/components/order-view/system-event-logs/columns/Note.d.ts +3 -0
- package/dist/components/order-view/system-event-logs/columns/index.d.ts +4 -0
- package/dist/components/order-view/system-event-logs/helper.d.ts +7 -0
- package/dist/components/store.d.ts +5 -2
- package/dist/components/types.d.ts +1 -1
- package/dist/dms-client-return.cjs.development.js +3553 -2396
- 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 +3557 -2400
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/common/expand-collapse/index.tsx +3 -3
- package/src/components/fakeData.ts +14 -23
- package/src/components/order-daily-overview/common/fakedata.tsx +5 -6
- package/src/components/order-daily-overview/common/interface.ts +120 -97
- package/src/components/order-daily-overview/filters/Filters.tsx +6 -13
- package/src/components/order-daily-overview/header-filters/HeaderFilter.tsx +56 -67
- package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +170 -224
- package/src/components/order-daily-overview/header-filters/Styledfilters.tsx +20 -7
- package/src/components/order-daily-overview/header-filters/filterStore.ts +145 -0
- package/src/components/order-daily-overview/index.tsx +77 -20
- package/src/components/order-daily-overview/return-after-table/ReturnAfterTable.tsx +32 -4
- package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +184 -235
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx +69 -10
- package/src/components/order-daily-overview/return-order-table/ReturnTable.tsx +10 -3
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnFilter.tsx +9 -47
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +106 -190
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/RightFilters.tsx +35 -38
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/returnstyles.ts +69 -1
- package/src/components/order-daily-overview/store/store.ts +23 -12
- package/src/components/order-daily-overview/table/ReturnTable.tsx +133 -207
- package/src/components/order-daily-overview/table/table-data/styles.ts +15 -0
- package/src/components/order-view/details-filters/DetailsFilters.tsx +5 -4
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/DropDowns.tsx +0 -2
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/PrintDropDown.tsx +54 -46
- package/src/components/order-view/general-information/Status.tsx +1 -1
- package/src/components/order-view/generic-table/AuditLogs.tsx +96 -0
- package/src/components/order-view/hooks/useGetEventNotes.tsx +47 -0
- package/src/components/order-view/hooks/useGetSystemLogs.tsx +60 -0
- package/src/components/order-view/index.tsx +25 -4
- package/src/components/order-view/modalsPopup/CreateReturnModal.tsx +83 -0
- package/src/components/order-view/modalsPopup/ModalManager.tsx +49 -49
- package/src/components/order-view/modalsPopup/UnReceiveProduct.tsx +1 -1
- package/src/components/order-view/notes/AddNote.tsx +127 -13
- package/src/components/order-view/notes/index.tsx +100 -3
- package/src/components/order-view/notes/logs/fakeData.ts +8 -48
- package/src/components/order-view/notes/logs/index.tsx +6 -45
- package/src/components/order-view/order-actions/actions/escalation/EscalationModal.tsx +1 -1
- package/src/components/order-view/order-details/expanded-content/customer-section/RecipientName.tsx +1 -0
- package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactEmail.tsx +1 -0
- package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactHome.tsx +1 -0
- package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactMobile.tsx +1 -1
- package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactWork.tsx +1 -0
- package/src/components/order-view/order-details/expanded-content/customer-section/location-info/Address.tsx +1 -0
- package/src/components/order-view/order-details/expanded-content/customer-section/location-info/Latitude.tsx +1 -0
- package/src/components/order-view/order-details/expanded-content/customer-section/location-info/Longitude.tsx +1 -0
- package/src/components/order-view/order-details/expanded-content/customer-section/location-info/Postcode.tsx +1 -0
- package/src/components/order-view/order-details/expanded-content/customer-section/location-info/What3words.tsx +1 -0
- package/src/components/order-view/order-details/expanded-content/footer/index.tsx +3 -2
- package/src/components/order-view/order-details/expanded-content/index.tsx +1 -1
- package/src/components/order-view/order-details/expanded-content/instruction-section/index.tsx +2 -1
- package/src/components/order-view/order-details/expanded-content/orders-section/Carrier.tsx +7 -1
- package/src/components/order-view/order-details/expanded-content/orders-section/DeliveryDate.tsx +1 -0
- package/src/components/order-view/order-details/expanded-content/orders-section/Depot.tsx +14 -1
- package/src/components/order-view/order-details/expanded-content/orders-section/Droptime.tsx +2 -1
- package/src/components/order-view/order-details/expanded-content/orders-section/OrderNumber.tsx +2 -1
- package/src/components/order-view/order-details/expanded-content/orders-section/RecipientReference.tsx +2 -1
- package/src/components/order-view/order-details/expanded-content/orders-section/ScheduleAfter.tsx +1 -0
- package/src/components/order-view/order-details/expanded-content/orders-section/VehicleType.tsx +13 -1
- package/src/components/order-view/order-details/expanded-content/services-section/DeliveryPoint.tsx +13 -1
- package/src/components/order-view/order-details/expanded-content/services-section/ServiceType.tsx +13 -1
- package/src/components/order-view/order-details/expanded-content/services-section/TimedService.tsx +14 -1
- package/src/components/order-view/order-resources/collapsed-content/index.tsx +1 -1
- package/src/components/order-view/products-info/expanded-content/index.tsx +2 -2
- package/src/components/order-view/products-info/index.tsx +3 -2
- package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +30 -34
- package/src/components/order-view/store.ts +80 -14
- package/src/components/order-view/system-event-logs/collapsed-content/index.tsx +1 -1
- package/src/components/order-view/system-event-logs/columns/Code.tsx +17 -0
- package/src/components/order-view/system-event-logs/columns/Date.tsx +18 -0
- package/src/components/order-view/system-event-logs/columns/Event.tsx +26 -0
- package/src/components/order-view/system-event-logs/columns/Note.tsx +24 -0
- package/src/components/order-view/system-event-logs/columns/index.tsx +6 -0
- package/src/components/order-view/system-event-logs/expanded-content/index.tsx +34 -6
- package/src/components/order-view/system-event-logs/helper.ts +29 -0
- package/src/components/store.ts +26 -4
- package/src/components/types.ts +2 -6
- package/src/index.tsx +32 -5
- package/dist/components/order-daily-overview/table/InfiniteScrolling.d.ts +0 -5
- package/dist/components/order-daily-overview/table/Return.d.ts +0 -3
- package/dist/components/order-daily-overview/table/table-data/MyTable.d.ts +0 -18
- package/dist/components/order-daily-overview/table/table-data/Table.d.ts +0 -18
- package/dist/components/order-view/system-event-logs/system-logs-table/SystemLogsTables.d.ts +0 -3
- package/dist/components/order-view/system-event-logs/system-logs-table/SytemLogsStyles.d.ts +0 -3
- package/src/components/order-daily-overview/table/InfiniteScrolling.tsx +0 -54
- package/src/components/order-daily-overview/table/Return.tsx +0 -156
- package/src/components/order-daily-overview/table/table-data/MyTable.tsx +0 -433
- package/src/components/order-daily-overview/table/table-data/Table.tsx +0 -445
- package/src/components/order-view/system-event-logs/system-logs-table/SystemLogsTables.tsx +0 -59
- package/src/components/order-view/system-event-logs/system-logs-table/SytemLogsStyles.tsx +0 -239
|
@@ -1,216 +1,159 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
ApplyButton,
|
|
4
|
-
// DatePickerWrap,
|
|
5
4
|
FilterColumn,
|
|
6
5
|
FilterRow,
|
|
7
6
|
Label,
|
|
8
7
|
LeftColumn,
|
|
9
|
-
// RangeSelect,
|
|
10
8
|
RightColumn,
|
|
11
|
-
StyledAntSelect,
|
|
12
9
|
Wrapper,
|
|
13
10
|
} from './Styledfilters';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// useSelectedSubClients,
|
|
28
|
-
// } from '../store';
|
|
29
|
-
// import { useApiHook } from '@bjsdistribution/dms-component-library';
|
|
30
|
-
// import { ApiResponse } from '../../readyforinvoice/types';
|
|
31
|
-
// import { DatePicker, Tooltip } from 'antd';
|
|
32
|
-
// import dayjs from 'dayjs';
|
|
33
|
-
// import { compareArrays, prepareData } from '../utils';
|
|
34
|
-
// import { useReadyForInvoiceView } from '../../readyforinvoice/store';
|
|
35
|
-
// import { emailFiltersReducerAtom } from '../../emailInvoice/EmailFilterStore';
|
|
11
|
+
import { atom, useAtom } from 'jotai';
|
|
12
|
+
import { useActionType, useCustomerData, useLocationData } from '../../store';
|
|
13
|
+
import { filtersReducerAtom } from './filterStore';
|
|
14
|
+
import {
|
|
15
|
+
useSelectedAction,
|
|
16
|
+
useSelectedClient,
|
|
17
|
+
useSelectedLocation,
|
|
18
|
+
useTableName,
|
|
19
|
+
} from '../store/store';
|
|
20
|
+
import styled from 'styled-components';
|
|
21
|
+
import { Select } from 'antd';
|
|
22
|
+
import { DefaultOptionType } from 'antd/es/select';
|
|
23
|
+
|
|
36
24
|
export const clickedState = atom<boolean>(false);
|
|
37
25
|
|
|
38
26
|
function SelectionFilter() {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
//
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
//
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
//
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
// setPrevSelectedClients(selectedClients);
|
|
170
|
-
// setPrevSelectedDate(selectedDate);
|
|
171
|
-
// setSelectedSubClients(subAccounts);
|
|
172
|
-
// if (selectedClients?.length === 0) {
|
|
173
|
-
// setIsClicked(false);
|
|
174
|
-
// }
|
|
175
|
-
// };
|
|
176
|
-
|
|
177
|
-
// const isDifferent = () => {
|
|
178
|
-
// let actualDate = null;
|
|
179
|
-
// let isDateDiff;
|
|
180
|
-
// if (selectedDate !== null) {
|
|
181
|
-
// actualDate = new Date(selectedDate);
|
|
182
|
-
// }
|
|
183
|
-
// if (prevSelectedDate !== null && actualDate !== null) {
|
|
184
|
-
// isDateDiff =
|
|
185
|
-
// actualDate.getTime() !== new Date(prevSelectedDate).getTime();
|
|
186
|
-
// }
|
|
187
|
-
// if (prevSelectedDate !== null && actualDate === null) {
|
|
188
|
-
// isDateDiff = false;
|
|
189
|
-
// }
|
|
190
|
-
// const isClientDiff = compareArrays(
|
|
191
|
-
// selectedClientValues,
|
|
192
|
-
// prevSelectedClientValues
|
|
193
|
-
// );
|
|
194
|
-
// const isSubAccountDiff = compareArrays(subAccounts, selectedSubClients);
|
|
195
|
-
// const isSame = isDateDiff || isClientDiff || isSubAccountDiff;
|
|
196
|
-
// return !isSame;
|
|
197
|
-
// };
|
|
198
|
-
const ActionOptions = [
|
|
199
|
-
{ label: 'RTS', value: 'rt' },
|
|
200
|
-
{ label: 'Dispose', value: 'dispose' },
|
|
201
|
-
{ label: 'Pending', value: 'pending' },
|
|
202
|
-
{ label: 'Re-allocated', value: 're-allocate' },
|
|
203
|
-
{ label: 'Re-Del', value: 're-del' },
|
|
204
|
-
{ label: 'Re-Recycle', value: 're-recycle' },
|
|
205
|
-
{ label: 'Unknown', value: 'unknown' },
|
|
206
|
-
];
|
|
207
|
-
|
|
208
|
-
const ReturnLocationOptions = [
|
|
209
|
-
{ label: 'bedkingdom wf14 0dq ', value: 'bedkingdom' },
|
|
210
|
-
{ label: 'cotswold returns', value: 'cotswold-returns' },
|
|
211
|
-
{ label: 'appliance house c/o hdl', value: 'appliance' },
|
|
212
|
-
];
|
|
213
|
-
|
|
27
|
+
const [customers] = useCustomerData();
|
|
28
|
+
const [actionType] = useActionType();
|
|
29
|
+
const [locationData] = useLocationData();
|
|
30
|
+
const [filteredLocationOptions, setFilteredLocationOptions] = useState([]);
|
|
31
|
+
const [getUuid, setUuid] = useState<any>();
|
|
32
|
+
const [selectedFilterValue, setSelectedFilterValue] = useSelectedAction();
|
|
33
|
+
const [, dispatch] = useAtom(filtersReducerAtom);
|
|
34
|
+
const [
|
|
35
|
+
selectedLocationValue,
|
|
36
|
+
setSelectedLocationValue,
|
|
37
|
+
] = useSelectedLocation();
|
|
38
|
+
const [selectedClientId, setSelectedClient] = useSelectedClient();
|
|
39
|
+
const [, setClientLabel] = useTableName();
|
|
40
|
+
const [, setName] = useState<any>();
|
|
41
|
+
const [isButtonEnabled, setIsButtonEnabled] = useState(false);
|
|
42
|
+
|
|
43
|
+
//client options
|
|
44
|
+
const clientOptions = customers?.map((option: any) => ({
|
|
45
|
+
label:
|
|
46
|
+
option?.customer_name?.charAt(0)?.toUpperCase() +
|
|
47
|
+
option?.customer_name?.slice(1),
|
|
48
|
+
value: `${option?.id}_${option?.uuid}`,
|
|
49
|
+
id: option?.id,
|
|
50
|
+
uuid: option?.uuid,
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
const actionTypeOptions = actionType?.map((option: any) => ({
|
|
54
|
+
label: option?.type?.charAt(0)?.toUpperCase() + option?.type?.slice(1),
|
|
55
|
+
value: option?.id,
|
|
56
|
+
}));
|
|
57
|
+
|
|
58
|
+
const LocationOptions = locationData?.map((option: any) => ({
|
|
59
|
+
label: option?.location_name,
|
|
60
|
+
value: option?.customer_id,
|
|
61
|
+
}));
|
|
62
|
+
|
|
63
|
+
//client change
|
|
64
|
+
const handleSelectChange = (value: unknown, option: DefaultOptionType) => {
|
|
65
|
+
console.log(value, 'value');
|
|
66
|
+
const selectedLabel = option?.label as string;
|
|
67
|
+
const selectedValue = option?.id as number;
|
|
68
|
+
const selectedUuids = option?.uuid as string;
|
|
69
|
+
setSelectedClient(selectedValue);
|
|
70
|
+
setName(selectedLabel);
|
|
71
|
+
localStorage.setItem('clientName', selectedLabel);
|
|
72
|
+
localStorage.setItem('clientId', selectedValue.toString());
|
|
73
|
+
const filteredSubLocations = locationData
|
|
74
|
+
?.filter((subCat: any) => subCat?.customer_id === selectedUuids)
|
|
75
|
+
.map((subCat: any) => ({
|
|
76
|
+
label: subCat?.location_name,
|
|
77
|
+
value: subCat?.customer_id,
|
|
78
|
+
}));
|
|
79
|
+
|
|
80
|
+
setFilteredLocationOptions(filteredSubLocations);
|
|
81
|
+
setUuid('');
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
useEffect(() => {}, [getUuid, filteredLocationOptions]);
|
|
85
|
+
|
|
86
|
+
//location change
|
|
87
|
+
const handleLocationChange = (value: unknown, option: DefaultOptionType) => {
|
|
88
|
+
const selectedLabel = option?.label as string;
|
|
89
|
+
console.log(value, 'value');
|
|
90
|
+
setSelectedLocationValue(selectedLabel);
|
|
91
|
+
|
|
92
|
+
if (selectedLocationValue === selectedLabel) {
|
|
93
|
+
dispatch({
|
|
94
|
+
type: 'CLEAR_ALL_FILTERS',
|
|
95
|
+
payload: null,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
//action type
|
|
101
|
+
const handleActionClick = (value: any) => {
|
|
102
|
+
setSelectedFilterValue(value);
|
|
103
|
+
if (selectedFilterValue === value) {
|
|
104
|
+
dispatch({
|
|
105
|
+
type: 'CLEAR_ALL_FILTERS',
|
|
106
|
+
payload: null,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
//Apply filters
|
|
112
|
+
const applyFilters = () => {
|
|
113
|
+
if (storedName) {
|
|
114
|
+
setClientLabel(storedName);
|
|
115
|
+
}
|
|
116
|
+
if (selectedClientId) {
|
|
117
|
+
dispatch({
|
|
118
|
+
type: 'SET_CLIENT_FILTER',
|
|
119
|
+
payload: selectedClientId,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
if (selectedFilterValue) {
|
|
123
|
+
dispatch({
|
|
124
|
+
type: 'SET_ACTIONS_FILTER',
|
|
125
|
+
payload: selectedFilterValue,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (selectedLocationValue) {
|
|
130
|
+
dispatch({
|
|
131
|
+
type: 'SET_LOCATION_FILTER',
|
|
132
|
+
payload: selectedLocationValue,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const storedName = localStorage.getItem('clientName');
|
|
138
|
+
const storedClientId = localStorage.getItem('clientId');
|
|
139
|
+
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
if (storedClientId) {
|
|
142
|
+
dispatch({
|
|
143
|
+
type: 'SET_CLIENT_FILTER',
|
|
144
|
+
payload: storedClientId,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}, [storedClientId]);
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
if (storedName || selectedFilterValue || selectedLocationValue) {
|
|
150
|
+
setIsButtonEnabled(true);
|
|
151
|
+
} else {
|
|
152
|
+
setIsButtonEnabled(false);
|
|
153
|
+
}
|
|
154
|
+
}, [storedName, selectedFilterValue, selectedLocationValue]);
|
|
155
|
+
|
|
156
|
+
console.log('check', storedName, selectedFilterValue, selectedLocationValue);
|
|
214
157
|
return (
|
|
215
158
|
<Wrapper>
|
|
216
159
|
<FilterRow>
|
|
@@ -218,55 +161,58 @@ function SelectionFilter() {
|
|
|
218
161
|
<FilterColumn>
|
|
219
162
|
<Label>Clients</Label>
|
|
220
163
|
<StyledAntSelect
|
|
221
|
-
options={
|
|
164
|
+
options={clientOptions}
|
|
222
165
|
placeholder="Select Client Name"
|
|
223
|
-
onChange={
|
|
224
|
-
mode="multiple"
|
|
166
|
+
onChange={handleSelectChange}
|
|
225
167
|
style={{ minWidth: '14vw' }}
|
|
168
|
+
value={storedName}
|
|
226
169
|
/>
|
|
227
170
|
</FilterColumn>
|
|
228
171
|
|
|
229
172
|
<FilterColumn>
|
|
230
173
|
<Label>Action Type</Label>
|
|
231
174
|
<StyledAntSelect
|
|
232
|
-
options={
|
|
175
|
+
options={actionTypeOptions}
|
|
233
176
|
placeholder="Select Action Type"
|
|
234
|
-
|
|
235
|
-
onChange={
|
|
177
|
+
value={selectedFilterValue}
|
|
178
|
+
onChange={handleActionClick}
|
|
236
179
|
style={{ minWidth: '14vw' }}
|
|
237
|
-
|
|
238
|
-
mode="multiple"
|
|
239
|
-
// maxTagCount={0}
|
|
240
|
-
// maxTagPlaceholder={(omittedValues: any) => (
|
|
241
|
-
// <Tooltip
|
|
242
|
-
// overlayStyle={{ pointerEvents: 'none' }}
|
|
243
|
-
// title={omittedValues
|
|
244
|
-
// .map(({ label }: any) => label)
|
|
245
|
-
// .join(', ')}
|
|
246
|
-
// >
|
|
247
|
-
// <span>{`${omittedValues.length} selected`}</span>
|
|
248
|
-
// </Tooltip>
|
|
249
|
-
// )}
|
|
180
|
+
allowClear
|
|
250
181
|
/>
|
|
251
182
|
</FilterColumn>
|
|
252
183
|
|
|
253
184
|
<FilterColumn>
|
|
254
185
|
<Label>Location </Label>
|
|
255
186
|
<StyledAntSelect
|
|
256
|
-
options={
|
|
187
|
+
options={
|
|
188
|
+
filteredLocationOptions?.length > 0
|
|
189
|
+
? filteredLocationOptions
|
|
190
|
+
: LocationOptions
|
|
191
|
+
}
|
|
192
|
+
value={selectedLocationValue}
|
|
257
193
|
placeholder="Select Location"
|
|
258
|
-
onChange={
|
|
259
|
-
mode="multiple"
|
|
194
|
+
onChange={handleLocationChange}
|
|
260
195
|
style={{ minWidth: '14vw' }}
|
|
196
|
+
allowClear
|
|
197
|
+
mode="multiple"
|
|
261
198
|
/>
|
|
262
199
|
</FilterColumn>
|
|
263
200
|
</LeftColumn>
|
|
264
201
|
<RightColumn>
|
|
265
|
-
<ApplyButton
|
|
202
|
+
<ApplyButton onClick={applyFilters} disabled={!isButtonEnabled}>
|
|
203
|
+
Apply
|
|
204
|
+
</ApplyButton>
|
|
266
205
|
</RightColumn>
|
|
267
206
|
</FilterRow>
|
|
268
207
|
</Wrapper>
|
|
269
208
|
);
|
|
270
209
|
}
|
|
271
210
|
|
|
211
|
+
const StyledAntSelect = styled(Select)`
|
|
212
|
+
.ant-select-selector {
|
|
213
|
+
/* width: 22vw; */
|
|
214
|
+
border-radius: 22px;
|
|
215
|
+
}
|
|
216
|
+
`;
|
|
217
|
+
|
|
272
218
|
export default SelectionFilter;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Button } from '@bjsdistribution/dms-component-library';
|
|
1
|
+
// import { Button } from '@bjsdistribution/dms-component-library';
|
|
2
2
|
import { Select } from 'antd';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
|
|
@@ -26,7 +26,7 @@ export const CoverPage = styled.div`
|
|
|
26
26
|
border: 1px solid #e3e3e3;
|
|
27
27
|
background: #fff;
|
|
28
28
|
box-shadow: 0px 4px 30px 0px rgba(46, 45, 116, 0.05);
|
|
29
|
-
padding:
|
|
29
|
+
padding: 20px 20px 20px 20px;
|
|
30
30
|
top: -60px;
|
|
31
31
|
`;
|
|
32
32
|
export const StatusPanel = styled.div`
|
|
@@ -92,7 +92,7 @@ export const Wrapper = styled.div`
|
|
|
92
92
|
gap: 15px;
|
|
93
93
|
flex: 1 0 0;
|
|
94
94
|
border-radius: 15px;
|
|
95
|
-
background: #
|
|
95
|
+
background: #f8fafc;
|
|
96
96
|
`;
|
|
97
97
|
|
|
98
98
|
export const StyledAntSelect = styled(Select)`
|
|
@@ -190,13 +190,26 @@ export const RangeSelect = styled.div`
|
|
|
190
190
|
color: #8e8a85;
|
|
191
191
|
`;
|
|
192
192
|
|
|
193
|
-
export const ApplyButton = styled
|
|
194
|
-
border-radius: 15px
|
|
193
|
+
export const ApplyButton = styled.button`
|
|
194
|
+
border-radius: 15px;
|
|
195
195
|
display: flex;
|
|
196
|
-
padding: 7px 12px
|
|
196
|
+
padding: 7px 12px;
|
|
197
197
|
justify-content: center;
|
|
198
198
|
align-items: center;
|
|
199
|
-
font-size: 14px
|
|
199
|
+
font-size: 14px;
|
|
200
200
|
font-family: 'Lato', sans-serif;
|
|
201
201
|
background: transparent;
|
|
202
|
+
color: #3a3620;
|
|
203
|
+
border: 1px solid #3a3630;
|
|
204
|
+
cursor: pointer;
|
|
205
|
+
|
|
206
|
+
&:not(:disabled):hover {
|
|
207
|
+
background: #feba30;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
&:disabled {
|
|
211
|
+
background: #ccc;
|
|
212
|
+
cursor: not-allowed;
|
|
213
|
+
opacity: 0.6;
|
|
214
|
+
}
|
|
202
215
|
`;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { atom, useAtom } from 'jotai';
|
|
2
|
+
// import { formatDate } from '../shared/utlis';
|
|
3
|
+
import { format } from 'date-fns';
|
|
4
|
+
|
|
5
|
+
const date = atom(new Date());
|
|
6
|
+
export const usedate = () => {
|
|
7
|
+
return useAtom(date);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
interface Filter {
|
|
11
|
+
field: string;
|
|
12
|
+
op: string;
|
|
13
|
+
value: any;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface Pagination {
|
|
17
|
+
page: number;
|
|
18
|
+
per_page: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface FilterState {
|
|
22
|
+
'x-filters': Filter[];
|
|
23
|
+
'x-pagination': Pagination;
|
|
24
|
+
}
|
|
25
|
+
// let todayDate = new Date();
|
|
26
|
+
const initialState: FilterState = {
|
|
27
|
+
'x-filters': [
|
|
28
|
+
// {
|
|
29
|
+
// field: 'action_date',
|
|
30
|
+
// op: '>=',
|
|
31
|
+
// value: `${format(new Date(todayDate), 'yyyy-MM-dd')}T00:00:00+00:00`,
|
|
32
|
+
// },
|
|
33
|
+
// {
|
|
34
|
+
// field: 'action_date',
|
|
35
|
+
// op: '<=',
|
|
36
|
+
// value: `${format(new Date(todayDate), 'yyyy-MM-dd')}T23:59:59+00:00`,
|
|
37
|
+
// },
|
|
38
|
+
// { field: 'status', op: 'count', value: '' },
|
|
39
|
+
],
|
|
40
|
+
'x-pagination': { page: 1, per_page: 50 },
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const filterReducer = (state: FilterState, action: any): FilterState => {
|
|
44
|
+
switch (action.type) {
|
|
45
|
+
case 'SET_DATE_FILTER':
|
|
46
|
+
return {
|
|
47
|
+
...state,
|
|
48
|
+
'x-filters': [
|
|
49
|
+
...state['x-filters'].filter(
|
|
50
|
+
f => f.field !== 'action_date' && f.field !== 'status'
|
|
51
|
+
),
|
|
52
|
+
{
|
|
53
|
+
field: 'action_date',
|
|
54
|
+
op: '>=',
|
|
55
|
+
value: `${format(
|
|
56
|
+
new Date(action.payload),
|
|
57
|
+
'yyyy-MM-dd'
|
|
58
|
+
)}T00:00:00+00:00`,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
field: 'action_date',
|
|
62
|
+
op: '<=',
|
|
63
|
+
value: `${format(
|
|
64
|
+
new Date(action.payload),
|
|
65
|
+
'yyyy-MM-dd'
|
|
66
|
+
)}T23:59:59+00:00`,
|
|
67
|
+
},
|
|
68
|
+
{ field: 'status', op: 'count', value: '' },
|
|
69
|
+
],
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
case 'SET_CLIENT_FILTER':
|
|
73
|
+
return {
|
|
74
|
+
...state,
|
|
75
|
+
'x-filters': [
|
|
76
|
+
...state['x-filters'].filter(f => f.field !== 'order.customer_id'),
|
|
77
|
+
{
|
|
78
|
+
field: 'order.customer_id',
|
|
79
|
+
op: '=',
|
|
80
|
+
value: action.payload,
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
case 'SET_ACTIONS_FILTER':
|
|
86
|
+
return {
|
|
87
|
+
...state,
|
|
88
|
+
'x-filters': [
|
|
89
|
+
...state['x-filters'].filter(
|
|
90
|
+
f => f.field !== 'product_return_action_id'
|
|
91
|
+
),
|
|
92
|
+
{
|
|
93
|
+
field: 'product_return_action_id',
|
|
94
|
+
op: '=',
|
|
95
|
+
value: action.payload,
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
case 'SET_LOCATION_FILTER':
|
|
101
|
+
return {
|
|
102
|
+
...state,
|
|
103
|
+
'x-filters': [
|
|
104
|
+
...state['x-filters'].filter(f => f.field !== 'return_location'),
|
|
105
|
+
{
|
|
106
|
+
field: 'return_location',
|
|
107
|
+
op: 'in',
|
|
108
|
+
value: action.payload,
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
case 'SET_PAGE':
|
|
114
|
+
return {
|
|
115
|
+
...state,
|
|
116
|
+
'x-pagination': {
|
|
117
|
+
...state['x-pagination'],
|
|
118
|
+
page: action.payload,
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
case 'SET_PERPAGE':
|
|
123
|
+
return {
|
|
124
|
+
...state,
|
|
125
|
+
'x-pagination': {
|
|
126
|
+
...state['x-pagination'],
|
|
127
|
+
per_page: action.payload,
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
case 'CLEAR_FILTERS':
|
|
131
|
+
return {
|
|
132
|
+
...state,
|
|
133
|
+
};
|
|
134
|
+
default:
|
|
135
|
+
return state;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const filtersStateAtom = atom(initialState);
|
|
140
|
+
|
|
141
|
+
export const filtersReducerAtom = atom(
|
|
142
|
+
get => get(filtersStateAtom),
|
|
143
|
+
(get, set, action) =>
|
|
144
|
+
set(filtersStateAtom, filterReducer(get(filtersStateAtom), action))
|
|
145
|
+
);
|