@bjsdistribution/dms-client-return 0.0.20 → 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 +464 -380
  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 +465 -381
  8. package/dist/dms-client-return.esm.js.map +1 -1
  9. package/package.json +1 -1
  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 +17 -11
  26. package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +21 -2
  27. package/src/index.tsx +74 -1
@@ -25,7 +25,7 @@ import { ApiResponse } from '../types';
25
25
  import CreateReturnModal from './CreateReturnModal';
26
26
  import {
27
27
  useFinalPayload,
28
- // useGroupedPayload,
28
+ useGroupedPayload,
29
29
  useNewReturnPayload,
30
30
  usePostLoading,
31
31
  useSelectAll,
@@ -33,6 +33,7 @@ import {
33
33
  useSelectedOrders,
34
34
  } from '../../store';
35
35
  import { notification } from 'antd';
36
+ import { useNavigate } from 'react-router-dom';
36
37
 
37
38
  const ModalManager = () => {
38
39
  const [popupName, dispatch] = useAtom(countReducerAtom);
@@ -50,9 +51,10 @@ const ModalManager = () => {
50
51
  const [, setSelectedReturnOrder] = useSelectedOrders();
51
52
  const [forDisabledCheck, setCheck] = useSelectedConfirmLoc();
52
53
  const [, setNewPayload] = useNewReturnPayload();
53
- // const [, setGrouped] = useGroupedPayload();
54
+ const [, setGrouped] = useGroupedPayload();
54
55
  const [, setSelectAll] = useSelectAll();
55
56
  const [, setCallForFetch] = usefetchAgain();
57
+ const navigate = useNavigate();
56
58
 
57
59
  console.log(orderProduct, 'abcabcabcabcabcabcabcabcabcabcabc');
58
60
 
@@ -150,8 +152,7 @@ const ModalManager = () => {
150
152
  }, [confirmLoading]);
151
153
 
152
154
  const handleConfirmReturn = () => {
153
- // setStateCheck(!forCheck);
154
- if (newGrouped.length > 0) {
155
+ if (newGrouped?.length > 0) {
155
156
  setShouldPerformAction(true);
156
157
  setCallForFetch(true);
157
158
  }
@@ -191,15 +192,16 @@ const ModalManager = () => {
191
192
  // @ts-ignore
192
193
  if (apiError && apiError?.code !== 200) {
193
194
  dispatch({ type: 'close' });
194
- // setSelectedReturnOrder([]);
195
- // setCheck([]);
196
- // setNewPayload([]);
197
- // setShouldPerformAction(false);
198
- // setSelectAll(false);
195
+ setSelectedReturnOrder([]);
196
+ setCheck([]);
197
+ setNewPayload([]);
198
+ setGrouped([]);
199
+ setSelectAll(false);
200
+ setShouldPerformAction(false);
199
201
  notification.error({
200
202
  message: 'Failure',
201
203
  // @ts-ignore
202
- description: `Failed`,
204
+ description: `${apiError?.message}`,
203
205
  });
204
206
  setError(null);
205
207
  // @ts-ignore
@@ -216,8 +218,12 @@ const ModalManager = () => {
216
218
  setShouldPerformAction(false);
217
219
  setSelectAll(false);
218
220
  setError(null);
221
+ navigate('/order-return');
219
222
  }
220
- }, [response]);
223
+ }, [response, apiError]);
224
+
225
+ console.log(apiError, 'apiError apiError');
226
+ console.log(response, 'response response ');
221
227
 
222
228
  return (
223
229
  <>
@@ -6,7 +6,7 @@ import {
6
6
  import { Checkbox, useApiHook } from '@bjsdistribution/dms-component-library';
7
7
  import ActionIcon from '../../../../assets/icons/ActionIcon';
8
8
  import { useSelectedOrders } from '../../../store';
9
- import { useOrderId, useProductDetails } from '../../store';
9
+ import { useOrderId, useOrderStaticData, useProductDetails } from '../../store';
10
10
  import { ApiResponse } from '../../types';
11
11
 
12
12
  const ReturnProductTable = () => {
@@ -52,6 +52,23 @@ const ReturnProductTable = () => {
52
52
  setSelectAll(prevSelectAll => !prevSelectAll);
53
53
  }, []);
54
54
 
55
+ // const returnreason =
56
+ const [orderStaticData] = useOrderStaticData();
57
+
58
+ const returnReasonsOptions = orderStaticData?.return_reasons?.map(
59
+ (option: any) => ({
60
+ label: option.reason,
61
+ value: option.id,
62
+ })
63
+ );
64
+
65
+ const getReturnReasonLabel = (returnReasonId: number) => {
66
+ const matchedReason = returnReasonsOptions?.find(
67
+ (option: any) => option.value === returnReasonId
68
+ );
69
+ return matchedReason ? matchedReason.label : 'N/A'; // Return label or 'N/A' if no match found
70
+ };
71
+
55
72
  return (
56
73
  <div>
57
74
  <StyledTableWrapper id="tableScrolling">
@@ -85,7 +102,9 @@ const ReturnProductTable = () => {
85
102
  <td>{'N/A'}</td>
86
103
  <td>{invoice.code}</td>
87
104
  <td>{invoice.description}</td>
88
- <td>{'N/A'}</td>
105
+ <td>
106
+ {getReturnReasonLabel(invoice?.return_reason_id)}
107
+ </td>{' '}
89
108
  <td>1 of 1</td>
90
109
  <td>
91
110
  <div
package/src/index.tsx CHANGED
@@ -10,6 +10,17 @@ import { useTableName } from './components/order-daily-overview/store/store';
10
10
  import ReturnMainTable from './components/order-daily-overview';
11
11
  import { notification } from 'antd';
12
12
  import RouterHeader from './components/order-daily-overview/header/route-header/RouterHeader';
13
+ import {
14
+ useActionType,
15
+ // useAtom,
16
+ // useAtom,
17
+ useCustomerData,
18
+ useLocationData,
19
+ useStatusOrderData,
20
+ } from './components/store';
21
+ import { ApiResponse } from './components/types';
22
+ import { useApiHook } from '@bjsdistribution/dms-component-library';
23
+ // import { filtersReducerAtom } from './components/order-daily-overview/header-filters/filterStore';
13
24
 
14
25
  function ReturnClient() {
15
26
  notification.config({
@@ -20,14 +31,22 @@ function ReturnClient() {
20
31
  const navigate = useNavigate();
21
32
  let selectedClientString = selectedClient?.replace(/\s+/g, '-');
22
33
  selectedClientString = selectedClientString?.toLowerCase();
34
+ const [, setCustomers] = useCustomerData();
35
+ const [, setActionType] = useActionType();
36
+ const [, setLocationData] = useLocationData();
37
+ const [, setStatusOfOrders] = useStatusOrderData();
38
+ // const [, dispatch] = useAtom(filtersReducerAtom);
23
39
 
24
40
  console.log(selectedClientString, 'selectedClient');
25
41
  console.log(`../filter/:${selectedClientString}`);
26
42
 
27
43
  useEffect(() => {
28
- if (!location.pathname.includes('/filter')) {
44
+ if (location.pathname.includes('/returnClient')) {
29
45
  localStorage.removeItem('clientName');
30
46
  localStorage.removeItem('clientId');
47
+ localStorage.removeItem('uuid');
48
+ localStorage.removeItem('customer_id');
49
+ // dispatch({ type: 'CLEAR_CLIENT', payload: [] });
31
50
  }
32
51
  }, [location.pathname]);
33
52
 
@@ -38,6 +57,60 @@ function ReturnClient() {
38
57
  }
39
58
  }, [selectedClient]);
40
59
 
60
+ //API for client data
61
+ const { data: fetchedCustomerData, loading: loading } = useApiHook<
62
+ ApiResponse
63
+ >({
64
+ endpoint: `/customers/`,
65
+ method: 'GET',
66
+ //@ts-ignore
67
+ pagination: { is_pagination: false },
68
+ });
69
+
70
+ //API for action type
71
+ const { data: fetchedStaticData, loading: actionLoading } = useApiHook<
72
+ ApiResponse
73
+ >({
74
+ endpoint: `/orders/getStaticData/all/`,
75
+ method: 'GET',
76
+ // pagination: { page: 1, per_page: 50 },
77
+ });
78
+
79
+ //API for return locations
80
+ const { data: fetchedLocationData, loading: locationloading } = useApiHook<
81
+ ApiResponse
82
+ >({
83
+ endpoint: `/return_locations/`,
84
+ method: 'GET',
85
+ //@ts-ignore
86
+ pagination: { is_pagination: false },
87
+ });
88
+
89
+ useEffect(() => {
90
+ if (fetchedCustomerData && fetchedCustomerData?.data) {
91
+ setCustomers(fetchedCustomerData?.data);
92
+ }
93
+ }, [loading]);
94
+
95
+ useEffect(() => {
96
+ if (fetchedStaticData && fetchedStaticData?.data) {
97
+ setActionType(
98
+ fetchedStaticData?.data?.flatMap(
99
+ (i: any) => i?.order_product_return_action
100
+ )
101
+ );
102
+ setStatusOfOrders(
103
+ fetchedStaticData?.data?.flatMap((i: any) => i?.order_stock_alias)
104
+ );
105
+ }
106
+ }, [actionLoading]);
107
+
108
+ useEffect(() => {
109
+ if (fetchedLocationData && fetchedLocationData?.data) {
110
+ setLocationData(fetchedLocationData?.data);
111
+ }
112
+ }, [locationloading]);
113
+
41
114
  return (
42
115
  <>
43
116
  <RouterHeader />