@bjsdistribution/dms-client-return 0.0.40 → 0.0.42

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.
@@ -37,6 +37,7 @@ const ReturnTable: React.FC = () => {
37
37
  const [, dispatch] = useAtom(filtersReducerAtom);
38
38
  const navigate = useNavigate();
39
39
  const [customers] = useCustomerData();
40
+ // const [searchParams] = useSearchParams();
40
41
 
41
42
  //sorting
42
43
  const [sortConfig, setSortConfig] = useState<{
@@ -93,7 +94,6 @@ const ReturnTable: React.FC = () => {
93
94
  });
94
95
 
95
96
  useEffect(() => {
96
- // setLoading(staticDataLoading);
97
97
  if (fetchedStaticData && fetchedStaticData.data) {
98
98
  const result = fetchedStaticData?.data;
99
99
  setOrderStaticData(result[0]);
@@ -117,15 +117,7 @@ const ReturnTable: React.FC = () => {
117
117
  }, [customers, clientData]);
118
118
 
119
119
  //handle Redirect
120
- const handleRedirect = (
121
- customerName: string,
122
- customerId: number,
123
- account_number: string
124
- ) => {
125
- localStorage.setItem('clientName', customerName);
126
- localStorage.setItem('clientId', customerId?.toString());
127
- localStorage.setItem('account_number', account_number);
128
-
120
+ const handleRedirect = (customerId: number) => {
129
121
  if (customerId) {
130
122
  dispatch({
131
123
  type: 'SET_CLIENT_FILTER',
@@ -141,14 +133,45 @@ const ReturnTable: React.FC = () => {
141
133
  payload: [],
142
134
  });
143
135
  }
136
+
137
+ const queryParams = new URLSearchParams({
138
+ customerId: customerId?.toString(),
139
+ });
144
140
  //for dev
145
- navigate(`filter/${customerId}`);
141
+ navigate(`filter?${queryParams.toString()}`);
146
142
 
147
143
  //for local
148
- // navigate(`/filter/${customerId}`);
144
+ //navigate(`/filter?${queryParams.toString()}`);
149
145
  };
150
146
 
151
- console.log(statsLoading, 'statsLoading');
147
+ //for RTS
148
+ const handleRedirectRTS = (customerId: number, RTS: string) => {
149
+ if (customerId) {
150
+ dispatch({
151
+ type: 'SET_CLIENT_FILTER',
152
+ payload: customerId,
153
+ });
154
+ dispatch({
155
+ type: 'SET_PAGE',
156
+ payload: 1,
157
+ });
158
+ } else {
159
+ dispatch({
160
+ type: 'SET_CLIENT_FILTER',
161
+ payload: [],
162
+ });
163
+ }
164
+
165
+ const queryParams = new URLSearchParams({
166
+ customerId: customerId?.toString(),
167
+ type: RTS,
168
+ });
169
+ //for dev
170
+ navigate(`filter?${queryParams.toString()}`);
171
+
172
+ //for local
173
+ //navigate(`/filter?${queryParams.toString()}`);
174
+ };
152
175
 
153
176
  return (
154
177
  <>
@@ -200,13 +223,7 @@ const ReturnTable: React.FC = () => {
200
223
  <td>{key?.trading_as}</td>
201
224
 
202
225
  <td
203
- onClick={() =>
204
- handleRedirect(
205
- key?.customer_name,
206
- key?.customer_id,
207
- key?.account_number
208
- )
209
- }
226
+ onClick={() => handleRedirect(key?.customer_id)}
210
227
  style={{
211
228
  color: '#0099ff',
212
229
  fontWeight: 600,
@@ -230,9 +247,25 @@ const ReturnTable: React.FC = () => {
230
247
  <GreyBox>{key?.return_order_products}</GreyBox>
231
248
  </ColumStyle>
232
249
  </td>
233
- <td>
250
+ <td
251
+ style={{
252
+ color: key?.RTS > 0 ? '#0099ff' : 'inherit',
253
+ fontWeight: key?.RTS > 0 ? 600 : 'normal',
254
+ cursor: key?.RTS > 0 ? 'pointer' : 'default',
255
+ }}
256
+ onClick={() => handleRedirectRTS(key?.customer_id, 'RTS')}
257
+ >
234
258
  <ColumStyle>
235
- <GreyBox>{key?.RTS}</GreyBox>
259
+ <GreyBox
260
+ style={{
261
+ backgroundColor:
262
+ key?.RTS > 0
263
+ ? 'rgba(99, 150, 229, 0.1)'
264
+ : 'rgba(153, 153, 153, 0.1)',
265
+ }}
266
+ >
267
+ {key?.RTS}
268
+ </GreyBox>
236
269
  </ColumStyle>
237
270
  </td>
238
271
 
@@ -7,7 +7,7 @@ function useGetEventNotes() {
7
7
  const ssoToken = getCookie('id_token');
8
8
 
9
9
  const perform = async () => {
10
- const endpoint = `${getBaseEndpoint()}/events/get/event_information/`;
10
+ const endpoint = `${getBaseEndpoint()}events/get/event_information/`;
11
11
  // setLoading(true);
12
12
  try {
13
13
  const headers = {
@@ -55,7 +55,7 @@ const ModalManager = () => {
55
55
  data: response,
56
56
  setShouldPerformAction,
57
57
  loading: confirmLoading,
58
- error: apiError,
58
+ // error: apiError,
59
59
  setError,
60
60
  } = useApiHook<{
61
61
  data: ApiResponse[];
@@ -80,11 +80,12 @@ const ModalManager = () => {
80
80
 
81
81
  useEffect(() => {
82
82
  // @ts-ignore
83
- if (apiError && apiError?.code !== 200) {
83
+ if (response && response?.code == 500) {
84
+ // @ts-ignore
84
85
  notification.error({
85
86
  message: 'Failure',
86
87
  // @ts-ignore
87
- description: `${apiError?.message}`,
88
+ description: `${response?.message}`,
88
89
  });
89
90
  dispatch({ type: 'close' });
90
91
  setSelectedReturnOrder([]);
@@ -115,7 +116,7 @@ const ModalManager = () => {
115
116
  // for dev
116
117
  navigate('/returnclient/order-return');
117
118
  }
118
- }, [response, apiError, postLoading]);
119
+ }, [postLoading]);
119
120
 
120
121
  return (
121
122
  <>
@@ -52,11 +52,10 @@ const Container = styled.div<{ disabled: boolean }>`
52
52
  ${({ disabled }) =>
53
53
  disabled &&
54
54
  `
55
- cursor: not-allowed;
56
55
  pointer-events: none;
57
56
 
58
57
  > * {
59
- cursor: not-allowed;
58
+ pointer-events: none;
60
59
  }
61
60
  `}
62
61
 
package/src/index.tsx CHANGED
@@ -1,11 +1,11 @@
1
1
  import React, { Suspense, useEffect } from 'react';
2
- import { Route, Routes, useNavigate } from 'react-router-dom';
2
+ import { Route, Routes, useSearchParams } 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
6
  import {
7
- useIdForTableName,
8
- useTableName,
7
+ useSelectedAction,
8
+ useSelectedClient,
9
9
  } from './components/order-daily-overview/store/store';
10
10
  import ReturnMainTable from './components/order-daily-overview';
11
11
  import { notification } from 'antd';
@@ -27,8 +27,6 @@ function ReturnClient() {
27
27
  top: 80,
28
28
  });
29
29
  const LoadingMessage = () => <div>Loading...</div>;
30
- const [selectedClientId] = useIdForTableName();
31
- const navigate = useNavigate();
32
30
  const [, setCustomers] = useCustomerData();
33
31
  const [, setActionType] = useActionType();
34
32
  const [, setLocationData] = useLocationData();
@@ -36,7 +34,9 @@ function ReturnClient() {
36
34
  const [, setAssignData] = useAssignData();
37
35
  const [, setActionTypeOptions] = useActionTypeOptions();
38
36
  const [, setLocationOptions] = useLocationOptions();
39
- const [, setTableName] = useTableName();
37
+ const [, setSelectedFilterValue] = useSelectedAction();
38
+ const [, setSelectedClient] = useSelectedClient();
39
+ const [searchParams] = useSearchParams();
40
40
 
41
41
  const splitPath = (str: any) => {
42
42
  const parts = str?.split('/')?.filter((part: any) => part !== ''); // Filter out empty parts
@@ -45,20 +45,18 @@ function ReturnClient() {
45
45
  const paths = splitPath(location.pathname);
46
46
  useEffect(() => {
47
47
  if (paths[paths.length - 1] === 'returnclient') {
48
- localStorage.removeItem('clientName');
49
- localStorage.removeItem('clientId');
50
- localStorage.removeItem('account_number');
51
48
  setActionTypeOptions([]);
52
49
  setLocationOptions([]);
53
- setTableName('');
50
+ setSelectedClient(null);
51
+ setSelectedFilterValue(null);
54
52
  }
55
- }, [location.pathname]);
53
+ }, [location.pathname, searchParams]);
56
54
 
57
- useEffect(() => {
58
- if (selectedClientId) {
59
- navigate(`filter/${selectedClientId}`);
60
- }
61
- }, [selectedClientId]);
55
+ // useEffect(() => {
56
+ // if (selectedClientId) {
57
+ // navigate(`filter/${selectedClientId}`);
58
+ // }
59
+ // }, [selectedClientId]);
62
60
 
63
61
  //API for client data
64
62
  const { data: fetchedCustomerData, loading: loading } = useApiHook<
@@ -76,7 +74,6 @@ function ReturnClient() {
76
74
  >({
77
75
  endpoint: `/orders/getStaticData/all/`,
78
76
  method: 'GET',
79
- // pagination: { page: 1, per_page: 50 },
80
77
  });
81
78
 
82
79
  //API for return locations
@@ -130,7 +127,7 @@ function ReturnClient() {
130
127
 
131
128
  <Route path="order-return" element={<ReturnAfterTable />} />
132
129
  <Route path="order-return/:id" element={<OrderView />} />
133
- <Route path="filter/:clientId" element={<ReturnTable />} />
130
+ <Route path="filter" element={<ReturnTable />} />
134
131
 
135
132
  {/* <Route
136
133
  path=""