@bjsdistribution/dms-client-return 0.0.32 → 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 (41) 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 +973 -2192
  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 +981 -2200
  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/return-order-table/return-orders-filters/returnstyles.ts +4 -3
  22. package/src/components/order-daily-overview/store/store.ts +15 -0
  23. package/src/components/order-daily-overview/table/ReturnTable.tsx +16 -11
  24. package/src/components/order-daily-overview/table/table-data/styles.ts +2 -2
  25. package/src/components/order-view/details-filters/left-side-filters/dropdowns/MenuDropDown.tsx +5 -9
  26. package/src/components/order-view/details-filters/left-side-filters/dropdowns/OptionsDropDown.tsx +3 -3
  27. package/src/components/order-view/details-filters/left-side-filters/dropdowns/PrintDropDownReturn.tsx +1 -1
  28. package/src/components/order-view/general-information/Status.tsx +1 -1
  29. package/src/components/order-view/general-information/dropdowns/Print.tsx +1 -1
  30. package/src/components/order-view/modalsPopup/ModalManager.tsx +4 -151
  31. package/src/components/order-view/notes/order-dropdown/NewReturnDropdown.tsx +88 -13
  32. package/src/components/order-view/order-actions/actions/split-order/SplitOrderTable.tsx +2 -2
  33. package/src/components/order-view/order-actions/index.tsx +0 -9
  34. package/src/components/order-view/order-details/expanded-content/footer/index.tsx +1 -0
  35. package/src/components/order-view/products-info/expanded-content/index.tsx +91 -16
  36. package/src/components/order-view/products-info/index.tsx +1 -1
  37. package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +47 -42
  38. package/src/components/order-view/store.ts +6 -1
  39. package/src/components/store.ts +51 -1
  40. package/src/components/types.ts +5 -0
  41. package/src/index.tsx +25 -16
@@ -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' }}
@@ -475,7 +475,12 @@ const popupReducer = (state: any, action: any) => {
475
475
  } else if (action.type === 'addProduct') {
476
476
  state = 'addProduct';
477
477
  return { state };
478
- } else if (action.type === 'deleteProduct') {
478
+ }
479
+ else if (action.type === 'split-order') {
480
+ state = 'split-order';
481
+ return { state };
482
+ }
483
+ else if (action.type === 'deleteProduct') {
479
484
  state = 'deleteProduct';
480
485
  return { state };
481
486
  } else if (action.type === 'defectsModal') {
@@ -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=""