@bjsdistribution/dms-client-return 0.0.19 → 0.0.21

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 +519 -402
  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 +520 -403
  8. package/dist/dms-client-return.esm.js.map +1 -1
  9. package/package.json +2 -2
  10. package/src/components/order-daily-overview/header-filters/HeaderFilter.tsx +58 -58
  11. package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +85 -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 +9 -5
  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 +73 -38
  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 +69 -31
  26. package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +21 -2
  27. package/src/index.tsx +74 -1
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.19",
2
+ "version": "0.0.21",
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.1.6",
62
+ "@bjsdistribution/dms-component-library": "0.1.4",
63
63
  "@size-limit/preset-small-lib": "^11.0.1",
64
64
  "@tippyjs/react": "^4.2.6",
65
65
  "@types/react": "^18.2.47",
@@ -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,70 @@ 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
+ // Reset to the first page
181
+ dispatch({
182
+ type: 'SET_PAGE',
183
+ payload: 1,
184
+ });
185
+ } else {
186
+ dispatch({
187
+ type: 'SET_CLIENT_FILTER',
188
+ payload: [],
189
+ });
188
190
  }
191
+ //action value
189
192
  if (selectedFilterValue) {
190
193
  dispatch({
191
194
  type: 'SET_ACTIONS_FILTER',
192
195
  payload: selectedFilterValue,
193
196
  });
197
+ // Reset to the first page
198
+ dispatch({
199
+ type: 'SET_PAGE',
200
+ payload: 1,
201
+ });
194
202
  }
195
-
196
- if (selectedLocationValue) {
203
+ //location value
204
+ if (selectedLocationValue && selectedLocationValue.length > 0) {
197
205
  dispatch({
198
206
  type: 'SET_LOCATION_FILTER',
199
207
  payload: selectedLocationValue,
200
208
  });
209
+ // Reset to the first page
210
+ dispatch({
211
+ type: 'SET_PAGE',
212
+ payload: 1,
213
+ });
201
214
  }
202
215
  };
203
216
 
204
- const storedName = localStorage.getItem('clientName');
205
- const storedClientId = localStorage.getItem('clientId');
217
+ useEffect(() => {
218
+ return () => {
219
+ dispatch({ type: 'CLEAR_CLIENT' });
220
+ };
221
+ }, []);
206
222
 
207
223
  useEffect(() => {
208
224
  if (storedClientId) {
@@ -221,6 +237,21 @@ function SelectionFilter() {
221
237
  }
222
238
  }, [storedName, selectedFilterValue, selectedLocationValue]);
223
239
 
240
+ useEffect(() => {}, [location.pathname]);
241
+
242
+ useEffect(() => {
243
+ if (!selectedFilterValue || selectedFilterValue === null) {
244
+ dispatch({ type: 'CLEAR_ACTION' });
245
+ }
246
+ if (
247
+ !selectedLocationValue ||
248
+ (Array.isArray(selectedLocationValue) &&
249
+ selectedLocationValue.length === 0)
250
+ ) {
251
+ dispatch({ type: 'CLEAR_LOC' });
252
+ }
253
+ }, [selectedFilterValue, selectedLocationValue]);
254
+
224
255
  return (
225
256
  <Wrapper>
226
257
  <FilterRow>
@@ -236,34 +267,38 @@ function SelectionFilter() {
236
267
  />
237
268
  </FilterColumn>
238
269
 
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>
270
+ {storedName && location.pathname.includes(`/filter/`) ? (
271
+ <>
272
+ <FilterColumn>
273
+ <Label>Action Type</Label>
274
+ <StyledAntSelect
275
+ options={actionTypeOptions}
276
+ placeholder="Select Action Type"
277
+ value={selectedFilterValue}
278
+ onChange={handleActionClick}
279
+ style={{ minWidth: '14vw' }}
280
+ allowClear
281
+ />
282
+ </FilterColumn>
250
283
 
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>
284
+ <FilterColumn>
285
+ <Label>Location </Label>
286
+ <StyledAntSelect
287
+ options={
288
+ filteredLocationOptions?.length > 0
289
+ ? filteredLocationOptions
290
+ : LocationOptions
291
+ }
292
+ value={selectedLocationValue}
293
+ placeholder="Select Location"
294
+ onChange={handleLocationChange}
295
+ style={{ minWidth: '14vw' }}
296
+ allowClear
297
+ mode="multiple"
298
+ />
299
+ </FilterColumn>
300
+ </>
301
+ ) : null}
267
302
  </LeftColumn>
268
303
  <RightColumn>
269
304
  <ApplyButton onClick={applyFilters} disabled={!isButtonEnabled}>
@@ -280,6 +315,10 @@ const StyledAntSelect = styled(Select)`
280
315
  /* width: 22vw; */
281
316
  border-radius: 22px;
282
317
  }
318
+ .ant-select-clear {
319
+ top: 40% !important;
320
+ font-size: 18px !important;
321
+ }
283
322
  `;
284
323
 
285
324
  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,7 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import styled from 'styled-components';
3
3
  // import RouterHeader from '../header/route-header/RouterHeader';
4
- import HeaderFilter from '../header-filters/HeaderFilter';
4
+ // import HeaderFilter from '../header-filters/HeaderFilter';
5
5
  import OrderTable from './table/OrderTable';
6
6
  import ReturnOrderFilter from './table-filters/ReturnOrderFilter';
7
7
  import { useAtom, useReturnAfterOrderData } from '../../order-view/store';
@@ -22,12 +22,16 @@ const ReturnAfterTable = () => {
22
22
  const [, setLoading] = useLoading();
23
23
  const [state] = useAtom(filtersReducerReturnAtom);
24
24
  const { 'x-filters': filters, 'x-pagination': pagination } = state;
25
-
25
+ const splitPath = (str: any) => {
26
+ const parts = str?.split('/')?.filter((part: any) => part !== ''); // Filter out empty parts
27
+ return parts;
28
+ };
29
+ const paths = splitPath(location.pathname);
26
30
  const [paginationObj] = UsePaginationReturnData();
27
31
  const [, setCurrentPage] = useState(1);
28
32
  const [itemsPerPage, setItemsPerPage] = useItemsPerReturnPage();
29
33
  const [, setPaginationObject] = UsePaginationData();
30
-
34
+ console.log(paths, 'paths');
31
35
  const { page, total } = paginationObj;
32
36
 
33
37
  const handlePageChange = (page: number) => {
@@ -68,7 +72,7 @@ const ReturnAfterTable = () => {
68
72
  <DashBoardWrapper>
69
73
  {/* <RouterHeader /> */}
70
74
  <div className="Tableconatiner">
71
- <HeaderFilter />
75
+ {/* <HeaderFilter /> */}
72
76
  <Container>
73
77
  <ReturnOrderFilter />
74
78
  <OrderTable />
@@ -89,7 +93,7 @@ const ReturnAfterTable = () => {
89
93
  };
90
94
  const Container = styled.div`
91
95
  position: relative;
92
- top: -30px;
96
+ /* top: -30px; */
93
97
  `;
94
98
  const DashBoardWrapper = styled.section`
95
99
  .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 {