@bjsdistribution/dms-client-return 0.0.33 → 0.0.34

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 (34) hide show
  1. package/dist/components/order-daily-overview/store/store.d.ts +3 -0
  2. package/dist/components/order-view/notes/order-dropdown/NewReturnDropdown.d.ts +3 -0
  3. package/dist/components/store.d.ts +12 -2
  4. package/dist/components/types.d.ts +4 -0
  5. package/dist/dms-client-return.cjs.development.js +619 -345
  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 +623 -349
  10. package/dist/dms-client-return.esm.js.map +1 -1
  11. package/package.json +1 -1
  12. package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +118 -139
  13. package/src/components/order-daily-overview/header-filters/filterStore.ts +4 -4
  14. package/src/components/order-daily-overview/index.tsx +29 -25
  15. package/src/components/order-daily-overview/return-after-table/ReturnAfterTable.tsx +14 -10
  16. package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +88 -32
  17. package/src/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.ts +18 -2
  18. package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx +18 -7
  19. package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnFilter.tsx +2 -3
  20. package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +6 -4
  21. package/src/components/order-daily-overview/store/store.ts +15 -0
  22. package/src/components/order-daily-overview/table/ReturnTable.tsx +16 -11
  23. package/src/components/order-daily-overview/table/table-data/styles.ts +1 -1
  24. package/src/components/order-view/details-filters/left-side-filters/dropdowns/OptionsDropDown.tsx +3 -3
  25. package/src/components/order-view/details-filters/left-side-filters/dropdowns/PrintDropDownReturn.tsx +1 -1
  26. package/src/components/order-view/general-information/dropdowns/Print.tsx +1 -1
  27. package/src/components/order-view/modalsPopup/ModalManager.tsx +3 -9
  28. package/src/components/order-view/notes/order-dropdown/NewReturnDropdown.tsx +88 -13
  29. package/src/components/order-view/products-info/expanded-content/index.tsx +91 -16
  30. package/src/components/order-view/products-info/index.tsx +1 -1
  31. package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +47 -42
  32. package/src/components/store.ts +51 -1
  33. package/src/components/types.ts +5 -0
  34. package/src/index.tsx +25 -16
@@ -1,45 +1,120 @@
1
- import React from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import styled from 'styled-components';
3
- import { AntSelect } from '@bjsdistribution/dms-component-library';
3
+ import { useApiHook } from '@bjsdistribution/dms-component-library';
4
+ import { ApiResponse } from '../../types';
5
+ import { useOrderDetails, useProductDetails } from '../../store';
6
+ import { Select } from 'antd';
7
+ import { useSelectedProducts } from '../../../store';
8
+ import { atom, useAtom } from 'jotai';
9
+
10
+ export const payloadAtom = atom<any>(null);
4
11
 
5
12
  const NewReturnDropdown = () => {
6
13
  const defaultSelectStyle = { width: '100%' };
7
14
  const defaultPopupClassName = 'dropDownStyle';
8
- const defaultSelectWrapperClass = 'rounded';
15
+ const [returnOrderData, setReturnOrderData] = useState<any>([]);
16
+ const [selectedOrderId, setSelectedOrderId] = useState<string | null>(null);
17
+ const [selectedProducts] = useSelectedProducts();
18
+ const [orderData] = useOrderDetails();
19
+ const [, setPayload] = useAtom(payloadAtom);
20
+ const [productData] = useProductDetails();
21
+ const [idProduct, setId] = useState<any>();
22
+
23
+ const id = orderData?.customer_id;
24
+
25
+ useEffect(() => {
26
+ const allProductIds =
27
+ productData?.map((product: any) => product.return_location) || [];
28
+ setId(allProductIds);
29
+ }, [productData]);
30
+
31
+ const filters = [
32
+ { field: 'customer_id', op: '=', value: id },
33
+ { field: 'is_deleted', op: '=', value: 0 },
34
+ { field: 'status', op: '!=', value: 'SD' },
35
+ ];
36
+
37
+ if (idProduct?.length > 0 && idProduct[0]) {
38
+ filters.push({
39
+ field: 'return_order_products.return_location',
40
+ op: '=',
41
+ value: idProduct[0],
42
+ });
43
+ }
44
+
45
+ const { data: fetchedReturnOrderData, setShouldPerformAction } = useApiHook<
46
+ ApiResponse
47
+ >({
48
+ endpoint: '/return_orders/?skip_filters=0',
49
+ method: 'GET',
50
+ filters,
51
+ //@ts-ignore
52
+ pagination: { is_pagination: false },
53
+ performAction: false,
54
+ });
55
+
56
+ useEffect(() => {
57
+ if (id && idProduct?.length > 0 && idProduct[0]) {
58
+ setShouldPerformAction(true);
59
+ }
60
+ }, [id, idProduct, setShouldPerformAction]);
61
+
62
+ useEffect(() => {
63
+ if (fetchedReturnOrderData && fetchedReturnOrderData?.data && id !== null) {
64
+ setReturnOrderData(fetchedReturnOrderData?.data);
65
+ }
66
+ }, [fetchedReturnOrderData, id]);
67
+
68
+ useEffect(() => {
69
+ if (selectedOrderId && selectedProducts?.length > 0) {
70
+ const newPayload = {
71
+ new_return_order: selectedOrderId,
72
+ products: selectedProducts,
73
+ };
74
+ setPayload(newPayload);
75
+ }
76
+ }, [selectedOrderId, selectedProducts, setPayload]);
77
+
78
+ const handleDropdownChange = (value: string) => {
79
+ setSelectedOrderId(value);
80
+ };
81
+
82
+ const dropdownOptions = returnOrderData?.map((order: any) => ({
83
+ label: `${order.order_recipient.recipient_name} - ${order.order_recipient.postcode}`,
84
+ value: order.id,
85
+ }));
9
86
 
10
87
  return (
11
88
  <Container>
12
89
  <Text>New Return Order:</Text>
13
- <AntSelect
14
- options={[]}
90
+ <Select
91
+ options={dropdownOptions}
15
92
  placeholder="Select"
16
- onChange={() => {}}
17
- defaultValue={'Current Return Order' || ''}
93
+ onChange={handleDropdownChange}
18
94
  style={defaultSelectStyle}
19
95
  disabled={false}
20
- // onSearch={handleSearch}
21
96
  showSearch
97
+ dropdownStyle={{ width: 'max-content' }}
22
98
  popupClassName={defaultPopupClassName}
23
- selectWrapperClass={defaultSelectWrapperClass}
24
99
  />
25
100
  </Container>
26
101
  );
27
102
  };
103
+
28
104
  const Container = styled.div`
29
105
  display: flex;
30
106
  align-items: center;
31
107
  gap: 10px;
32
108
  align-self: stretch;
109
+ white-space: nowrap;
33
110
  `;
111
+
34
112
  const Text = styled.div`
35
113
  color: #000;
36
-
37
- /* body/captions */
38
114
  font-family: 'Lato';
39
115
  font-size: 13px;
40
- font-style: normal;
41
116
  font-weight: 400;
42
- line-height: 16px; /* 123.077% */
117
+ line-height: 16px;
43
118
  `;
44
119
 
45
120
  export default NewReturnDropdown;
@@ -1,37 +1,111 @@
1
- import React from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import styled from 'styled-components';
3
3
  import ProductTable from '../../return-client-products/ProductTable';
4
- import NewReturnDropdown from '../../notes/order-dropdown/NewReturnDropdown';
5
- import { Button } from '@bjsdistribution/dms-component-library';
6
- // import { notification } from 'antd';
4
+ import NewReturnDropdown, {
5
+ payloadAtom,
6
+ } from '../../notes/order-dropdown/NewReturnDropdown';
7
+ import { Button, useApiHook } from '@bjsdistribution/dms-component-library';
8
+ import { useAtom } from 'jotai';
9
+ import { ApiResponse } from '../../types';
10
+ import { usePostLoading, useSelectedProducts } from '../../../store';
11
+ import { useOrderId } from '../../store';
12
+ import { useNavigate } from 'react-router-dom';
13
+ import { notification } from 'antd';
7
14
 
8
15
  function ExpandedContent() {
9
- // const SaveNote = () => {
10
- // // alert('saved');
11
- // notification.success({
12
- // message: 'Success',
13
- // description: ' Saved successfully.',
14
- // });
15
- // };
16
+ const [payload] = useAtom(payloadAtom);
17
+ const [, setPostLoading] = usePostLoading();
18
+ const [orderId] = useOrderId();
19
+ const [isButtonDisabled, setIsButtonDisabled] = useState(true);
20
+ const navigate = useNavigate();
21
+ const [, setSelectedProducts] = useSelectedProducts();
22
+
23
+ const {
24
+ data: response,
25
+ setShouldPerformAction,
26
+ loading: confirmLoading,
27
+ } = useApiHook<{
28
+ data: ApiResponse[];
29
+ }>({
30
+ endpoint: `return_order_products/move/${orderId}`,
31
+ method: 'POST',
32
+ body: payload,
33
+ performAction: false,
34
+ });
35
+
36
+ useEffect(() => {
37
+ setPostLoading(confirmLoading);
38
+ }, [confirmLoading, setPostLoading]);
39
+
40
+ useEffect(() => {
41
+ if (payload?.new_return_order && payload?.products?.length > 0) {
42
+ setIsButtonDisabled(false);
43
+ } else {
44
+ setIsButtonDisabled(true);
45
+ }
46
+ }, [payload]);
47
+
48
+ const handleConfirmReturn = () => {
49
+ if (!isButtonDisabled) {
50
+ setShouldPerformAction(true);
51
+ setPostLoading(confirmLoading);
52
+ } else {
53
+ console.error('Payload is incomplete:', payload);
54
+ }
55
+ };
56
+
57
+ const newId = Array.isArray(response?.data)
58
+ ? //@ts-ignore
59
+ response?.data?.[0]?.id
60
+ : //@ts-ignore
61
+ response?.data?.id;
62
+
63
+ useEffect(() => {
64
+ //@ts-ignore
65
+ if (response?.code === 200) {
66
+ notification.success({
67
+ message: 'Success',
68
+ //@ts-ignore
69
+
70
+ description: response?.message || 'Products moved successfully',
71
+ });
72
+ setSelectedProducts([]);
73
+ } else if (response) {
74
+ notification.error({
75
+ message: 'Error',
76
+ //@ts-ignore
77
+
78
+ description: response?.message || 'Error while moving products',
79
+ });
80
+ }
81
+
82
+ //@ts-ignore
83
+ if (response?.code === 200 && newId) {
84
+ navigate(`details/${newId}`);
85
+ setSelectedProducts([]);
86
+ }
87
+ }, [response, newId, navigate, setSelectedProducts]);
88
+
16
89
  return (
17
90
  <Container>
18
91
  <ProductTable />
19
- <MidConatiner>
92
+ <MidContainer>
20
93
  <SaveNoteContainer>
21
94
  <Button
22
95
  style={{ borderRadius: '20px' }}
23
- onClick={() => {}}
24
- disabled={true}
96
+ onClick={handleConfirmReturn}
97
+ disabled={isButtonDisabled}
25
98
  >
26
99
  Move Products
27
100
  </Button>
28
101
  <NewReturnDropdown />
29
102
  </SaveNoteContainer>
30
- </MidConatiner>
103
+ </MidContainer>
31
104
  </Container>
32
105
  );
33
106
  }
34
- const MidConatiner = styled.div`
107
+
108
+ const MidContainer = styled.div`
35
109
  display: flex;
36
110
  justify-content: space-between;
37
111
  padding: 10px 15px;
@@ -47,6 +121,7 @@ const SaveNoteContainer = styled.div`
47
121
  display: inline-flex;
48
122
  gap: 10px;
49
123
  `;
124
+
50
125
  const Container = styled.div``;
51
126
 
52
127
  export default ExpandedContent;
@@ -25,7 +25,7 @@ function ProductsInfo() {
25
25
  const { data: fetchedData, loading, setShouldPerformAction } = useApiHook<{
26
26
  data: ApiResponse[];
27
27
  }>({
28
- endpoint: `/order/order_products/${customerData.id}`,
28
+ endpoint: `return_order_products/${customerData.id}`,
29
29
  method: 'GET',
30
30
  performAction: false,
31
31
  });
@@ -1,30 +1,31 @@
1
- import React, { useEffect, useState, useCallback } from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import {
3
3
  StyledTable,
4
4
  StyledTableWrapper,
5
5
  } from '../../../order-daily-overview/return-order-table/return-orders-filters/returnstyles';
6
6
  import { Checkbox, useApiHook } from '@bjsdistribution/dms-component-library';
7
7
  import ActionIcon from '../../../../assets/icons/ActionIcon';
8
- import { useSelectedOrders } from '../../../store';
8
+ // import { useSelectedOrders } from '../../../store';
9
9
  import { useOrderId, useOrderStaticData, useProductDetails } from '../../store';
10
10
  import { ApiResponse } from '../../types';
11
11
  import Loader from '../../../order-daily-overview/header/loader/Loader';
12
12
  import { notification } from 'antd';
13
+ import { useSelectedProducts } from '../../../store';
13
14
 
14
15
  const ReturnProductTable = () => {
15
- const [selectedInvoices] = useSelectedOrders();
16
+ const [selectedProducts, setSelectedProducts] = useSelectedProducts();
16
17
  const [selectAll, setSelectAll] = useState(false);
17
18
  const [productData, setProductData] = useProductDetails();
18
19
  const [selectedRowId, setSelectedRowId] = useState<number | null>(null);
19
20
  const [orderId] = useOrderId();
20
21
 
21
- const handleActionClick = useCallback((id: number) => {
22
+ const handleActionClick = (id: number) => {
22
23
  setSelectedRowId(id);
23
- }, []);
24
+ };
24
25
 
25
26
  const {
26
27
  data: isresponse,
27
- setShouldPerformAction: setaction,
28
+ setShouldPerformAction: setAction,
28
29
  loading,
29
30
  } = useApiHook<{
30
31
  data: ApiResponse[];
@@ -39,33 +40,43 @@ const ReturnProductTable = () => {
39
40
  if (isresponse && isresponse.data) {
40
41
  notification.success({
41
42
  message: 'Success',
42
- description:
43
- //@ts-ignore
44
- isresponse?.message ||
45
- 'An error has occurred. Please try again later.',
43
+ description: 'An error has occurred. Please try again later.',
46
44
  });
47
45
  handleRemoveRow();
48
46
  setSelectedRowId(null);
49
47
  }
50
48
  }, [isresponse]);
51
49
 
52
- const handleRemoveRow = useCallback(() => {
50
+ const handleRemoveRow = () => {
53
51
  if (selectedRowId !== null) {
54
52
  setProductData((prevData: any) =>
55
53
  prevData.filter((item: any) => item.id !== selectedRowId)
56
54
  );
57
55
  }
58
- }, [selectedRowId, setProductData]);
56
+ };
59
57
 
60
- const onDeleteProducts = useCallback(() => {
61
- setaction(true);
62
- }, [setaction, selectedRowId]);
58
+ const onDeleteProducts = () => {
59
+ setAction(true);
60
+ };
63
61
 
64
- const handleSelectAll = useCallback(() => {
65
- setSelectAll(prevSelectAll => !prevSelectAll);
66
- }, []);
62
+ const handleSelectAll = () => {
63
+ if (selectAll) {
64
+ setSelectedProducts([]);
65
+ } else {
66
+ const allProductIds = productData.map((product: any) => product.id);
67
+ setSelectedProducts(allProductIds);
68
+ }
69
+ setSelectAll(!selectAll);
70
+ };
71
+
72
+ const handleSelectProduct = (id: number) => {
73
+ setSelectedProducts((prevSelected: any) =>
74
+ prevSelected.includes(id)
75
+ ? prevSelected.filter((selectedId: any) => selectedId !== id)
76
+ : [...prevSelected, id]
77
+ );
78
+ };
67
79
 
68
- // const returnreason =
69
80
  const [orderStaticData] = useOrderStaticData();
70
81
 
71
82
  const returnReasonsOptions = orderStaticData?.return_reasons?.map(
@@ -79,23 +90,18 @@ const ReturnProductTable = () => {
79
90
  const matchedReason = returnReasonsOptions?.find(
80
91
  (option: any) => option.value === returnReasonId
81
92
  );
82
- return matchedReason ? matchedReason.label : 'N/A'; // Return label or 'N/A' if no match found
93
+ return matchedReason ? matchedReason.label : 'N/A';
83
94
  };
84
95
 
85
96
  return (
86
97
  <div>
87
98
  {loading && <Loader title="Deleting" />}
88
- <StyledTableWrapper id="tableScrolling">
99
+ <StyledTableWrapper id="tableScrolling" className="orderProductTable">
89
100
  <StyledTable>
90
101
  <thead>
91
102
  <tr>
92
- <th className="emailInvoiceCheckbox">
93
- <Checkbox
94
- checked={selectAll}
95
- onChange={handleSelectAll}
96
- disabled={true}
97
- style={{ cursor: 'not-allowed' }}
98
- />
103
+ <th className="emailproductsCheckbox">
104
+ <Checkbox checked={selectAll} onChange={handleSelectAll} />
99
105
  </th>
100
106
  <th>Location</th>
101
107
  <th>Sender</th>
@@ -107,29 +113,28 @@ const ReturnProductTable = () => {
107
113
  </tr>
108
114
  </thead>
109
115
  <tbody>
110
- {productData && productData.length > 0 ? (
111
- productData.map((invoice: any) => (
112
- <tr key={invoice.id}>
116
+ {productData && productData?.length > 0 ? (
117
+ productData?.map((product: any) => (
118
+ <tr key={product.id}>
113
119
  <td>
114
120
  <Checkbox
115
- checked={selectedInvoices.some(
116
- selectedInvoice => selectedInvoice.id === invoice.id
117
- )}
118
- style={{ cursor: 'not-allowed' }}
121
+ checked={selectedProducts?.includes(product?.id)}
122
+ onChange={() => handleSelectProduct(product?.id)}
119
123
  />
120
124
  </td>
121
- <td>{'N/A'}</td>
122
- <td>{'N/A'}</td>
123
- <td>{invoice.code}</td>
124
- <td>{invoice.description}</td>
125
+ <td>{product?.orders_products_stock?.location || 'N/A'}</td>
125
126
  <td>
126
- {getReturnReasonLabel(invoice?.return_reason_id)}
127
- </td>{' '}
127
+ {product?.order_data?.order_recipient?.recipient_name}{' '}
128
+ {product?.order_data?.order_recipient?.postcode}
129
+ </td>
130
+ <td>{product?.code}</td>
131
+ <td>{product?.description}</td>
132
+ <td>{getReturnReasonLabel(product?.return_reason_id)}</td>
128
133
  <td>1 of 1</td>
129
134
  <td>
130
135
  <div
131
136
  onClick={() => {
132
- handleActionClick(invoice.id);
137
+ handleActionClick(product?.id);
133
138
  onDeleteProducts();
134
139
  }}
135
140
  style={{ cursor: 'pointer' }}
@@ -1,5 +1,9 @@
1
1
  import { atom, useAtom } from 'jotai';
2
- import { CreateReturnPayload, SelectDateType } from './types';
2
+ import {
3
+ AssignUpdatePayload,
4
+ CreateReturnPayload,
5
+ SelectDateType,
6
+ } from './types';
3
7
 
4
8
  export const filtersInitialValue = {
5
9
  date: {
@@ -16,6 +20,11 @@ export const CreateReturnInitial = {
16
20
  return_action: [],
17
21
  };
18
22
 
23
+ export const AssignUpdateInitial = {
24
+ return_order_id: 0,
25
+ bjs_delivery: false,
26
+ };
27
+
19
28
  export const triggerApiCallAtom = atom(false);
20
29
 
21
30
  const staticData = atom<any>({});
@@ -53,6 +62,18 @@ const final = atom<any[]>([]);
53
62
 
54
63
  const clearState = atom<boolean>(false);
55
64
 
65
+ const assignData = atom<any[]>([]);
66
+
67
+ const assignPayload = atom<AssignUpdatePayload>(AssignUpdateInitial);
68
+
69
+ const callAPIAgain = atom<boolean>(true);
70
+
71
+ const actionTypeOptions = atom<any[]>([]);
72
+
73
+ const locationOptions = atom<any[]>([]);
74
+
75
+ const selectedProductsMove = atom<any>([]);
76
+
56
77
  function useReminderData() {
57
78
  return useAtom(reminderTableData);
58
79
  }
@@ -141,6 +162,29 @@ function useClearState() {
141
162
  return useAtom(clearState);
142
163
  }
143
164
 
165
+ function useAssignData() {
166
+ return useAtom(assignData);
167
+ }
168
+
169
+ function useAssignPayload() {
170
+ return useAtom(assignPayload);
171
+ }
172
+
173
+ function useCallApiAgain() {
174
+ return useAtom(callAPIAgain);
175
+ }
176
+
177
+ function useActionTypeOptions() {
178
+ return useAtom(actionTypeOptions);
179
+ }
180
+
181
+ function useLocationOptions() {
182
+ return useAtom(locationOptions);
183
+ }
184
+ function useSelectedProducts() {
185
+ return useAtom(selectedProductsMove);
186
+ }
187
+
144
188
  export {
145
189
  useAtom,
146
190
  useFilter,
@@ -164,4 +208,10 @@ export {
164
208
  usePostLoading,
165
209
  useFinalPayload,
166
210
  useClearState,
211
+ useAssignData,
212
+ useAssignPayload,
213
+ useCallApiAgain,
214
+ useActionTypeOptions,
215
+ useLocationOptions,
216
+ useSelectedProducts,
167
217
  };
@@ -227,3 +227,8 @@ export type CreateReturnPayload = {
227
227
  products: number[];
228
228
  return_action: string[];
229
229
  };
230
+
231
+ export type AssignUpdatePayload = {
232
+ return_order_id: number | null;
233
+ bjs_delivery: boolean;
234
+ };
package/src/index.tsx CHANGED
@@ -3,35 +3,40 @@ import { Route, Routes, useNavigate } from 'react-router-dom';
3
3
  import OrderView from './components/order-view';
4
4
  import ReturnTable from './components/order-daily-overview/return-order-table/ReturnTable';
5
5
  import ReturnAfterTable from './components/order-daily-overview/return-after-table/ReturnAfterTable';
6
- import { useTableName } from './components/order-daily-overview/store/store';
6
+ import {
7
+ useIdForTableName,
8
+ useTableName,
9
+ } from './components/order-daily-overview/store/store';
7
10
  import ReturnMainTable from './components/order-daily-overview';
8
11
  import { notification } from 'antd';
9
12
  import RouterHeader from './components/order-daily-overview/header/route-header/RouterHeader';
10
13
  import {
11
14
  useActionType,
12
- // useAtom,
15
+ useActionTypeOptions,
16
+ useAssignData,
13
17
  useCustomerData,
14
18
  useLocationData,
15
19
  useStatusOrderData,
16
20
  } from './components/store';
17
21
  import { ApiResponse } from './components/types';
18
22
  import { useApiHook } from '@bjsdistribution/dms-component-library';
19
- // import { filtersReducerAtom } from './components/order-daily-overview/header-filters/filterStore';
23
+ import { useLocationOptions } from './components/order-view/store';
20
24
 
21
25
  function ReturnClient() {
22
26
  notification.config({
23
27
  top: 80,
24
28
  });
25
29
  const LoadingMessage = () => <div>Loading...</div>;
26
- const [selectedClient] = useTableName();
30
+ const [selectedClientId] = useIdForTableName();
27
31
  const navigate = useNavigate();
28
- let selectedClientString = selectedClient?.replace(/\s+/g, '-');
29
- selectedClientString = selectedClientString?.toLowerCase();
30
32
  const [, setCustomers] = useCustomerData();
31
33
  const [, setActionType] = useActionType();
32
34
  const [, setLocationData] = useLocationData();
33
35
  const [, setStatusOfOrders] = useStatusOrderData();
34
- // const [dispatchvalue] = useAtom(filtersReducerAtom);
36
+ const [, setAssignData] = useAssignData();
37
+ const [, setActionTypeOptions] = useActionTypeOptions();
38
+ const [, setLocationOptions] = useLocationOptions();
39
+ const [, setTableName] = useTableName();
35
40
 
36
41
  const splitPath = (str: any) => {
37
42
  const parts = str?.split('/')?.filter((part: any) => part !== ''); // Filter out empty parts
@@ -42,26 +47,27 @@ function ReturnClient() {
42
47
  if (paths[paths.length - 1] === 'returnclient') {
43
48
  localStorage.removeItem('clientName');
44
49
  localStorage.removeItem('clientId');
45
- localStorage.removeItem('uuid');
46
- // dispatch({ type: 'CLEAR_CLIENT' });
50
+ localStorage.removeItem('account_number');
51
+ setActionTypeOptions([]);
52
+ setLocationOptions([]);
53
+ setTableName('');
47
54
  }
48
55
  }, [location.pathname]);
49
56
 
50
57
  useEffect(() => {
51
- if (selectedClient) {
52
- const selectedClientString = selectedClient.replace(/\s+/g, '-');
53
- navigate(`filter/${selectedClientString}`);
58
+ if (selectedClientId) {
59
+ navigate(`filter/${selectedClientId}`);
54
60
  }
55
- }, [selectedClient]);
61
+ }, [selectedClientId]);
56
62
 
57
63
  //API for client data
58
64
  const { data: fetchedCustomerData, loading: loading } = useApiHook<
59
65
  ApiResponse
60
66
  >({
61
- endpoint: `/customers/`,
67
+ endpoint: `/return_orders/customers/`,
62
68
  method: 'GET',
63
69
  //@ts-ignore
64
- pagination: { is_pagination: false },
70
+ pagination: { page: 1, per_page: 50 },
65
71
  });
66
72
 
67
73
  //API for action type
@@ -99,6 +105,9 @@ function ReturnClient() {
99
105
  setStatusOfOrders(
100
106
  fetchedStaticData?.data?.flatMap((i: any) => i?.order_stock_alias)
101
107
  );
108
+ setAssignData(
109
+ fetchedStaticData?.data?.flatMap((i: any) => i?.assign_client)
110
+ );
102
111
  }
103
112
  }, [actionLoading]);
104
113
 
@@ -121,7 +130,7 @@ function ReturnClient() {
121
130
 
122
131
  <Route path="order-return" element={<ReturnAfterTable />} />
123
132
  <Route path="order-return/:id" element={<OrderView />} />
124
- <Route path="filter/:clientName" element={<ReturnTable />} />
133
+ <Route path="filter/:clientId" element={<ReturnTable />} />
125
134
 
126
135
  {/* <Route
127
136
  path=""