@bjsdistribution/dms-client-return 0.0.20 → 0.0.22

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 (27) hide show
  1. package/dist/components/order-daily-overview/store/store.d.ts +1 -1
  2. package/dist/components/order-view/utils.d.ts +2 -0
  3. package/dist/dms-client-return.cjs.development.js +457 -381
  4. package/dist/dms-client-return.cjs.development.js.map +1 -1
  5. package/dist/dms-client-return.cjs.production.min.js +1 -1
  6. package/dist/dms-client-return.cjs.production.min.js.map +1 -1
  7. package/dist/dms-client-return.esm.js +458 -382
  8. package/dist/dms-client-return.esm.js.map +1 -1
  9. package/package.json +1 -1
  10. package/src/components/order-daily-overview/header-filters/HeaderFilter.tsx +58 -58
  11. package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +82 -46
  12. package/src/components/order-daily-overview/header-filters/Styledfilters.tsx +1 -0
  13. package/src/components/order-daily-overview/header-filters/filterStore.ts +17 -1
  14. package/src/components/order-daily-overview/index.tsx +9 -8
  15. package/src/components/order-daily-overview/return-after-table/ReturnAfterTable.tsx +8 -6
  16. package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +5 -5
  17. package/src/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.ts +1 -0
  18. package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx +22 -19
  19. package/src/components/order-daily-overview/return-after-table/table-filters/TableFilters.tsx +55 -55
  20. package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +69 -39
  21. package/src/components/order-daily-overview/return-order-table/return-orders-filters/RightFilters.tsx +42 -43
  22. package/src/components/order-daily-overview/return-order-table/return-orders-filters/returnstyles.ts +1 -0
  23. package/src/components/order-daily-overview/store/store.ts +1 -1
  24. package/src/components/order-view/index.tsx +6 -6
  25. package/src/components/order-view/modalsPopup/ModalManager.tsx +17 -11
  26. package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +21 -2
  27. package/src/index.tsx +78 -1
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.20",
2
+ "version": "0.0.22",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -1,72 +1,72 @@
1
- import React, { useEffect } from 'react';
1
+ import React from 'react';
2
2
  import { CoverPage } from './Styledfilters';
3
3
  import SelectionFilter from './SelectionFilter';
4
- import { ApiResponse } from '../../types';
5
- import { useApiHook } from '@bjsdistribution/dms-component-library';
6
- import {
7
- useActionType,
8
- useCustomerData,
9
- useLocationData,
10
- useStatusOrderData,
11
- } from '../../store';
4
+ // import { ApiResponse } from '../../types';
5
+ // import { useApiHook } from '@bjsdistribution/dms-component-library';
6
+ // import {
7
+ // useActionType,
8
+ // useCustomerData,
9
+ // useLocationData,
10
+ // useStatusOrderData,
11
+ // } from '../../store';
12
12
 
13
13
  function HeaderFilter() {
14
- const [, setCustomers] = useCustomerData();
15
- const [, setActionType] = useActionType();
16
- const [, setLocationData] = useLocationData();
17
- const [, setStatusOfOrders] = useStatusOrderData();
14
+ // const [, setCustomers] = useCustomerData();
15
+ // const [, setActionType] = useActionType();
16
+ // const [, setLocationData] = useLocationData();
17
+ // const [, setStatusOfOrders] = useStatusOrderData();
18
18
 
19
19
  //API for client data
20
- const { data: fetchedCustomerData, loading: loading } = useApiHook<
21
- ApiResponse
22
- >({
23
- endpoint: `/customers/`,
24
- method: 'GET',
25
- pagination: { page: 1, per_page: 50 },
26
- });
20
+ // const { data: fetchedCustomerData, loading: loading } = useApiHook<
21
+ // ApiResponse
22
+ // >({
23
+ // endpoint: `/customers/`,
24
+ // method: 'GET',
25
+ // // pagination: { page: 1, per_page: 50 },
26
+ // });
27
27
 
28
- //API for action type
29
- const { data: fetchedStaticData, loading: actionLoading } = useApiHook<
30
- ApiResponse
31
- >({
32
- endpoint: `/orders/getStaticData/all/`,
33
- method: 'GET',
34
- pagination: { page: 1, per_page: 50 },
35
- });
28
+ // //API for action type
29
+ // const { data: fetchedStaticData, loading: actionLoading } = useApiHook<
30
+ // ApiResponse
31
+ // >({
32
+ // endpoint: `/orders/getStaticData/all/`,
33
+ // method: 'GET',
34
+ // // pagination: { page: 1, per_page: 50 },
35
+ // });
36
36
 
37
- //API for return locations
38
- const { data: fetchedLocationData, loading: locationloading } = useApiHook<
39
- ApiResponse
40
- >({
41
- endpoint: `/return_locations/`,
42
- method: 'GET',
43
- pagination: { page: 1, per_page: 50 },
44
- });
37
+ // //API for return locations
38
+ // const { data: fetchedLocationData, loading: locationloading } = useApiHook<
39
+ // ApiResponse
40
+ // >({
41
+ // endpoint: `/return_locations/`,
42
+ // method: 'GET',
43
+ // pagination: { page: 1, per_page: 50 },
44
+ // });
45
45
 
46
- useEffect(() => {
47
- if (fetchedCustomerData && fetchedCustomerData?.data) {
48
- setCustomers(fetchedCustomerData?.data);
49
- }
50
- }, [loading, fetchedCustomerData]);
46
+ // useEffect(() => {
47
+ // if (fetchedCustomerData && fetchedCustomerData?.data) {
48
+ // setCustomers(fetchedCustomerData?.data);
49
+ // }
50
+ // }, [loading]);
51
51
 
52
- useEffect(() => {
53
- if (fetchedStaticData && fetchedStaticData?.data) {
54
- setActionType(
55
- fetchedStaticData?.data?.flatMap(
56
- (i: any) => i?.order_product_return_action
57
- )
58
- );
59
- setStatusOfOrders(
60
- fetchedStaticData?.data?.flatMap((i: any) => i?.order_stock_alias)
61
- );
62
- }
63
- }, [actionLoading, fetchedStaticData]);
52
+ // useEffect(() => {
53
+ // if (fetchedStaticData && fetchedStaticData?.data) {
54
+ // setActionType(
55
+ // fetchedStaticData?.data?.flatMap(
56
+ // (i: any) => i?.order_product_return_action
57
+ // )
58
+ // );
59
+ // setStatusOfOrders(
60
+ // fetchedStaticData?.data?.flatMap((i: any) => i?.order_stock_alias)
61
+ // );
62
+ // }
63
+ // }, [actionLoading]);
64
64
 
65
- useEffect(() => {
66
- if (fetchedLocationData && fetchedLocationData?.data) {
67
- setLocationData(fetchedLocationData?.data);
68
- }
69
- }, [locationloading, fetchedLocationData]);
65
+ // useEffect(() => {
66
+ // if (fetchedLocationData && fetchedLocationData?.data) {
67
+ // setLocationData(fetchedLocationData?.data);
68
+ // }
69
+ // }, [locationloading]);
70
70
 
71
71
  return (
72
72
  <CoverPage>
@@ -17,6 +17,7 @@ import {
17
17
  useNewReturnPayload,
18
18
  useReturnPayload,
19
19
  useSelectAll,
20
+ useSelectedConfirmLoc,
20
21
  useSelectedOrders,
21
22
  } from '../../store';
22
23
  import { filtersReducerAtom } from './filterStore';
@@ -55,6 +56,7 @@ function SelectionFilter() {
55
56
  const [, setGrouped] = useGroupedPayload();
56
57
  const [, setSelectedReturnOrder] = useSelectedOrders();
57
58
  const [, setSelectAll] = useSelectAll();
59
+ const [, setCheck] = useSelectedConfirmLoc();
58
60
 
59
61
  //client options
60
62
  const clientOptions = customers?.map((option: any) => ({
@@ -116,6 +118,7 @@ function SelectionFilter() {
116
118
  setNewPayload([]);
117
119
  setGrouped([]);
118
120
  setSelectAll(false);
121
+ setCheck([]);
119
122
  };
120
123
 
121
124
  useEffect(() => {
@@ -152,57 +155,67 @@ function SelectionFilter() {
152
155
  }, [storedUuid, locationData]);
153
156
 
154
157
  //location change
155
- const handleLocationChange = (value: any, option: DefaultOptionType) => {
156
- const selectedLabel = option?.label as string;
158
+ const handleLocationChange = (value: any) => {
157
159
  setSelectedLocationValue(value);
158
-
159
- if (selectedLocationValue === selectedLabel) {
160
- dispatch({
161
- type: 'CLEAR_ALL_FILTERS',
162
- payload: null,
163
- });
164
- }
165
160
  };
166
161
 
167
162
  //action type
168
163
  const handleActionClick = (value: any) => {
169
164
  setSelectedFilterValue(value);
170
- if (selectedFilterValue === value) {
171
- dispatch({
172
- type: 'CLEAR_ALL_FILTERS',
173
- payload: null,
174
- });
175
- }
176
165
  };
166
+ const storedName = localStorage.getItem('clientName');
167
+ const storedClientId = localStorage.getItem('clientId');
177
168
 
178
169
  //Apply filters
179
170
  const applyFilters = () => {
180
171
  if (storedName) {
181
172
  setClientLabel(storedName);
182
173
  }
174
+ //client value
183
175
  if (storedClientId) {
184
176
  dispatch({
185
177
  type: 'SET_CLIENT_FILTER',
186
178
  payload: storedClientId,
187
179
  });
180
+ dispatch({
181
+ type: 'SET_PAGE',
182
+ payload: 1,
183
+ });
184
+ } else {
185
+ dispatch({
186
+ type: 'SET_CLIENT_FILTER',
187
+ payload: [],
188
+ });
188
189
  }
190
+ //action value
189
191
  if (selectedFilterValue) {
190
192
  dispatch({
191
193
  type: 'SET_ACTIONS_FILTER',
192
194
  payload: selectedFilterValue,
193
195
  });
196
+ dispatch({
197
+ type: 'SET_PAGE',
198
+ payload: 1,
199
+ });
194
200
  }
195
-
196
- if (selectedLocationValue) {
201
+ //location value
202
+ if (selectedLocationValue && selectedLocationValue.length > 0) {
197
203
  dispatch({
198
204
  type: 'SET_LOCATION_FILTER',
199
205
  payload: selectedLocationValue,
200
206
  });
207
+ dispatch({
208
+ type: 'SET_PAGE',
209
+ payload: 1,
210
+ });
201
211
  }
202
212
  };
203
213
 
204
- const storedName = localStorage.getItem('clientName');
205
- const storedClientId = localStorage.getItem('clientId');
214
+ useEffect(() => {
215
+ return () => {
216
+ dispatch({ type: 'CLEAR_CLIENT' });
217
+ };
218
+ }, []);
206
219
 
207
220
  useEffect(() => {
208
221
  if (storedClientId) {
@@ -221,6 +234,21 @@ function SelectionFilter() {
221
234
  }
222
235
  }, [storedName, selectedFilterValue, selectedLocationValue]);
223
236
 
237
+ useEffect(() => {}, [location.pathname]);
238
+
239
+ useEffect(() => {
240
+ if (!selectedFilterValue || selectedFilterValue === null) {
241
+ dispatch({ type: 'CLEAR_ACTION' });
242
+ }
243
+ if (
244
+ !selectedLocationValue ||
245
+ (Array.isArray(selectedLocationValue) &&
246
+ selectedLocationValue.length === 0)
247
+ ) {
248
+ dispatch({ type: 'CLEAR_LOC' });
249
+ }
250
+ }, [selectedFilterValue, selectedLocationValue]);
251
+
224
252
  return (
225
253
  <Wrapper>
226
254
  <FilterRow>
@@ -236,34 +264,38 @@ function SelectionFilter() {
236
264
  />
237
265
  </FilterColumn>
238
266
 
239
- <FilterColumn>
240
- <Label>Action Type</Label>
241
- <StyledAntSelect
242
- options={actionTypeOptions}
243
- placeholder="Select Action Type"
244
- value={selectedFilterValue}
245
- onChange={handleActionClick}
246
- style={{ minWidth: '14vw' }}
247
- allowClear
248
- />
249
- </FilterColumn>
267
+ {storedName && location.pathname.includes(`/filter/`) ? (
268
+ <>
269
+ <FilterColumn>
270
+ <Label>Action Type</Label>
271
+ <StyledAntSelect
272
+ options={actionTypeOptions}
273
+ placeholder="Select Action Type"
274
+ value={selectedFilterValue}
275
+ onChange={handleActionClick}
276
+ style={{ minWidth: '14vw' }}
277
+ allowClear
278
+ />
279
+ </FilterColumn>
250
280
 
251
- <FilterColumn>
252
- <Label>Location </Label>
253
- <StyledAntSelect
254
- options={
255
- filteredLocationOptions?.length > 0
256
- ? filteredLocationOptions
257
- : LocationOptions
258
- }
259
- value={selectedLocationValue}
260
- placeholder="Select Location"
261
- onChange={handleLocationChange}
262
- style={{ minWidth: '14vw' }}
263
- allowClear
264
- mode="multiple"
265
- />
266
- </FilterColumn>
281
+ <FilterColumn>
282
+ <Label>Location </Label>
283
+ <StyledAntSelect
284
+ options={
285
+ filteredLocationOptions?.length > 0
286
+ ? filteredLocationOptions
287
+ : LocationOptions
288
+ }
289
+ value={selectedLocationValue}
290
+ placeholder="Select Location"
291
+ onChange={handleLocationChange}
292
+ style={{ minWidth: '14vw' }}
293
+ allowClear
294
+ mode="multiple"
295
+ />
296
+ </FilterColumn>
297
+ </>
298
+ ) : null}
267
299
  </LeftColumn>
268
300
  <RightColumn>
269
301
  <ApplyButton onClick={applyFilters} disabled={!isButtonEnabled}>
@@ -280,6 +312,10 @@ const StyledAntSelect = styled(Select)`
280
312
  /* width: 22vw; */
281
313
  border-radius: 22px;
282
314
  }
315
+ .ant-select-clear {
316
+ top: 40% !important;
317
+ font-size: 18px !important;
318
+ }
283
319
  `;
284
320
 
285
321
  export default SelectionFilter;
@@ -129,6 +129,7 @@ export const FilterColumn = styled.div`
129
129
  export const RightColumn = styled.div`
130
130
  flex-direction: row;
131
131
  display: flex;
132
+ gap: 15px;
132
133
  `;
133
134
 
134
135
  export const LeftColumn = styled.div`
@@ -25,7 +25,7 @@ interface FilterState {
25
25
  // let todayDate = new Date();
26
26
  const initialState: FilterState = {
27
27
  'x-filters': [],
28
- 'x-pagination': { page: 1, per_page: 5 },
28
+ 'x-pagination': { page: 1, per_page: 50 },
29
29
  };
30
30
 
31
31
  const filterReducer = (state: FilterState, action: any): FilterState => {
@@ -98,6 +98,22 @@ const filterReducer = (state: FilterState, action: any): FilterState => {
98
98
  ],
99
99
  };
100
100
 
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
+
109
+ case 'CLEAR_ACTION':
110
+ return {
111
+ ...state,
112
+ 'x-filters': state['x-filters'].filter(
113
+ f => f.field !== 'product_return_action_id'
114
+ ),
115
+ };
116
+
101
117
  case 'CLEAR_LOC':
102
118
  return {
103
119
  ...state,
@@ -3,29 +3,28 @@ import {
3
3
  //useItemsPerPage,
4
4
  useLoading,
5
5
  //UsePaginationData,
6
- useTableName,
7
6
  } from './store/store';
8
7
  import Filters from './filters/Filters';
9
8
  import styled from 'styled-components';
10
9
  import { useStickyStatus } from '../store';
11
10
  import HeaderFilter from './header-filters/HeaderFilter';
12
11
  import { useApiHook } from '@bjsdistribution/dms-component-library';
13
- import { useAtom, useClientData } from '../order-view/store';
12
+ import { useClientData } from '../order-view/store';
14
13
  import { ClientData } from './common/interface';
15
14
  import ReturnFilter from './return-order-table/return-orders-filters/ReturnFilter';
16
15
  import { Text } from './filters/FilterStyle';
17
16
  import ReturnTable from './table/ReturnTable';
18
17
  // import Pagination from './table-view/Pagination';
19
- import { overviewfiltersReducerAtom } from './header-filters/overViewFilter';
18
+ // import { overviewfiltersReducerAtom } from './header-filters/overViewFilter';
20
19
 
21
20
  function ReturnMainTable() {
22
- const [state] = useAtom(overviewfiltersReducerAtom);
21
+ // const [state] = useAtom(overviewfiltersReducerAtom);
23
22
  // const [paginationObj] = UsePaginationData();
24
23
  // const [, setCurrentPage] = useState(1);
25
24
  // const [itemsPerPage, setItemsPerPage] = useItemsPerPage();
26
- const { 'x-pagination': pagination } = state;
25
+ // const { 'x-pagination': pagination } = state;
27
26
  // const { page, total } = paginationObj;
28
- const [selectedClient] = useTableName();
27
+ // const [selectedClient] = useTableName();
29
28
  // const [, setPaginationObject] = UsePaginationData();
30
29
  const [isScrolled] = useStickyStatus();
31
30
  const [, setLoading] = useLoading();
@@ -47,7 +46,7 @@ function ReturnMainTable() {
47
46
  }>({
48
47
  endpoint: `/return_orders/get/client-returns/`,
49
48
  method: 'GET',
50
- pagination: pagination,
49
+ pagination: { page: 1, per_page: 200 },
51
50
  });
52
51
 
53
52
  useEffect(() => {
@@ -67,6 +66,8 @@ function ReturnMainTable() {
67
66
  }
68
67
  }, [staticDataLoading]);
69
68
 
69
+ const getClient = localStorage.getItem('clientName');
70
+
70
71
  return (
71
72
  <>
72
73
  <DashBoardWrapper className={` ${isScrolled ? 'stickyTableHead' : ''}`}>
@@ -76,7 +77,7 @@ function ReturnMainTable() {
76
77
  <Container>
77
78
  <Row>
78
79
  <Text>Client Return</Text>
79
- {selectedClient ? <ReturnFilter /> : <Filters />}
80
+ {getClient ? <ReturnFilter /> : <Filters />}
80
81
  </Row>
81
82
  <ReturnTable />
82
83
  </Container>
@@ -1,7 +1,5 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import styled from 'styled-components';
3
- // import RouterHeader from '../header/route-header/RouterHeader';
4
- import HeaderFilter from '../header-filters/HeaderFilter';
5
3
  import OrderTable from './table/OrderTable';
6
4
  import ReturnOrderFilter from './table-filters/ReturnOrderFilter';
7
5
  import { useAtom, useReturnAfterOrderData } from '../../order-view/store';
@@ -22,12 +20,16 @@ const ReturnAfterTable = () => {
22
20
  const [, setLoading] = useLoading();
23
21
  const [state] = useAtom(filtersReducerReturnAtom);
24
22
  const { 'x-filters': filters, 'x-pagination': pagination } = state;
25
-
23
+ const splitPath = (str: any) => {
24
+ const parts = str?.split('/')?.filter((part: any) => part !== ''); // Filter out empty parts
25
+ return parts;
26
+ };
27
+ const paths = splitPath(location.pathname);
26
28
  const [paginationObj] = UsePaginationReturnData();
27
29
  const [, setCurrentPage] = useState(1);
28
30
  const [itemsPerPage, setItemsPerPage] = useItemsPerReturnPage();
29
31
  const [, setPaginationObject] = UsePaginationData();
30
-
32
+ console.log(paths, 'paths');
31
33
  const { page, total } = paginationObj;
32
34
 
33
35
  const handlePageChange = (page: number) => {
@@ -68,7 +70,7 @@ const ReturnAfterTable = () => {
68
70
  <DashBoardWrapper>
69
71
  {/* <RouterHeader /> */}
70
72
  <div className="Tableconatiner">
71
- <HeaderFilter />
73
+ {/* <HeaderFilter /> */}
72
74
  <Container>
73
75
  <ReturnOrderFilter />
74
76
  <OrderTable />
@@ -89,7 +91,7 @@ const ReturnAfterTable = () => {
89
91
  };
90
92
  const Container = styled.div`
91
93
  position: relative;
92
- top: -30px;
94
+ /* top: -30px; */
93
95
  `;
94
96
  const DashBoardWrapper = styled.section`
95
97
  .Tableconatiner {
@@ -1,4 +1,4 @@
1
- import { AntSelect, Checkbox } from '@bjsdistribution/dms-component-library';
1
+ import { AntSelect } from '@bjsdistribution/dms-component-library';
2
2
  import { Empty } from 'antd';
3
3
  import React, { useEffect, useRef } from 'react';
4
4
  import { Skeleton } from 'antd';
@@ -113,9 +113,9 @@ const OrderTable = ({ loadingskeleton }: any) => {
113
113
  <StyledTable>
114
114
  <thead>
115
115
  <tr>
116
- <th className="emailInvoiceCheckbox">
116
+ {/* <th className="emailInvoiceCheckbox">
117
117
  <Checkbox checked={false} />
118
- </th>
118
+ </th> */}
119
119
  <th className="emailInvoiceNo">Created</th>
120
120
  <th>Return Location</th>
121
121
  <th>Pick Up Location</th>
@@ -161,12 +161,12 @@ const OrderTable = ({ loadingskeleton }: any) => {
161
161
  const statusClass = getStatusClass(status);
162
162
  return (
163
163
  <tr key={item.id}>
164
- <td>
164
+ {/* <td>
165
165
  <Checkbox
166
166
  checked={false}
167
167
  // onChange={() => handleSelectInvoice(item.id)}
168
168
  />
169
- </td>
169
+ </td> */}
170
170
  <td>{formatDate(new Date(item?.created_at))}</td>
171
171
  <td>
172
172
  {displayValueOrNA(item?.return_locations?.location_name)}
@@ -29,6 +29,7 @@ const initialState: FilterState = {
29
29
  };
30
30
 
31
31
  const filterReducer = (state: FilterState, action: any): FilterState => {
32
+ console.log(action,'action')
32
33
  switch (action.type) {
33
34
  case 'SET_DATE_FILTER':
34
35
  return {