@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.
Files changed (119) hide show
  1. package/README.md +1 -1
  2. package/dist/components/order-daily-overview/common/interface.d.ts +22 -0
  3. package/dist/components/order-daily-overview/header-filters/Styledfilters.d.ts +1 -2
  4. package/dist/components/order-daily-overview/header-filters/filterStore.d.ts +16 -0
  5. package/dist/components/order-daily-overview/return-order-table/return-orders-filters/returnstyles.d.ts +1 -0
  6. package/dist/components/order-daily-overview/shared/utlis.d.ts +2 -2
  7. package/dist/components/order-daily-overview/store/store.d.ts +4 -0
  8. package/dist/components/order-daily-overview/table/table-data/styles.d.ts +2 -0
  9. package/dist/components/order-view/details-filters/left-side-filters/dropdowns/PrintDropDown.d.ts +3 -1
  10. package/dist/components/order-view/generic-table/AuditLogs.d.ts +4 -0
  11. package/dist/components/order-view/hooks/useGetEventNotes.d.ts +2 -0
  12. package/dist/components/order-view/hooks/useGetSystemLogs.d.ts +2 -0
  13. package/dist/components/order-view/modalsPopup/CreateReturnModal.d.ts +4 -0
  14. package/dist/components/order-view/notes/logs/fakeData.d.ts +7 -7
  15. package/dist/components/order-view/store.d.ts +23 -1
  16. package/dist/components/order-view/system-event-logs/columns/Code.d.ts +3 -0
  17. package/dist/components/order-view/system-event-logs/columns/Date.d.ts +3 -0
  18. package/dist/components/order-view/system-event-logs/columns/Event.d.ts +3 -0
  19. package/dist/components/order-view/system-event-logs/columns/Note.d.ts +3 -0
  20. package/dist/components/order-view/system-event-logs/columns/index.d.ts +4 -0
  21. package/dist/components/order-view/system-event-logs/helper.d.ts +7 -0
  22. package/dist/components/store.d.ts +5 -2
  23. package/dist/components/types.d.ts +1 -1
  24. package/dist/dms-client-return.cjs.development.js +3553 -2396
  25. package/dist/dms-client-return.cjs.development.js.map +1 -1
  26. package/dist/dms-client-return.cjs.production.min.js +1 -1
  27. package/dist/dms-client-return.cjs.production.min.js.map +1 -1
  28. package/dist/dms-client-return.esm.js +3557 -2400
  29. package/dist/dms-client-return.esm.js.map +1 -1
  30. package/package.json +2 -2
  31. package/src/common/expand-collapse/index.tsx +3 -3
  32. package/src/components/fakeData.ts +14 -23
  33. package/src/components/order-daily-overview/common/fakedata.tsx +5 -6
  34. package/src/components/order-daily-overview/common/interface.ts +120 -97
  35. package/src/components/order-daily-overview/filters/Filters.tsx +6 -13
  36. package/src/components/order-daily-overview/header-filters/HeaderFilter.tsx +56 -67
  37. package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +170 -224
  38. package/src/components/order-daily-overview/header-filters/Styledfilters.tsx +20 -7
  39. package/src/components/order-daily-overview/header-filters/filterStore.ts +145 -0
  40. package/src/components/order-daily-overview/index.tsx +77 -20
  41. package/src/components/order-daily-overview/return-after-table/ReturnAfterTable.tsx +32 -4
  42. package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +184 -235
  43. package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx +69 -10
  44. package/src/components/order-daily-overview/return-order-table/ReturnTable.tsx +10 -3
  45. package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnFilter.tsx +9 -47
  46. package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +106 -190
  47. package/src/components/order-daily-overview/return-order-table/return-orders-filters/RightFilters.tsx +35 -38
  48. package/src/components/order-daily-overview/return-order-table/return-orders-filters/returnstyles.ts +69 -1
  49. package/src/components/order-daily-overview/store/store.ts +23 -12
  50. package/src/components/order-daily-overview/table/ReturnTable.tsx +133 -207
  51. package/src/components/order-daily-overview/table/table-data/styles.ts +15 -0
  52. package/src/components/order-view/details-filters/DetailsFilters.tsx +5 -4
  53. package/src/components/order-view/details-filters/left-side-filters/dropdowns/DropDowns.tsx +0 -2
  54. package/src/components/order-view/details-filters/left-side-filters/dropdowns/PrintDropDown.tsx +54 -46
  55. package/src/components/order-view/general-information/Status.tsx +1 -1
  56. package/src/components/order-view/generic-table/AuditLogs.tsx +96 -0
  57. package/src/components/order-view/hooks/useGetEventNotes.tsx +47 -0
  58. package/src/components/order-view/hooks/useGetSystemLogs.tsx +60 -0
  59. package/src/components/order-view/index.tsx +25 -4
  60. package/src/components/order-view/modalsPopup/CreateReturnModal.tsx +83 -0
  61. package/src/components/order-view/modalsPopup/ModalManager.tsx +49 -49
  62. package/src/components/order-view/modalsPopup/UnReceiveProduct.tsx +1 -1
  63. package/src/components/order-view/notes/AddNote.tsx +127 -13
  64. package/src/components/order-view/notes/index.tsx +100 -3
  65. package/src/components/order-view/notes/logs/fakeData.ts +8 -48
  66. package/src/components/order-view/notes/logs/index.tsx +6 -45
  67. package/src/components/order-view/order-actions/actions/escalation/EscalationModal.tsx +1 -1
  68. package/src/components/order-view/order-details/expanded-content/customer-section/RecipientName.tsx +1 -0
  69. package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactEmail.tsx +1 -0
  70. package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactHome.tsx +1 -0
  71. package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactMobile.tsx +1 -1
  72. package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactWork.tsx +1 -0
  73. package/src/components/order-view/order-details/expanded-content/customer-section/location-info/Address.tsx +1 -0
  74. package/src/components/order-view/order-details/expanded-content/customer-section/location-info/Latitude.tsx +1 -0
  75. package/src/components/order-view/order-details/expanded-content/customer-section/location-info/Longitude.tsx +1 -0
  76. package/src/components/order-view/order-details/expanded-content/customer-section/location-info/Postcode.tsx +1 -0
  77. package/src/components/order-view/order-details/expanded-content/customer-section/location-info/What3words.tsx +1 -0
  78. package/src/components/order-view/order-details/expanded-content/footer/index.tsx +3 -2
  79. package/src/components/order-view/order-details/expanded-content/index.tsx +1 -1
  80. package/src/components/order-view/order-details/expanded-content/instruction-section/index.tsx +2 -1
  81. package/src/components/order-view/order-details/expanded-content/orders-section/Carrier.tsx +7 -1
  82. package/src/components/order-view/order-details/expanded-content/orders-section/DeliveryDate.tsx +1 -0
  83. package/src/components/order-view/order-details/expanded-content/orders-section/Depot.tsx +14 -1
  84. package/src/components/order-view/order-details/expanded-content/orders-section/Droptime.tsx +2 -1
  85. package/src/components/order-view/order-details/expanded-content/orders-section/OrderNumber.tsx +2 -1
  86. package/src/components/order-view/order-details/expanded-content/orders-section/RecipientReference.tsx +2 -1
  87. package/src/components/order-view/order-details/expanded-content/orders-section/ScheduleAfter.tsx +1 -0
  88. package/src/components/order-view/order-details/expanded-content/orders-section/VehicleType.tsx +13 -1
  89. package/src/components/order-view/order-details/expanded-content/services-section/DeliveryPoint.tsx +13 -1
  90. package/src/components/order-view/order-details/expanded-content/services-section/ServiceType.tsx +13 -1
  91. package/src/components/order-view/order-details/expanded-content/services-section/TimedService.tsx +14 -1
  92. package/src/components/order-view/order-resources/collapsed-content/index.tsx +1 -1
  93. package/src/components/order-view/products-info/expanded-content/index.tsx +2 -2
  94. package/src/components/order-view/products-info/index.tsx +3 -2
  95. package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +30 -34
  96. package/src/components/order-view/store.ts +80 -14
  97. package/src/components/order-view/system-event-logs/collapsed-content/index.tsx +1 -1
  98. package/src/components/order-view/system-event-logs/columns/Code.tsx +17 -0
  99. package/src/components/order-view/system-event-logs/columns/Date.tsx +18 -0
  100. package/src/components/order-view/system-event-logs/columns/Event.tsx +26 -0
  101. package/src/components/order-view/system-event-logs/columns/Note.tsx +24 -0
  102. package/src/components/order-view/system-event-logs/columns/index.tsx +6 -0
  103. package/src/components/order-view/system-event-logs/expanded-content/index.tsx +34 -6
  104. package/src/components/order-view/system-event-logs/helper.ts +29 -0
  105. package/src/components/store.ts +26 -4
  106. package/src/components/types.ts +2 -6
  107. package/src/index.tsx +32 -5
  108. package/dist/components/order-daily-overview/table/InfiniteScrolling.d.ts +0 -5
  109. package/dist/components/order-daily-overview/table/Return.d.ts +0 -3
  110. package/dist/components/order-daily-overview/table/table-data/MyTable.d.ts +0 -18
  111. package/dist/components/order-daily-overview/table/table-data/Table.d.ts +0 -18
  112. package/dist/components/order-view/system-event-logs/system-logs-table/SystemLogsTables.d.ts +0 -3
  113. package/dist/components/order-view/system-event-logs/system-logs-table/SytemLogsStyles.d.ts +0 -3
  114. package/src/components/order-daily-overview/table/InfiniteScrolling.tsx +0 -54
  115. package/src/components/order-daily-overview/table/Return.tsx +0 -156
  116. package/src/components/order-daily-overview/table/table-data/MyTable.tsx +0 -433
  117. package/src/components/order-daily-overview/table/table-data/Table.tsx +0 -445
  118. package/src/components/order-view/system-event-logs/system-logs-table/SystemLogsTables.tsx +0 -59
  119. 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
- // import {
15
- // displayFormattedDate,
16
- // // overviewFiltersReducerAtom,
17
- // lastSundayDate,
18
- // filtersReducerAtom,
19
- // usefilterApplied,
20
- // } from './FilterStore';
21
- import { atom } from 'jotai';
22
- // import {
23
- // allCustomerData,
24
- // usePrevSelectedClients,
25
- // useSelectedClients,
26
- // useSelectedFilter,
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
- // const [, setFilterAplied] = usefilterApplied();
40
- // const [selectedFilter] = useSelectedFilter();
41
- // const [, dispatchEmailFilters] = useAtom(emailFiltersReducerAtom);
42
-
43
- // const [, dispatchOverviewFilters] = useAtom(overviewFiltersReducerAtom);
44
- // const [, dispatchFilters] = useAtom(filtersReducerAtom);
45
- // const [
46
- // readyForInvoiceView,
47
- // setReadyForInvoiceView,
48
- // ] = useReadyForInvoiceView();
49
- // const [prevSelectedDate, setPrevSelectedDate] = useState<
50
- // Date | string | null
51
- // >(lastSundayDate); // for comparison
52
- // const [selectedDate, setDate] = useState<Date | string | null>(
53
- // lastSundayDate
54
- // );
55
- // const [customerData, setCustomerData] = allCustomerData();
56
-
57
- // const [
58
- // prevSelectedClients,
59
- // setPrevSelectedClients,
60
- // ] = usePrevSelectedClients();
61
-
62
- // const [selectedClients, setClients] = useSelectedClients();
63
-
64
- // const [subAccounts, setSubaccounts] = useState<any>([]);
65
-
66
- // const [selectedSubClients, setSelectedSubClients] = useSelectedSubClients();
67
-
68
- // const [, setIsClicked] = useAtom(clickedState);
69
-
70
- //API
71
- // const { data: fetchedStaticData, loading: loading } = useApiHook<ApiResponse>(
72
- // {
73
- // endpoint: `/customer/`,
74
- // method: 'GET',
75
- // pagination: { page: 1, per_page: 50 },
76
- // }
77
- // );
78
-
79
- // useEffect(() => {
80
- // if (!loading) {
81
- // setCustomerData(fetchedStaticData?.data);
82
- // }
83
- // }, [loading]);
84
-
85
- // const clientOptions = customerData
86
- // ?.filter((x: any) => x.id === x?.parent_id || x?.parent_id === null)
87
- // ?.map((option: any) => ({
88
- // label: option?.name?.charAt(0)?.toUpperCase() + option?.name?.slice(1),
89
- // value: option?.id,
90
- // }));
91
-
92
- // const selectedClientValues = selectedClients?.map(item => item?.value);
93
- // const prevSelectedClientValues = prevSelectedClients?.map(
94
- // item => item?.value
95
- // );
96
-
97
- // const subAccountData = customerData
98
- // ?.filter(item => selectedClientValues?.includes(item?.parent_id))
99
- // ?.filter(x => x.id !== x.parent_id);
100
-
101
- // const preparedData = prepareData(clientOptions, subAccountData);
102
-
103
- // const subAccountOptions = preparedData?.filter(
104
- // (item: any) => item?.options?.length > 0
105
- // );
106
-
107
- // const handleDateChange: DatePickerProps['onChange'] = (date, _dateString) => {
108
- // setFilterAplied(true);
109
- // const newDate = date?.format('YYYY-MM-DDTHH:mm:ss');
110
- // if (newDate !== undefined) {
111
- // setDate(newDate);
112
- // } else {
113
- // setDate(null);
114
- // }
115
- // };
116
-
117
- // const handleCustomerChange = (_label: any, value: any) => {
118
- // if (value.length === 0) {
119
- // setReadyForInvoiceView(undefined);
120
- // setPrevSelectedClients(value);
121
- // dispatchOverviewFilters({
122
- // type: 'SET_DATE_FILTER',
123
- // payload: selectedDate,
124
- // });
125
- // }
126
- // setClients(value);
127
- // };
128
-
129
- // const onChangeSubAccount = (value: any) => {
130
- // setSubaccounts(value);
131
- // };
132
-
133
- // const ApplyFilters = () => {
134
- // setIsClicked(true);
135
- // if (
136
- // readyForInvoiceView !== 'client' &&
137
- // selectedClientValues?.length === 0
138
- // ) {
139
- // console.log('inside if rfiview');
140
- // dispatchOverviewFilters({
141
- // type: 'SET_DATE_FILTER',
142
- // payload: selectedDate,
143
- // });
144
- // }
145
- // if (selectedClientValues?.length > 0) {
146
- // console.log('inside if rfiview asdfasdf');
147
- // dispatchFilters({
148
- // type: 'SET_CUSTOMER_FILTER',
149
- // payload: selectedClientValues,
150
- // });
151
- // dispatchFilters({
152
- // type: 'SET_DATE_FILTER',
153
- // payload: selectedDate,
154
- // });
155
- // if (readyForInvoiceView !== 'client') {
156
- // setReadyForInvoiceView('client');
157
- // }
158
- // }
159
- // dispatchEmailFilters({
160
- // type: 'SET_CUSTOMER_FILTER',
161
- // payload: selectedClientValues,
162
- // });
163
- // dispatchEmailFilters({
164
- // type: 'SET_DATE_FILTERS',
165
- // payload: selectedDate,
166
- // });
167
-
168
- // // need to update prev selected clients state for comparison
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={ActionOptions}
175
+ options={actionTypeOptions}
233
176
  placeholder="Select Action Type"
234
- // value={""}
235
- onChange={() => {}}
177
+ value={selectedFilterValue}
178
+ onChange={handleActionClick}
236
179
  style={{ minWidth: '14vw' }}
237
- // style={{ width: '18vw', overflow: 'hidden' }}
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={ReturnLocationOptions}
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 colors="secondary">Apply</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: 20px 20px 20px 20px;
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: #F8FAFC;
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(Button)`
194
- border-radius: 15px !important;
193
+ export const ApplyButton = styled.button`
194
+ border-radius: 15px;
195
195
  display: flex;
196
- padding: 7px 12px !important;
196
+ padding: 7px 12px;
197
197
  justify-content: center;
198
198
  align-items: center;
199
- font-size: 14px !important;
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
+ );