@bjsdistribution/dms-client-return 0.0.18 → 0.0.20

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 (80) hide show
  1. package/dist/assets/icons/DustbinIcon.d.ts +3 -0
  2. package/dist/common/date-picker/header/ClearDate.d.ts +1 -1
  3. package/dist/components/order-daily-overview/header-filters/overViewFilter.d.ts +16 -0
  4. package/dist/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.d.ts +1 -1
  5. package/dist/components/order-daily-overview/store/store.d.ts +2 -0
  6. package/dist/components/order-daily-overview/table-view/ReturnPagination.d.ts +3 -0
  7. package/dist/components/order-daily-overview/table-view/TableStyle.d.ts +4 -4
  8. package/dist/components/order-view/fakedata.d.ts +1 -1
  9. package/dist/components/order-view/order-actions/Dropdown.d.ts +6 -2
  10. package/dist/components/order-view/order-actions/actions/confirm-order/customer-info/ContactWith.d.ts +3 -0
  11. package/dist/components/order-view/order-actions/actions/confirm-order/tables/NotesTable.d.ts +1 -1
  12. package/dist/components/order-view/order-actions/actions/confirm-order/tables/ProductTable.d.ts +1 -1
  13. package/dist/components/order-view/order-actions/actions/confirm-order/tables/ReminderStyles.d.ts +9 -0
  14. package/dist/components/order-view/order-actions/store.d.ts +34 -1
  15. package/dist/components/order-view/order-actions/types.d.ts +5 -0
  16. package/dist/components/order-view/store.d.ts +1 -0
  17. package/dist/components/order-view/types.d.ts +5 -2
  18. package/dist/dms-client-return.cjs.development.js +2395 -1670
  19. package/dist/dms-client-return.cjs.development.js.map +1 -1
  20. package/dist/dms-client-return.cjs.production.min.js +1 -1
  21. package/dist/dms-client-return.cjs.production.min.js.map +1 -1
  22. package/dist/dms-client-return.esm.js +2398 -1673
  23. package/dist/dms-client-return.esm.js.map +1 -1
  24. package/package.json +2 -2
  25. package/src/assets/icons/DustbinIcon.tsx +20 -0
  26. package/src/common/modals/order-action-modal/OrderActionModal.tsx +4 -2
  27. package/src/components/order-daily-overview/header-filters/filterStore.ts +19 -18
  28. package/src/components/order-daily-overview/header-filters/overViewFilter.ts +80 -0
  29. package/src/components/order-daily-overview/index.tsx +27 -33
  30. package/src/components/order-daily-overview/return-after-table/ReturnAfterTable.tsx +47 -5
  31. package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +9 -5
  32. package/src/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.ts +1 -1
  33. package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx +2 -2
  34. package/src/components/order-daily-overview/return-order-table/ReturnTable.tsx +25 -1
  35. package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +29 -11
  36. package/src/components/order-daily-overview/store/store.ts +11 -1
  37. package/src/components/order-daily-overview/table-view/Pagination.tsx +2 -1
  38. package/src/components/order-daily-overview/table-view/ReturnPagination.tsx +136 -0
  39. package/src/components/order-view/details-filters/left-side-filters/dropdowns/OptionsDropDown.tsx +26 -12
  40. package/src/components/order-view/details-filters/right-side-filters/Details.tsx +8 -1
  41. package/src/components/order-view/fakedata.ts +5 -9
  42. package/src/components/order-view/general-information/dropdowns/BjsMenu.tsx +15 -4
  43. package/src/components/order-view/general-information/dropdowns/Print.tsx +79 -39
  44. package/src/components/order-view/general-information/dropdowns/index.tsx +0 -13
  45. package/src/components/order-view/general-information/index.tsx +3 -19
  46. package/src/components/order-view/generic-table/AuditLogs.tsx +7 -5
  47. package/src/components/order-view/index.tsx +1 -2
  48. package/src/components/order-view/modalsPopup/ModalManager.tsx +69 -196
  49. package/src/components/order-view/notes/AddNote.tsx +4 -14
  50. package/src/components/order-view/notes/index.tsx +8 -13
  51. package/src/components/order-view/order-actions/Dropdown.tsx +8 -3
  52. package/src/components/order-view/order-actions/actions/cancel-order/index.tsx +146 -12
  53. package/src/components/order-view/order-actions/actions/charge-log/index.tsx +126 -79
  54. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ActionDropdown.tsx +21 -9
  55. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactMobile.tsx +64 -1
  56. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactPhone.tsx +67 -1
  57. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactTypeDropdown.tsx +19 -7
  58. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactWith.tsx +28 -0
  59. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactWork.tsx +65 -1
  60. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/DeliveryDate.tsx +40 -3
  61. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/EmailAddress.tsx +47 -2
  62. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/TimedServiceDropdown.tsx +38 -9
  63. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/index.tsx +4 -1
  64. package/src/components/order-view/order-actions/actions/confirm-order/index.tsx +196 -6
  65. package/src/components/order-view/order-actions/actions/confirm-order/slot-and-instructions/index.tsx +5 -1
  66. package/src/components/order-view/order-actions/actions/confirm-order/tables/NotesTable.tsx +121 -20
  67. package/src/components/order-view/order-actions/actions/confirm-order/tables/ProductTable.tsx +54 -32
  68. package/src/components/order-view/order-actions/actions/confirm-order/tables/ReminderStyles.tsx +289 -0
  69. package/src/components/order-view/order-actions/actions/create-task-reminder/CreateReminderModal.tsx +41 -8
  70. package/src/components/order-view/order-actions/actions/create-task-reminder/index.tsx +11 -83
  71. package/src/components/order-view/order-actions/actions/hold-order/HoldOrderModal.tsx +61 -14
  72. package/src/components/order-view/order-actions/actions/release-order/ReleaseOrder.tsx +93 -25
  73. package/src/components/order-view/order-actions/actions/split-order/SplitOrderTable.tsx +102 -247
  74. package/src/components/order-view/order-actions/actions/split-order/index.tsx +57 -9
  75. package/src/components/order-view/order-actions/index.tsx +7 -2
  76. package/src/components/order-view/order-actions/store.ts +45 -0
  77. package/src/components/order-view/order-actions/types.ts +5 -0
  78. package/src/components/order-view/order-details/expanded-content/footer/index.tsx +15 -12
  79. package/src/components/order-view/store.ts +7 -0
  80. package/src/components/order-view/types.ts +5 -2
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.18",
2
+ "version": "0.0.20",
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.3",
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",
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+
3
+ const DustbinIcon = () => {
4
+ return (
5
+ <svg
6
+ xmlns="http://www.w3.org/2000/svg"
7
+ width="17"
8
+ height="16"
9
+ viewBox="0 0 17 16"
10
+ fill="none"
11
+ >
12
+ <path
13
+ d="M6.76699 11L8.50033 9.26667L10.2337 11L11.167 10.0667L9.43366 8.33333L11.167 6.6L10.2337 5.66667L8.50033 7.4L6.76699 5.66667L5.83366 6.6L7.56699 8.33333L5.83366 10.0667L6.76699 11ZM5.16699 14C4.80033 14 4.48655 13.8696 4.22566 13.6087C3.96477 13.3478 3.8341 13.0338 3.83366 12.6667V4H3.16699V2.66667H6.50033V2H10.5003V2.66667H13.8337V4H13.167V12.6667C13.167 13.0333 13.0365 13.3473 12.7757 13.6087C12.5148 13.87 12.2008 14.0004 11.8337 14H5.16699ZM11.8337 4H5.16699V12.6667H11.8337V4Z"
14
+ fill="#E95252"
15
+ />
16
+ </svg>
17
+ );
18
+ };
19
+
20
+ export default DustbinIcon;
@@ -14,7 +14,7 @@ interface ActionModalProps {
14
14
  children: React.ReactNode;
15
15
  onCloseHeader: () => void;
16
16
  onSubmit: () => void;
17
- isSubmitDisabled?: boolean;
17
+ isSubmitDisabled?: boolean;
18
18
  }
19
19
 
20
20
  function OrderActionModal(props: ActionModalProps) {
@@ -48,10 +48,12 @@ const MainContainer = styled.div`
48
48
  box-shadow: 0px 20px 24px -4px #10182814;
49
49
  display: flex;
50
50
  flex-direction: column;
51
- gap: 15px;
51
+ /* gap: 15px; */
52
52
  align-items: center;
53
53
  justify-content: space-between;
54
54
  overflow-x: hidden;
55
+ max-width: 75vw;
56
+ min-width: 30vw;
55
57
  `;
56
58
 
57
59
  export default OrderActionModal;
@@ -24,20 +24,8 @@ interface FilterState {
24
24
  }
25
25
  // let todayDate = new Date();
26
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 },
27
+ 'x-filters': [],
28
+ 'x-pagination': { page: 1, per_page: 5 },
41
29
  };
42
30
 
43
31
  const filterReducer = (state: FilterState, action: any): FilterState => {
@@ -110,6 +98,23 @@ const filterReducer = (state: FilterState, action: any): FilterState => {
110
98
  ],
111
99
  };
112
100
 
101
+ case 'CLEAR_LOC':
102
+ return {
103
+ ...state,
104
+ 'x-filters': state['x-filters'].filter(
105
+ f => f.field !== 'return_location'
106
+ ),
107
+ };
108
+ case 'CLEAR_FILTERS':
109
+ return {
110
+ ...state,
111
+ };
112
+
113
+ case 'CLEAR_ALL_FILTER':
114
+ return {
115
+ ...state,
116
+ };
117
+
113
118
  case 'SET_PAGE':
114
119
  return {
115
120
  ...state,
@@ -127,10 +132,6 @@ const filterReducer = (state: FilterState, action: any): FilterState => {
127
132
  per_page: action.payload,
128
133
  },
129
134
  };
130
- case 'CLEAR_FILTERS':
131
- return {
132
- ...state,
133
- };
134
135
  default:
135
136
  return state;
136
137
  }
@@ -0,0 +1,80 @@
1
+ import { atom, useAtom } from 'jotai';
2
+
3
+ const date = atom(new Date());
4
+ export const usedate = () => {
5
+ return useAtom(date);
6
+ };
7
+
8
+ interface Filter {
9
+ field: string;
10
+ op: string;
11
+ value: any;
12
+ }
13
+
14
+ interface Pagination {
15
+ page: number;
16
+ per_page: number;
17
+ }
18
+
19
+ interface FilterState {
20
+ 'x-filters': Filter[];
21
+ 'x-pagination': Pagination;
22
+ }
23
+ // let todayDate = new Date();
24
+ const initialState: FilterState = {
25
+ 'x-filters': [
26
+ // {
27
+ // field: 'action_date',
28
+ // op: '>=',
29
+ // value: `${format(new Date(todayDate), 'yyyy-MM-dd')}T00:00:00+00:00`,
30
+ // },
31
+ // {
32
+ // field: 'action_date',
33
+ // op: '<=',
34
+ // value: `${format(new Date(todayDate), 'yyyy-MM-dd')}T23:59:59+00:00`,
35
+ // },
36
+ // { field: 'status', op: 'count', value: '' },
37
+ ],
38
+ 'x-pagination': { page: 1, per_page: 50 },
39
+ };
40
+
41
+ const filterReducer = (state: FilterState, action: any): FilterState => {
42
+ switch (action.type) {
43
+ case 'SET_PAGE':
44
+ return {
45
+ ...state,
46
+ 'x-pagination': {
47
+ ...state['x-pagination'],
48
+ page: action.payload,
49
+ },
50
+ };
51
+
52
+ case 'SET_PERPAGE':
53
+ return {
54
+ ...state,
55
+ 'x-pagination': {
56
+ ...state['x-pagination'],
57
+ per_page: action.payload,
58
+ },
59
+ };
60
+ case 'CLEAR_FILTERS':
61
+ return {
62
+ ...state,
63
+ };
64
+
65
+ case 'CLEAR_ALL_FILTER':
66
+ return {
67
+ ...state,
68
+ };
69
+ default:
70
+ return state;
71
+ }
72
+ };
73
+
74
+ const filtersStateAtom = atom(initialState);
75
+
76
+ export const overviewfiltersReducerAtom = atom(
77
+ get => get(filtersStateAtom),
78
+ (get, set, action) =>
79
+ set(filtersStateAtom, filterReducer(get(filtersStateAtom), action))
80
+ );
@@ -1,45 +1,35 @@
1
1
  import React, { useEffect } from 'react';
2
2
  import {
3
- // UsePaginationData,
4
- // useItemsPerPage,
3
+ //useItemsPerPage,
5
4
  useLoading,
6
- // useSelectedAction,
7
- // useSelectedLocation,
5
+ //UsePaginationData,
8
6
  useTableName,
9
7
  } from './store/store';
10
8
  import Filters from './filters/Filters';
11
- // import TableComponent from '../../components/order-daily-overview/table-view/table/Table';
12
- // import TableComponent from '../../components/order-daily-overview/Cards/CardsTable'
13
- // import Pagination from './table-view/Pagination';
14
9
  import styled from 'styled-components';
15
- // import RouterHeader from './header/route-header/RouterHeader';
16
- // import Loader from './header/loader/Loader';
17
10
  import { useStickyStatus } from '../store';
18
11
  import HeaderFilter from './header-filters/HeaderFilter';
19
- // import ReturnTable from './table/ReturnTable';
20
12
  import { useApiHook } from '@bjsdistribution/dms-component-library';
21
- import { useClientData } from '../order-view/store';
13
+ import { useAtom, useClientData } from '../order-view/store';
22
14
  import { ClientData } from './common/interface';
23
- // import ReturnOrderTable from './return-order-table/return-orders-filters/ReturnOrderTable';
24
15
  import ReturnFilter from './return-order-table/return-orders-filters/ReturnFilter';
25
16
  import { Text } from './filters/FilterStyle';
26
17
  import ReturnTable from './table/ReturnTable';
27
- // import Loader from '../loader/Loader';
28
-
29
- // interface ApiResponse {
30
- // message: string;
31
- // code: number;
32
- // error: string | null;
33
- // error_traceback: string | null;
34
- // data: [];
35
- // }
18
+ // import Pagination from './table-view/Pagination';
19
+ import { overviewfiltersReducerAtom } from './header-filters/overViewFilter';
36
20
 
37
21
  function ReturnMainTable() {
22
+ const [state] = useAtom(overviewfiltersReducerAtom);
38
23
  // const [paginationObj] = UsePaginationData();
39
24
  // const [, setCurrentPage] = useState(1);
40
25
  // const [itemsPerPage, setItemsPerPage] = useItemsPerPage();
41
-
26
+ const { 'x-pagination': pagination } = state;
42
27
  // const { page, total } = paginationObj;
28
+ const [selectedClient] = useTableName();
29
+ // const [, setPaginationObject] = UsePaginationData();
30
+ const [isScrolled] = useStickyStatus();
31
+ const [, setLoading] = useLoading();
32
+ const [, setClientData] = useClientData();
43
33
 
44
34
  // const handlePageChange = (page: number) => {
45
35
  // setCurrentPage(page);
@@ -48,28 +38,32 @@ function ReturnMainTable() {
48
38
  // setItemsPerPage(itemsPerPage);
49
39
  // };
50
40
 
51
- ////
52
- const [selectedClient] = useTableName();
53
-
54
- const [isScrolled] = useStickyStatus();
55
-
56
- const [, setLoading] = useLoading();
57
- const [, setClientData] = useClientData();
58
-
59
- const { data: fetchedClientData, loading: staticDataLoading } = useApiHook<{
41
+ const {
42
+ data: fetchedClientData,
43
+ loading: staticDataLoading,
44
+ // paginationData,
45
+ } = useApiHook<{
60
46
  data: ClientData[];
61
47
  }>({
62
48
  endpoint: `/return_orders/get/client-returns/`,
63
49
  method: 'GET',
64
- pagination: { page: 1, per_page: 50 },
50
+ pagination: pagination,
65
51
  });
66
- // console.log('fetchedClientData', fetchedClientData?.data);
67
52
 
68
53
  useEffect(() => {
69
54
  setLoading(staticDataLoading);
70
55
  if (fetchedClientData && fetchedClientData.data) {
71
56
  const result = fetchedClientData?.data;
72
57
  setClientData(result);
58
+ // if (paginationData !== null) {
59
+ // const { count, ...rest } = JSON.parse(paginationData);
60
+ // setPaginationObject(rest);
61
+ // } else {
62
+ // notification.error({
63
+ // message: 'Error',
64
+ // description: 'Pagination data is null',
65
+ // });
66
+ // }
73
67
  }
74
68
  }, [staticDataLoading]);
75
69
 
@@ -1,33 +1,66 @@
1
- import React, { useEffect } from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import styled from 'styled-components';
3
3
  // import RouterHeader from '../header/route-header/RouterHeader';
4
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';
8
- import { useLoading } from '../store/store';
8
+ import {
9
+ useItemsPerReturnPage,
10
+ useLoading,
11
+ UsePaginationData,
12
+ UsePaginationReturnData,
13
+ } from '../store/store';
9
14
  import { ApiResponse } from '../common/interface';
10
15
  import { useApiHook } from '@bjsdistribution/dms-component-library';
11
- import { filtersReducerAtom } from './table-filters/ReturnFilterStore';
16
+ import { filtersReducerReturnAtom } from './table-filters/ReturnFilterStore';
17
+ import { notification } from 'antd';
18
+ import ReturnPagination from '../table-view/ReturnPagination';
12
19
 
13
20
  const ReturnAfterTable = () => {
14
21
  const [, setReturnOrderData] = useReturnAfterOrderData();
15
22
  const [, setLoading] = useLoading();
16
- const [state] = useAtom(filtersReducerAtom);
17
- const { 'x-filters': filters } = state;
23
+ const [state] = useAtom(filtersReducerReturnAtom);
24
+ const { 'x-filters': filters, 'x-pagination': pagination } = state;
25
+
26
+ const [paginationObj] = UsePaginationReturnData();
27
+ const [, setCurrentPage] = useState(1);
28
+ const [itemsPerPage, setItemsPerPage] = useItemsPerReturnPage();
29
+ const [, setPaginationObject] = UsePaginationData();
30
+
31
+ const { page, total } = paginationObj;
32
+
33
+ const handlePageChange = (page: number) => {
34
+ setCurrentPage(page);
35
+ };
36
+ const handleItemsPerPageChange = (itemsPerPage: number) => {
37
+ setItemsPerPage(itemsPerPage);
38
+ };
18
39
 
19
40
  const {
20
41
  data: fetchedReturnOrderData,
21
42
  loading: staticDataLoading,
43
+ paginationData,
22
44
  } = useApiHook<ApiResponse>({
23
45
  endpoint: '/return_orders/?skip_filters=0',
24
46
  method: 'GET',
25
47
  filters: filters,
48
+ pagination: pagination,
26
49
  });
50
+
27
51
  useEffect(() => {
28
52
  setLoading(staticDataLoading);
29
53
  if (fetchedReturnOrderData && fetchedReturnOrderData?.data) {
30
54
  setReturnOrderData(fetchedReturnOrderData?.data);
55
+ if (paginationData !== null) {
56
+ const { count, ...rest } = JSON.parse(paginationData);
57
+ setPaginationObject(rest);
58
+ } else {
59
+ notification.error({
60
+ message: 'Error',
61
+ description: 'Pagination data is null',
62
+ });
63
+ }
31
64
  }
32
65
  }, [fetchedReturnOrderData, staticDataLoading]);
33
66
  return (
@@ -39,6 +72,15 @@ const ReturnAfterTable = () => {
39
72
  <Container>
40
73
  <ReturnOrderFilter />
41
74
  <OrderTable />
75
+ {total > 0 && (
76
+ <ReturnPagination
77
+ currentPage={page}
78
+ totalItems={total}
79
+ itemsPerPage={itemsPerPage}
80
+ onPageChange={handlePageChange}
81
+ onItemsPerPageChange={handleItemsPerPageChange}
82
+ ></ReturnPagination>
83
+ )}
42
84
  </Container>
43
85
  </div>
44
86
  </DashBoardWrapper>
@@ -77,7 +77,7 @@ const OrderTable = ({ loadingskeleton }: any) => {
77
77
  // }
78
78
  // });
79
79
  // };
80
- console.log('', returnAfterOrder);
80
+ // console.log('', returnAfterOrder);
81
81
 
82
82
  const assigneOptions = [
83
83
  {
@@ -168,7 +168,9 @@ const OrderTable = ({ loadingskeleton }: any) => {
168
168
  />
169
169
  </td>
170
170
  <td>{formatDate(new Date(item?.created_at))}</td>
171
- <td>{displayValueOrNA(item?.return_locations)}</td>
171
+ <td>
172
+ {displayValueOrNA(item?.return_locations?.location_name)}
173
+ </td>
172
174
  <td>{displayValueOrNA(item?.pick_up_location)}</td>
173
175
 
174
176
  <td onClick={() => setOrderId(item.id)}>
@@ -200,7 +202,10 @@ const OrderTable = ({ loadingskeleton }: any) => {
200
202
  <td>{displayValueOrNA(item?.order_number)}</td>
201
203
 
202
204
  <td>{displayValueOrNA(item?.box_count)}</td>
203
- <td>{displayValueOrNA(item?.weight)} KG</td>
205
+ <td>
206
+ {displayValueOrNA(item?.weight)}{' '}
207
+ {item?.weight && item?.weight !== null ? 'KG' : ''}
208
+ </td>
204
209
  <td>{displayValueOrNA(item?.cube)}</td>
205
210
  <td>
206
211
  <AntSelect
@@ -209,8 +214,7 @@ const OrderTable = ({ loadingskeleton }: any) => {
209
214
  onChange={() => {}}
210
215
  // defaultValue={item?.assign || ''}
211
216
  // style={defaultSelectStyle}
212
- // disabled={false}
213
- // onSearch={handleSearch}
217
+ disabled // onSearch={handleSearch}
214
218
  showSearch
215
219
  popupClassName={defaultPopupClassName}
216
220
  selectWrapperClass={defaultSelectWrapperClass}
@@ -113,7 +113,7 @@ const filterReducer = (state: FilterState, action: any): FilterState => {
113
113
 
114
114
  const filtersStateAtom = atom(initialState);
115
115
 
116
- export const filtersReducerAtom = atom(
116
+ export const filtersReducerReturnAtom = atom(
117
117
  get => get(filtersStateAtom),
118
118
  (get, set, action) =>
119
119
  set(filtersStateAtom, filterReducer(get(filtersStateAtom), action))
@@ -13,7 +13,7 @@ import ClientIcon from '../../../../assets/icons/ClientIcon';
13
13
  import { DatePicker, Select } from 'antd';
14
14
  import { useAtom } from '../../../order-view/store';
15
15
  import styled from 'styled-components';
16
- import { filtersReducerAtom } from './ReturnFilterStore';
16
+ import { filtersReducerReturnAtom } from './ReturnFilterStore';
17
17
  import dayjs from 'dayjs';
18
18
  import { useCustomerData, useStatusOrderData } from '../../../store';
19
19
  import StatusIcon from '../../../../assets/icons/StatusIcon';
@@ -25,7 +25,7 @@ import {
25
25
  } from '../../table/table-data/styles';
26
26
 
27
27
  const ReturnOrderFilter = () => {
28
- const [, dispatch] = useAtom(filtersReducerAtom);
28
+ const [, dispatch] = useAtom(filtersReducerReturnAtom);
29
29
  const [customers] = useCustomerData();
30
30
  const [selectedDate, setSelectedDate] = useState<any | null>();
31
31
  const [statusOfOrder] = useStatusOrderData();
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import styled from 'styled-components';
3
3
  // import RouterHeader from '../header/route-header/RouterHeader';
4
4
  import HeaderFilter from '../header-filters/HeaderFilter';
@@ -6,8 +6,23 @@ import HeaderFilter from '../header-filters/HeaderFilter';
6
6
  import ReturnFilter from './return-orders-filters/ReturnFilter';
7
7
  import ReturnOrderTable from './return-orders-filters/ReturnOrderTable';
8
8
  import ModalManager from '../../order-view/modalsPopup/ModalManager';
9
+ import { useItemsPerPage, UsePaginationData } from '../store/store';
10
+ import Pagination from '../table-view/Pagination';
9
11
 
10
12
  const ReturnTable = () => {
13
+ const [paginationObj] = UsePaginationData();
14
+ const [, setCurrentPage] = useState(1);
15
+ const [itemsPerPage, setItemsPerPage] = useItemsPerPage();
16
+
17
+ const { page, total } = paginationObj;
18
+
19
+ const handlePageChange = (page: number) => {
20
+ setCurrentPage(page);
21
+ };
22
+ const handleItemsPerPageChange = (itemsPerPage: number) => {
23
+ setItemsPerPage(itemsPerPage);
24
+ };
25
+
11
26
  return (
12
27
  <div>
13
28
  <DashBoardWrapper>
@@ -17,6 +32,15 @@ const ReturnTable = () => {
17
32
  <Container>
18
33
  <ReturnFilter />
19
34
  <ReturnOrderTable />
35
+ {total > 0 && (
36
+ <Pagination
37
+ currentPage={page}
38
+ totalItems={total}
39
+ itemsPerPage={itemsPerPage}
40
+ onPageChange={handlePageChange}
41
+ onItemsPerPageChange={handleItemsPerPageChange}
42
+ ></Pagination>
43
+ )}
20
44
  </Container>
21
45
  </div>
22
46
  </DashBoardWrapper>
@@ -1,5 +1,5 @@
1
1
  import { Checkbox, useApiHook } from '@bjsdistribution/dms-component-library';
2
- import { Empty } from 'antd';
2
+ import { Empty, notification } from 'antd';
3
3
  import { useAtom } from 'jotai';
4
4
  import React, { useEffect, useRef } from 'react';
5
5
  import { Skeleton } from 'antd';
@@ -11,12 +11,16 @@ import {
11
11
  useSelectAll,
12
12
  useSelectedOrders,
13
13
  } from '../../../store';
14
- import { useReturnData } from '../../../order-view/store';
14
+ import { usefetchAgain, useReturnData } from '../../../order-view/store';
15
15
  import { EmptyDataContainer } from '../../table/table-data/styles';
16
16
  import { CustomDrop, StyledTable, StyledTableWrapper } from './returnstyles';
17
17
  import PrinterIcon from '../../../../assets/icons/PrinterIcon';
18
18
  import DownIcon from '../../../../assets/icons/DownIcon';
19
- import { useLoading, usePrintOptionTOggle } from '../../store/store';
19
+ import {
20
+ useLoading,
21
+ UsePaginationData,
22
+ usePrintOptionTOggle,
23
+ } from '../../store/store';
20
24
  import { ApiResponse } from '../../../types';
21
25
  import { filtersReducerAtom } from '../../header-filters/filterStore';
22
26
  import { displayValueOrNA } from '../../shared/utlis';
@@ -37,7 +41,9 @@ const ReturnOrderTable = () => {
37
41
  const [newpayload, setNewPayload] = useNewReturnPayload();
38
42
  const [, setGrouped] = useGroupedPayload();
39
43
  const [locationData] = useLocationData();
40
-
44
+ const [, setPaginationObject] = UsePaginationData();
45
+ const [callForFetch] = usefetchAgain();
46
+ // console.log(callForFetch, 'callForFetchcallForFetchcallForFetchcallForFetch');
41
47
  const OpenDropDown = (index: number) => {
42
48
  setPrintToggle(prevIndex => (prevIndex === index ? null : index));
43
49
  };
@@ -58,25 +64,38 @@ const ReturnOrderTable = () => {
58
64
  }
59
65
  };
60
66
 
61
- const { data: fetchedOrderData, loading: returnDataLoad } = useApiHook<
62
- ApiResponse
63
- >({
67
+ const {
68
+ data: fetchedOrderData,
69
+ loading: returnDataLoad,
70
+ paginationData,
71
+ setShouldPerformAction,
72
+ } = useApiHook<ApiResponse>({
64
73
  endpoint: '/return_order_products/',
65
74
  method: 'GET',
66
75
  filters: filters,
67
76
  pagination: pagination,
77
+ performAction: false,
68
78
  });
69
79
 
70
80
  useEffect(() => {
71
81
  setLoading(returnDataLoad);
72
82
  if (fetchedOrderData && fetchedOrderData?.data) {
73
83
  setReturnData(fetchedOrderData?.data);
84
+ if (paginationData !== null) {
85
+ const { count, ...rest } = JSON.parse(paginationData);
86
+ setPaginationObject(rest);
87
+ } else {
88
+ notification.error({
89
+ message: 'Error',
90
+ description: 'Pagination data is null',
91
+ });
92
+ }
74
93
  }
75
94
  }, [fetchedOrderData, returnDataLoad]);
76
95
 
77
96
  useEffect(() => {
78
97
  setLoading(returnDataLoad);
79
-
98
+ setShouldPerformAction(true);
80
99
  if (fetchedOrderData && fetchedOrderData?.data && locationData) {
81
100
  const updatedReturnData = fetchedOrderData.data.map(returnItem => {
82
101
  const matchingLocation = locationData.find(
@@ -92,7 +111,8 @@ const ReturnOrderTable = () => {
92
111
 
93
112
  setReturnData(updatedReturnData);
94
113
  }
95
- }, [fetchedOrderData, returnDataLoad, locationData]);
114
+ // setShouldPerformAction(false);
115
+ }, [fetchedOrderData, returnDataLoad, locationData, state, callForFetch]);
96
116
 
97
117
  const handleSelectAll = (e: any) => {
98
118
  setSelectAll(e.target.checked);
@@ -139,8 +159,6 @@ const ReturnOrderTable = () => {
139
159
  (loc: any) => loc.id === id
140
160
  );
141
161
 
142
- console.log(new_location, 'new_location');
143
-
144
162
  if (isSelected) {
145
163
  const updatedSelectedLocations = prevSelectedLocations.filter(
146
164
  (loc: any) => loc.id !== id
@@ -72,7 +72,7 @@ const atomPaginationData = atom<PaginationData>({
72
72
  total: 0,
73
73
  totalPages: 0,
74
74
  });
75
-
75
+ //client filter
76
76
  export const UsePaginationData = () => {
77
77
  return useAtom(atomPaginationData);
78
78
  };
@@ -82,6 +82,16 @@ export const useItemsPerPage = () => {
82
82
  return useAtom(atomItemsPerPage);
83
83
  };
84
84
 
85
+ //return after order
86
+ export const UsePaginationReturnData = () => {
87
+ return useAtom(atomPaginationData);
88
+ };
89
+
90
+ const atomItemsPerReturnPage = atom<number>(50);
91
+ export const useItemsPerReturnPage = () => {
92
+ return useAtom(atomItemsPerReturnPage);
93
+ };
94
+
85
95
  const countStatus = atom<any>([]);
86
96
  export const useCountData = () => {
87
97
  return useAtom(countStatus);
@@ -13,9 +13,10 @@ import PrevIcon from '../../../assets/icons/PrevIcon';
13
13
  import NextIcon from '../../../assets/icons/NextIcon';
14
14
  import { useAtom } from 'jotai';
15
15
  import { Select } from 'antd';
16
- import { filtersReducerAtom } from '../return-after-table/table-filters/ReturnFilterStore';
16
+ import { filtersReducerAtom } from '../header-filters/filterStore';
17
17
 
18
18
  const PAGE_SIZE_OPTIONS = [50, 100, 150];
19
+
19
20
  const MAX_PAGES_TO_SHOW = 5;
20
21
 
21
22
  const Pagination: React.FC<any> = ({