@bjsdistribution/dms-client-return 0.0.10 → 0.0.12

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 (26) hide show
  1. package/dist/components/order-daily-overview/common/fakedata.d.ts +4 -0
  2. package/dist/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.d.ts +1 -1
  3. package/dist/components/order-view/details-filters/left-side-filters/dropdowns/{PrintDropDown.d.ts → PrintDropDownReturn.d.ts} +2 -2
  4. package/dist/components/store.d.ts +6 -1
  5. package/dist/dms-client-return.cjs.development.js +289 -210
  6. package/dist/dms-client-return.cjs.development.js.map +1 -1
  7. package/dist/dms-client-return.cjs.production.min.js +1 -1
  8. package/dist/dms-client-return.cjs.production.min.js.map +1 -1
  9. package/dist/dms-client-return.esm.js +290 -211
  10. package/dist/dms-client-return.esm.js.map +1 -1
  11. package/package.json +2 -2
  12. package/src/components/order-daily-overview/common/fakedata.tsx +4 -0
  13. package/src/components/order-daily-overview/header-filters/HeaderFilter.tsx +10 -1
  14. package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +15 -7
  15. package/src/components/order-daily-overview/index.tsx +1 -1
  16. package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +4 -8
  17. package/src/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.ts +12 -14
  18. package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx +41 -39
  19. package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +80 -37
  20. package/src/components/order-daily-overview/return-order-table/return-orders-filters/returnstyles.ts +17 -0
  21. package/src/components/order-daily-overview/shared/utlis.ts +7 -1
  22. package/src/components/order-daily-overview/table-view/Pagination.tsx +15 -14
  23. package/src/components/order-view/details-filters/left-side-filters/dropdowns/{PrintDropDown.tsx → PrintDropDownReturn.tsx} +4 -4
  24. package/src/components/order-view/modalsPopup/CreateReturnModal.tsx +74 -36
  25. package/src/components/order-view/modalsPopup/ModalManager.tsx +47 -12
  26. package/src/components/store.ts +35 -0
@@ -2,16 +2,18 @@ import React from 'react';
2
2
  import {
3
3
  StyledContainer,
4
4
  StyledContentWrapper,
5
+ // StyledDropdown,
5
6
  StyledInfoBox,
6
7
  StyledLabel,
7
8
  StyledPaginationItem,
8
9
  StyledPaginationWrapper,
10
+ // StyledDropdownData,
9
11
  } from './PaginationStyle';
10
12
  import PrevIcon from '../../../assets/icons/PrevIcon';
11
13
  import NextIcon from '../../../assets/icons/NextIcon';
12
14
  import { useAtom } from 'jotai';
13
- import { filtersReducerAtom } from '../store/filterStore';
14
15
  import { Select } from 'antd';
16
+ import { filtersReducerAtom } from '../return-after-table/table-filters/ReturnFilterStore';
15
17
 
16
18
  const PAGE_SIZE_OPTIONS = [50, 100, 150];
17
19
  const MAX_PAGES_TO_SHOW = 5;
@@ -46,18 +48,17 @@ const Pagination: React.FC<any> = ({
46
48
  type: 'SET_PERPAGE',
47
49
  payload: newItemsPerPage,
48
50
  });
49
-
51
+
50
52
  // Reset to the first page
51
53
  dispatch({
52
54
  type: 'SET_PAGE',
53
55
  payload: 1,
54
56
  });
55
-
57
+
56
58
  onPageChange(1);
57
59
  onItemsPerPageChange(newItemsPerPage);
58
60
  };
59
61
 
60
-
61
62
  const getPageNumbers = (
62
63
  currentPage: number,
63
64
  totalPages: number
@@ -96,16 +97,16 @@ const Pagination: React.FC<any> = ({
96
97
  </StyledInfoBox>
97
98
  <StyledLabel>Row on Page</StyledLabel>
98
99
  <Select
99
- value={itemsPerPage}
100
- onChange={handleItemsPerPageChange}
101
- style={{ width: 75 }}
102
- >
103
- {PAGE_SIZE_OPTIONS.map(option => (
104
- <Select.Option key={option} value={option}>
105
- {option}
106
- </Select.Option>
107
- ))}
108
- </Select>
100
+ value={itemsPerPage}
101
+ onChange={handleItemsPerPageChange}
102
+ style={{ width: 75 }}
103
+ >
104
+ {PAGE_SIZE_OPTIONS.map(option => (
105
+ <Select.Option key={option} value={option}>
106
+ {option}
107
+ </Select.Option>
108
+ ))}
109
+ </Select>
109
110
  <StyledPaginationWrapper>
110
111
  <StyledPaginationItem
111
112
  onClick={() => handlePageChange(currentPage - 1)}
@@ -2,14 +2,14 @@ import React from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { PrintIconMap } from '../../../../order-daily-overview/shared/utlis';
4
4
  import { PrintData } from '../../../../order-daily-overview/shared/interface';
5
- import { optionsPrint } from '../../../../order-daily-overview/common/fakedata';
5
+ import { optionsForReturnPrint } from '../../../../order-daily-overview/common/fakedata';
6
6
  // import { PrintIconMap } from '../utils';
7
7
  // import { optionsPrint } from '../fakeData';
8
8
  // import { PrintData } from '../interface';
9
9
 
10
- const options: PrintData[] = optionsPrint;
10
+ const options: PrintData[] = optionsForReturnPrint;
11
11
 
12
- const PrintDropDown = () => {
12
+ const PrintDropDownReturn = () => {
13
13
  const downloadFiles = () => {};
14
14
  return (
15
15
  <OptionsList>
@@ -26,7 +26,7 @@ const PrintDropDown = () => {
26
26
  );
27
27
  };
28
28
 
29
- export default PrintDropDown;
29
+ export default PrintDropDownReturn;
30
30
 
31
31
  export const OptionsList = styled.ul`
32
32
  margin: 0;
@@ -1,56 +1,94 @@
1
1
  import { Alert, Checkbox } from '@bjsdistribution/dms-component-library';
2
- import React, { useState } from 'react';
2
+ import React, { useEffect } from 'react';
3
3
  import styled from 'styled-components';
4
- import { useSelectedOrders } from '../../store';
4
+ import {
5
+ useFinalPayload,
6
+ useGroupedPayload,
7
+ usePostLoading,
8
+ useSelectedConfirmLoc,
9
+ useSelectedOrders,
10
+ } from '../../store';
11
+ import { displayValueOrNA } from '../../order-daily-overview/shared/utlis';
12
+ import Loader from '../../order-daily-overview/header/loader/Loader';
5
13
 
6
14
  const CreateReturnModal = () => {
7
- const [selectedlocation, setSelectedLocations] = useState<any[]>([]);
15
+ const [selectedlocation, setSelectedLocations] = useSelectedConfirmLoc();
8
16
  const [selectedReturnOrder] = useSelectedOrders();
17
+ const [load] = usePostLoading();
18
+ const [groupedPayload] = useGroupedPayload();
19
+ const [forDisabledCheck] = useSelectedConfirmLoc();
20
+ const [, setNew] = useFinalPayload();
9
21
 
10
22
  const handleSelectLocations = (id: number) => {
11
23
  setSelectedLocations((prevSelectedLocations: number[]) => {
12
- const isSelected = prevSelectedLocations.includes(id);
24
+ const isSelected = prevSelectedLocations?.includes(id);
13
25
 
14
26
  if (isSelected) {
15
- return prevSelectedLocations.filter(selectedId => selectedId !== id);
27
+ return prevSelectedLocations?.filter(selectedId => selectedId !== id);
16
28
  } else {
17
29
  return [...prevSelectedLocations, id];
18
30
  }
19
31
  });
20
32
  };
21
33
 
34
+ const uniqueLocations = selectedReturnOrder?.reduce((acc, current) => {
35
+ const x = acc.find(
36
+ (item: any) => item.return_location === current.return_location
37
+ );
38
+ if (!x) {
39
+ acc.push(current);
40
+ }
41
+ return acc;
42
+ }, []);
43
+
44
+ useEffect(() => {
45
+ if (groupedPayload?.length > 0 && forDisabledCheck?.length > 0) {
46
+ const matchedItems = groupedPayload?.filter((item: any) =>
47
+ forDisabledCheck.includes(item.id)
48
+ );
49
+
50
+ if (matchedItems.length > 0) {
51
+ const finalPayload = matchedItems?.map(({ id, ...rest }: any) => rest);
52
+ setNew(finalPayload);
53
+ }
54
+ }
55
+ }, [forDisabledCheck]);
56
+
22
57
  return (
23
- <Wrapper>
24
- <Alert
25
- onClose={() => {}}
26
- description=""
27
- type="info"
28
- title="Do you wish to proceed?"
29
- showOkButton={false}
30
- />
31
- <Container>
32
- <ul style={{ listStyle: 'none', padding: 0 }}>
33
- {selectedReturnOrder?.map((returnLoc: any) => (
34
- <li
35
- key={returnLoc.id}
36
- style={{
37
- marginBottom: '8px',
38
- display: 'flex',
39
- alignItems: 'center',
40
- }}
41
- >
42
- <Checkbox
43
- checked={selectedlocation.includes(returnLoc.id)}
44
- onChange={() => handleSelectLocations(returnLoc.id)}
45
- />
46
- <StyledText style={{ marginLeft: '8px' }}>
47
- {returnLoc?.return_location}
48
- </StyledText>
49
- </li>
50
- ))}
51
- </ul>
52
- </Container>
53
- </Wrapper>
58
+ <>
59
+ {load && <Loader />}
60
+ <Wrapper>
61
+ <Alert
62
+ onClose={() => {}}
63
+ description=""
64
+ type="info"
65
+ title="Do you wish to proceed?"
66
+ showOkButton={false}
67
+ />
68
+ <Container>
69
+ <ul style={{ listStyle: 'none', padding: 0 }}>
70
+ {uniqueLocations?.map((returnLoc: any) => (
71
+ <li
72
+ key={returnLoc.id}
73
+ style={{
74
+ marginBottom: '8px',
75
+ display: 'flex',
76
+ alignItems: 'center',
77
+ }}
78
+ >
79
+ <Checkbox
80
+ checked={selectedlocation?.includes(returnLoc.id)}
81
+ onChange={() => handleSelectLocations(returnLoc.id)}
82
+ />
83
+ <StyledText style={{ marginLeft: '8px' }}>
84
+ {displayValueOrNA(returnLoc?.new_location)}
85
+ </StyledText>
86
+ </li>
87
+ ))}
88
+ </ul>
89
+ </Container>
90
+ </Wrapper>
91
+ </>
54
92
  );
55
93
  };
56
94
 
@@ -21,7 +21,16 @@ import DefectsModal from './DefectsModal';
21
21
  import repackModal from './RepackModal';
22
22
  import { ApiResponse } from '../types';
23
23
  import CreateReturnModal from './CreateReturnModal';
24
- import { useNewReturnPayload } from '../../store';
24
+ import {
25
+ useFinalPayload,
26
+ useGroupedPayload,
27
+ useNewReturnPayload,
28
+ usePostLoading,
29
+ useSelectAll,
30
+ useSelectedConfirmLoc,
31
+ useSelectedOrders,
32
+ } from '../../store';
33
+
25
34
  const ModalManager = () => {
26
35
  const [popupName, dispatch] = useAtom(countReducerAtom);
27
36
  const [,] = useProductDetails();
@@ -33,7 +42,13 @@ const ModalManager = () => {
33
42
  const [selectedProductId] = useAtom(selectedProductIdAtom);
34
43
  const [selectedTab] = useAtom(selectedTabKeyAtom);
35
44
  const [, setIsFormValid] = useState(false);
36
- const [newPayload, setNewPayload] = useNewReturnPayload();
45
+ const [newGrouped, setNewGrouped] = useFinalPayload();
46
+ const [, SetPostLoading] = usePostLoading();
47
+ const [, setSelectedReturnOrder] = useSelectedOrders();
48
+ const [, setCheck] = useSelectedConfirmLoc();
49
+ const [, setNewPayload] = useNewReturnPayload();
50
+ const [, setGrouped] = useGroupedPayload();
51
+ const [, setSelectAll] = useSelectAll();
37
52
 
38
53
  console.log(orderProduct, 'abcabcabcabcabcabcabcabcabcabcabc');
39
54
 
@@ -227,27 +242,47 @@ const ModalManager = () => {
227
242
  }, [updateResponse]);
228
243
 
229
244
  //Confirm return popup
230
- const { data: response, setShouldPerformAction } = useApiHook<{
245
+ const {
246
+ data: response,
247
+ setShouldPerformAction,
248
+ loading: confirmLoading,
249
+ } = useApiHook<{
231
250
  data: ApiResponse[];
232
251
  }>({
233
252
  endpoint: `return_orders/`,
234
253
  method: 'POST',
235
- body: [newPayload],
254
+ body: newGrouped,
236
255
  performAction: false,
237
256
  });
238
- const handleConfirmReturn = () => {
239
- const payloadWithoutId = newPayload?.map(({ id, ...rest }: any) => ({
240
- ...rest,
241
- }));
242
257
 
243
- console.log(response);
258
+ useEffect(() => {
259
+ SetPostLoading(confirmLoading);
260
+ }, [confirmLoading]);
261
+
262
+ console.log(response);
244
263
 
245
- if (payloadWithoutId) {
246
- setNewPayload(payloadWithoutId);
264
+ useEffect(() => {
265
+ if (response === null || (response && response?.data)) {
266
+ dispatch({ type: 'close' });
267
+ setNewGrouped([]);
268
+ setSelectedReturnOrder([]);
269
+ setCheck([]);
270
+ setNewPayload([]);
271
+ setGrouped([]);
272
+ setShouldPerformAction(false);
273
+ setSelectAll(false);
274
+ }
275
+ }, [response]);
276
+
277
+ const handleConfirmReturn = () => {
278
+ setShouldPerformAction(false);
279
+
280
+ if (newGrouped.length > 0) {
247
281
  setShouldPerformAction(true);
248
282
  } else {
249
283
  setShouldPerformAction(false);
250
284
  }
285
+ dispatch({ type: 'close' });
251
286
  };
252
287
 
253
288
  return (
@@ -267,7 +302,7 @@ const ModalManager = () => {
267
302
  btnStyle: 'rounded',
268
303
  onClick: handleConfirmReturn,
269
304
  type: 'button',
270
- disabled: !newPayload,
305
+ // disabled: forDisabledCheck.length === 0,
271
306
  },
272
307
  ],
273
308
 
@@ -41,6 +41,16 @@ const newPayload = atom<any>([]);
41
41
 
42
42
  const grpPayload = atom<any>([]);
43
43
 
44
+ const statusOfOrder = atom<any>([]);
45
+
46
+ const selectedLocationConfirm = atom<any[]>([]);
47
+
48
+ const selectAll = atom<boolean>(false);
49
+
50
+ const postLoading = atom<boolean>(false);
51
+
52
+ const final = atom<any[]>([]);
53
+
44
54
  function useReminderData() {
45
55
  return useAtom(reminderTableData);
46
56
  }
@@ -105,6 +115,26 @@ function useGroupedPayload() {
105
115
  return useAtom(grpPayload);
106
116
  }
107
117
 
118
+ function useStatusOrderData() {
119
+ return useAtom(statusOfOrder);
120
+ }
121
+
122
+ function useSelectedConfirmLoc() {
123
+ return useAtom(selectedLocationConfirm);
124
+ }
125
+
126
+ function useSelectAll() {
127
+ return useAtom(selectAll);
128
+ }
129
+
130
+ function usePostLoading() {
131
+ return useAtom(postLoading);
132
+ }
133
+
134
+ function useFinalPayload() {
135
+ return useAtom(final);
136
+ }
137
+
108
138
  export {
109
139
  useAtom,
110
140
  useFilter,
@@ -122,4 +152,9 @@ export {
122
152
  useReturnPayload,
123
153
  useNewReturnPayload,
124
154
  useGroupedPayload,
155
+ useStatusOrderData,
156
+ useSelectedConfirmLoc,
157
+ useSelectAll,
158
+ usePostLoading,
159
+ useFinalPayload,
125
160
  };