@bjsdistribution/dms-client-return 0.1.66-prod → 0.1.67-prod

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.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.66-prod",
2
+ "version": "0.1.67-prod",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -10,7 +10,7 @@ import SortIcon from '../../../../common/SortIcon';
10
10
  import PrintDropDownReturn from '../../../order-view/details-filters/left-side-filters/dropdowns/PrintDropDownReturn';
11
11
  import { usefetchAgain, useReturnData } from '../../../order-view/store';
12
12
  import {
13
- useCustomerData,
13
+ useFlatCustomerData,
14
14
  useGroupedPayload,
15
15
  useLocationData,
16
16
  useNewReturnPayload,
@@ -31,7 +31,14 @@ import { CustomDrop, StyledTable, StyledTableWrapper } from './returnstyles';
31
31
  import { NavLink, useSearchParams } from 'react-router-dom';
32
32
  import { WEIGHT_UNIT } from '../../../../common/utils';
33
33
 
34
- const SELECTABLE_ACTIONS = ['RTS', 'CLAIMS PAID', 'DISPOSE', 'RE-ALLOCATE', 'RECYCLE', 'UNKNOWN'];
34
+ const SELECTABLE_ACTIONS = [
35
+ 'RTS',
36
+ 'CLAIMS PAID',
37
+ 'DISPOSE',
38
+ 'RE-ALLOCATE',
39
+ 'RECYCLE',
40
+ 'UNKNOWN',
41
+ ];
35
42
 
36
43
  const isSelectableItem = (item: any) =>
37
44
  SELECTABLE_ACTIONS.includes(item?.product_return_action) &&
@@ -179,9 +186,10 @@ const ReturnOrderTable = () => {
179
186
  }
180
187
  // setShouldPerformAction(false);
181
188
  }, [fetchedOrderData, returnDataLoad, locationData, state, callForFetch]);
182
- const [customers] = useCustomerData();
189
+ // const [customers] = useCustomerData();
190
+ const [flatCustomers] = useFlatCustomerData();
183
191
 
184
- const selectedCustomer = customers?.find((customer: any) => {
192
+ const selectedCustomer = flatCustomers?.find((customer: any) => {
185
193
  const customerId = customer?.customer_id?.toString();
186
194
  return customerId && customerId === urlCustomerId;
187
195
  });
@@ -193,16 +201,21 @@ const ReturnOrderTable = () => {
193
201
  setSelectAll(isChecked);
194
202
 
195
203
  if (isChecked) {
196
- const firstSelectable = returnData?.find((loc: any) => isSelectableItem(loc));
197
- const targetAction = selectedReturnOrder.length > 0
198
- ? selectedReturnOrder[0]?.product_return_action
199
- : firstSelectable?.product_return_action;
204
+ const firstSelectable = returnData?.find((loc: any) =>
205
+ isSelectableItem(loc)
206
+ );
207
+ const targetAction =
208
+ selectedReturnOrder.length > 0
209
+ ? selectedReturnOrder[0]?.product_return_action
210
+ : firstSelectable?.product_return_action;
200
211
 
201
212
  if (!targetAction) return;
202
213
 
203
214
  const filteredData = returnData?.filter(
204
- (loc: any) => isSelectableItem(loc) && loc?.product_return_action === targetAction
215
+ (loc: any) =>
216
+ isSelectableItem(loc) && loc?.product_return_action === targetAction
205
217
  );
218
+
206
219
  const selectedOrders = filteredData.map((loc: any) => ({
207
220
  id: loc.id,
208
221
  return_locations: loc?.return_location_name,
@@ -219,6 +232,7 @@ const ReturnOrderTable = () => {
219
232
  return_action: loc?.product_return_action,
220
233
  return_location_token: loc?.return_location || null,
221
234
  }));
235
+ console.log(newPayload, 'newPayloadnewPayload');
222
236
 
223
237
  setSelectedReturnOrder(selectedOrders);
224
238
  setNewPayload(newPayload);
@@ -258,12 +272,13 @@ const ReturnOrderTable = () => {
258
272
 
259
273
  const targetAction = product_return_action;
260
274
  const totalItemsOfAction = returnData?.filter(
261
- (loc: any) => isSelectableItem(loc) && loc?.product_return_action === targetAction
275
+ (loc: any) =>
276
+ isSelectableItem(loc) && loc?.product_return_action === targetAction
262
277
  )?.length;
263
278
 
264
279
  setSelectAll(
265
280
  updatedSelectedLocations?.length > 0 &&
266
- updatedSelectedLocations?.length === totalItemsOfAction
281
+ updatedSelectedLocations?.length === totalItemsOfAction
267
282
  );
268
283
  return updatedSelectedLocations;
269
284
  } else {
@@ -290,12 +305,11 @@ const ReturnOrderTable = () => {
290
305
 
291
306
  const targetAction = product_return_action;
292
307
  const totalItemsOfAction = returnData?.filter(
293
- (loc: any) => isSelectableItem(loc) && loc?.product_return_action === targetAction
308
+ (loc: any) =>
309
+ isSelectableItem(loc) && loc?.product_return_action === targetAction
294
310
  )?.length;
295
311
 
296
- setSelectAll(
297
- updatedSelectedLocations?.length === totalItemsOfAction
298
- );
312
+ setSelectAll(updatedSelectedLocations?.length === totalItemsOfAction);
299
313
  return updatedSelectedLocations;
300
314
  }
301
315
  });
@@ -319,16 +333,10 @@ const ReturnOrderTable = () => {
319
333
  };
320
334
  }
321
335
 
322
- acc[key].products = [
323
- ...acc[key].products,
324
- ...item.products,
325
- ];
336
+ acc[key].products = [...acc[key].products, ...item.products];
326
337
 
327
338
  acc[key].return_action = Array.from(
328
- new Set([
329
- ...acc[key].return_action,
330
- ...item.return_action,
331
- ])
339
+ new Set([...acc[key].return_action, ...item.return_action])
332
340
  );
333
341
 
334
342
  return acc;
@@ -416,7 +424,8 @@ const ReturnOrderTable = () => {
416
424
  className="custom-check"
417
425
  disabled={
418
426
  selectedReturnOrder.length > 0 &&
419
- selectedReturnOrder[0]?.product_return_action !== item?.product_return_action
427
+ selectedReturnOrder[0]?.product_return_action !==
428
+ item?.product_return_action
420
429
  }
421
430
  checked={selectedReturnOrder.some(
422
431
  (selectedInvoice: any) =>
@@ -443,7 +452,9 @@ const ReturnOrderTable = () => {
443
452
  )}
444
453
  </td>
445
454
  <td> {displayValueOrNA(item?.return_location_name)}</td>
446
- <td title={item?.client_name ?? ''}>{displayValueOrNA(item?.client_name)}</td>
455
+ <td title={item?.client_name ?? ''}>
456
+ {displayValueOrNA(item?.client_name)}
457
+ </td>
447
458
  <td>
448
459
  <ul style={{ listStyleType: 'none', padding: 0 }}>
449
460
  <li
@@ -36,7 +36,10 @@ const ModalManager = () => {
36
36
  const [, setGrouped] = useGroupedPayload();
37
37
  const [, setSelectAll] = useSelectAll();
38
38
  const [, setCallForFetch] = usefetchAgain();
39
- const [sendEmailNotification, setSendEmailNotification] = useSendEmailNotification();
39
+ const [
40
+ sendEmailNotification,
41
+ setSendEmailNotification,
42
+ ] = useSendEmailNotification();
40
43
  const navigate = useNavigate();
41
44
 
42
45
  const closeModal = () => {
@@ -67,6 +70,7 @@ const ModalManager = () => {
67
70
  body: newGrouped,
68
71
  performAction: false,
69
72
  });
73
+
70
74
  useEffect(() => {
71
75
  SetPostLoading(confirmLoading);
72
76
  }, [confirmLoading]);
@@ -116,14 +120,15 @@ const ModalManager = () => {
116
120
 
117
121
  const emailApiPayload = {
118
122
  // order_ids: response?.data ? response.data.map((item: any) => item?.order_id ?? 0) : [],
119
- gsit_order_ids: response?.data ? response.data.map((item: any) => item?.order_id ?? 0) : [],
123
+ gsit_order_ids: response?.data
124
+ ? response.data.map((item: any) => item?.order_id ?? 0)
125
+ : [],
120
126
  };
121
127
 
122
128
  // send to API
123
129
  if (sendEmailNotification) {
124
130
  callSendEmail({ payload: emailApiPayload });
125
131
  }
126
- console.log("orderIdsString", orderIdsString)
127
132
  if (orderIdsString) {
128
133
  navigate(`/orders/view/return/?order=${orderIdsString}`);
129
134
  } else {
@@ -163,14 +168,29 @@ const ModalManager = () => {
163
168
  {
164
169
  name: (
165
170
  <div
166
- style={{ display: 'flex', alignItems: 'center', marginRight: '16px', gap: '8px' }}
167
- onClick={(e) => e.stopPropagation()}
171
+ style={{
172
+ display: 'flex',
173
+ alignItems: 'center',
174
+ marginRight: '16px',
175
+ gap: '8px',
176
+ }}
177
+ onClick={e => e.stopPropagation()}
168
178
  >
169
179
  <Checkbox
170
180
  checked={sendEmailNotification}
171
- onChange={() => setSendEmailNotification(!sendEmailNotification)}
181
+ onChange={() =>
182
+ setSendEmailNotification(!sendEmailNotification)
183
+ }
172
184
  />
173
- <span style={{ color: '#8d8f90', fontFamily: 'Poppins', fontSize: '14px', fontWeight: 400, textTransform: 'none' }}>
185
+ <span
186
+ style={{
187
+ color: '#8d8f90',
188
+ fontFamily: 'Poppins',
189
+ fontSize: '14px',
190
+ fontWeight: 400,
191
+ textTransform: 'none',
192
+ }}
193
+ >
174
194
  Send Email Notification
175
195
  </span>
176
196
  </div>
@@ -223,4 +243,4 @@ const ModalManager = () => {
223
243
  );
224
244
  };
225
245
 
226
- export default ModalManager;
246
+ export default ModalManager;