@bjsdistribution/dms-client-return 0.1.65-prod → 0.1.66-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.65-prod",
2
+ "version": "0.1.66-prod",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -31,6 +31,13 @@ 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'];
35
+
36
+ const isSelectableItem = (item: any) =>
37
+ SELECTABLE_ACTIONS.includes(item?.product_return_action) &&
38
+ item?.return_location !== 'null' &&
39
+ item?.return_location !== null;
40
+
34
41
  const ReturnOrderTable = () => {
35
42
  const [state] = useAtom(filtersReducerAtom);
36
43
  const [selectedReturnOrder, setSelectedReturnOrder] = useSelectedOrders();
@@ -186,8 +193,15 @@ const ReturnOrderTable = () => {
186
193
  setSelectAll(isChecked);
187
194
 
188
195
  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;
200
+
201
+ if (!targetAction) return;
202
+
189
203
  const filteredData = returnData?.filter(
190
- (loc: any) => loc?.product_return_action === 'RTS'
204
+ (loc: any) => isSelectableItem(loc) && loc?.product_return_action === targetAction
191
205
  );
192
206
  const selectedOrders = filteredData.map((loc: any) => ({
193
207
  id: loc.id,
@@ -236,14 +250,21 @@ const ReturnOrderTable = () => {
236
250
  products: legacy_product_id,
237
251
  return_action: product_return_action || null,
238
252
  return_location_token: return_location || null,
239
- // new_location: new_location,
240
253
  }));
241
254
 
242
255
  setNewPayload((prevPayload: any) =>
243
256
  prevPayload.filter((item: any) => item.id !== id)
244
257
  );
245
258
 
246
- setSelectAll(false); // Ensure "select all" is false if one is deselected
259
+ const targetAction = product_return_action;
260
+ const totalItemsOfAction = returnData?.filter(
261
+ (loc: any) => isSelectableItem(loc) && loc?.product_return_action === targetAction
262
+ )?.length;
263
+
264
+ setSelectAll(
265
+ updatedSelectedLocations?.length > 0 &&
266
+ updatedSelectedLocations?.length === totalItemsOfAction
267
+ );
247
268
  return updatedSelectedLocations;
248
269
  } else {
249
270
  const newReturnPayload = {
@@ -266,11 +287,14 @@ const ReturnOrderTable = () => {
266
287
  product_return_action,
267
288
  },
268
289
  ];
290
+
291
+ const targetAction = product_return_action;
292
+ const totalItemsOfAction = returnData?.filter(
293
+ (loc: any) => isSelectableItem(loc) && loc?.product_return_action === targetAction
294
+ )?.length;
295
+
269
296
  setSelectAll(
270
- updatedSelectedLocations?.length ===
271
- returnData?.filter(
272
- (loc: any) => loc?.product_return_action === 'RTS'
273
- )?.length
297
+ updatedSelectedLocations?.length === totalItemsOfAction
274
298
  );
275
299
  return updatedSelectedLocations;
276
300
  }
@@ -278,35 +302,37 @@ const ReturnOrderTable = () => {
278
302
  };
279
303
 
280
304
  useEffect(() => {
281
- if (newpayload?.length === 0) return;
305
+ if (newpayload?.length === 0) {
306
+ setGrouped([]);
307
+ return;
308
+ }
282
309
 
283
310
  const groupedPayload = newpayload?.reduce((acc: any, item: any) => {
284
- const { return_location_token } = item;
311
+ const { return_location_token, id } = item;
312
+ const key = return_location_token || `no_token_${id}`;
285
313
 
286
- if (!return_location_token) {
287
- acc.push(item);
288
- } else {
289
- if (!acc[return_location_token]) {
290
- acc[return_location_token] = {
291
- ...item,
292
- products: [],
293
- return_action: [],
294
- };
295
- }
314
+ if (!acc[key]) {
315
+ acc[key] = {
316
+ ...item,
317
+ products: [],
318
+ return_action: [],
319
+ };
320
+ }
296
321
 
297
- acc[return_location_token].products = [
298
- ...acc[return_location_token].products,
299
- ...item.products,
300
- ];
322
+ acc[key].products = [
323
+ ...acc[key].products,
324
+ ...item.products,
325
+ ];
301
326
 
302
- acc[return_location_token].return_action = [
303
- ...acc[return_location_token].return_action,
327
+ acc[key].return_action = Array.from(
328
+ new Set([
329
+ ...acc[key].return_action,
304
330
  ...item.return_action,
305
- ];
306
- }
331
+ ])
332
+ );
307
333
 
308
334
  return acc;
309
- }, []);
335
+ }, {});
310
336
  const mergedPayload = Object.values(groupedPayload);
311
337
  setGrouped(mergedPayload);
312
338
  }, [newpayload]);
@@ -319,12 +345,7 @@ const ReturnOrderTable = () => {
319
345
  {/* <th className="emailInvoiceCheckbox">
320
346
  <Checkbox checked={selectAll} onChange={handleSelectAll} />
321
347
  </th> */}
322
- {returnData?.some(
323
- (item: any) =>
324
- item?.product_return_action === 'RTS' &&
325
- item?.return_location !== 'null' &&
326
- item?.return_location !== null
327
- ) ? (
348
+ {returnData?.some((item: any) => isSelectableItem(item)) ? (
328
349
  <th className="emailInvoiceCheckbox">
329
350
  <Checkbox checked={selectAll} onChange={handleSelectAll} />
330
351
  </th>
@@ -390,11 +411,13 @@ const ReturnOrderTable = () => {
390
411
  sortedData?.map((item: any, index: any) => (
391
412
  <tr key={item.id}>
392
413
  <td>
393
- {item?.product_return_action === 'RTS' &&
394
- item?.return_location !== 'null' &&
395
- item?.return_location !== null ? (
414
+ {isSelectableItem(item) ? (
396
415
  <Checkbox
397
416
  className="custom-check"
417
+ disabled={
418
+ selectedReturnOrder.length > 0 &&
419
+ selectedReturnOrder[0]?.product_return_action !== item?.product_return_action
420
+ }
398
421
  checked={selectedReturnOrder.some(
399
422
  (selectedInvoice: any) =>
400
423
  selectedInvoice?.id === item?.id
@@ -128,7 +128,7 @@ const ReturnTable: React.FC = () => {
128
128
  navigate(`/orders/view/return/filter?${queryParams.toString()}`);
129
129
 
130
130
  //for local
131
- //navigate(`/filter?${queryParams.toString()}`);
131
+ // navigate(`/filter?${queryParams.toString()}`);
132
132
  };
133
133
 
134
134
  //for RTS
@@ -278,19 +278,82 @@ const ReturnTable: React.FC = () => {
278
278
  <GreyBox>{rowKey?.PENDING ?? 0}</GreyBox>
279
279
  </ColumStyle>
280
280
  </td>
281
- <td style={{ textAlign: 'center' }}>
281
+ <td
282
+ style={{
283
+ color: rowKey?.['CLAIMS PAID'] > 0 ? '#0099ff' : 'inherit',
284
+ fontWeight: rowKey?.['CLAIMS PAID'] > 0 ? 600 : 'normal',
285
+ cursor: rowKey?.['CLAIMS PAID'] > 0 ? 'pointer' : 'default',
286
+ textAlign: 'center',
287
+ }}
288
+ onClick={
289
+ rowKey?.['CLAIMS PAID'] > 0
290
+ ? () => handleRedirectRTS(rowKey?.customer_id, 'CLAIMS PAID')
291
+ : undefined
292
+ }
293
+ >
282
294
  <ColumStyle>
283
- <GreyBox>{rowKey?.['CLAIMS PAID'] ?? 0}</GreyBox>
295
+ <GreyBox
296
+ style={{
297
+ backgroundColor:
298
+ rowKey?.['CLAIMS PAID'] > 0
299
+ ? 'rgba(99, 150, 229, 0.1)'
300
+ : 'rgba(153, 153, 153, 0.1)',
301
+ }}
302
+ >
303
+ {rowKey?.['CLAIMS PAID'] ?? 0}
304
+ </GreyBox>
284
305
  </ColumStyle>
285
306
  </td>
286
- <td style={{ textAlign: 'center' }}>
307
+ <td
308
+ style={{
309
+ color: rowKey?.DISPOSE > 0 ? '#0099ff' : 'inherit',
310
+ fontWeight: rowKey?.DISPOSE > 0 ? 600 : 'normal',
311
+ cursor: rowKey?.DISPOSE > 0 ? 'pointer' : 'default',
312
+ textAlign: 'center',
313
+ }}
314
+ onClick={
315
+ rowKey?.DISPOSE > 0
316
+ ? () => handleRedirectRTS(rowKey?.customer_id, 'DISPOSE')
317
+ : undefined
318
+ }
319
+ >
287
320
  <ColumStyle>
288
- <GreyBox>{rowKey?.DISPOSE ?? 0}</GreyBox>
321
+ <GreyBox
322
+ style={{
323
+ backgroundColor:
324
+ rowKey?.DISPOSE > 0
325
+ ? 'rgba(99, 150, 229, 0.1)'
326
+ : 'rgba(153, 153, 153, 0.1)',
327
+ }}
328
+ >
329
+ {rowKey?.DISPOSE ?? 0}
330
+ </GreyBox>
289
331
  </ColumStyle>
290
332
  </td>
291
- <td style={{ textAlign: 'center' }}>
333
+ <td
334
+ style={{
335
+ color: rowKey?.['RE-ALLOCATE'] > 0 ? '#0099ff' : 'inherit',
336
+ fontWeight: rowKey?.['RE-ALLOCATE'] > 0 ? 600 : 'normal',
337
+ cursor: rowKey?.['RE-ALLOCATE'] > 0 ? 'pointer' : 'default',
338
+ textAlign: 'center',
339
+ }}
340
+ onClick={
341
+ rowKey?.['RE-ALLOCATE'] > 0
342
+ ? () => handleRedirectRTS(rowKey?.customer_id, 'RE-ALLOCATE')
343
+ : undefined
344
+ }
345
+ >
292
346
  <ColumStyle>
293
- <GreyBox>{rowKey?.['RE-ALLOCATE'] ?? 0}</GreyBox>
347
+ <GreyBox
348
+ style={{
349
+ backgroundColor:
350
+ rowKey?.['RE-ALLOCATE'] > 0
351
+ ? 'rgba(99, 150, 229, 0.1)'
352
+ : 'rgba(153, 153, 153, 0.1)',
353
+ }}
354
+ >
355
+ {rowKey?.['RE-ALLOCATE'] ?? 0}
356
+ </GreyBox>
294
357
  </ColumStyle>
295
358
  </td>
296
359
  <td style={{ textAlign: 'center' }}>
@@ -298,14 +361,56 @@ const ReturnTable: React.FC = () => {
298
361
  <GreyBox>{rowKey?.['RE-DEL'] ?? 0}</GreyBox>
299
362
  </ColumStyle>
300
363
  </td>
301
- <td style={{ textAlign: 'center' }}>
364
+ <td
365
+ style={{
366
+ color: rowKey?.RECYCLE > 0 ? '#0099ff' : 'inherit',
367
+ fontWeight: rowKey?.RECYCLE > 0 ? 600 : 'normal',
368
+ cursor: rowKey?.RECYCLE > 0 ? 'pointer' : 'default',
369
+ textAlign: 'center',
370
+ }}
371
+ onClick={
372
+ rowKey?.RECYCLE > 0
373
+ ? () => handleRedirectRTS(rowKey?.customer_id, 'RECYCLE')
374
+ : undefined
375
+ }
376
+ >
302
377
  <ColumStyle>
303
- <GreyBox>{rowKey?.RECYCLE ?? 0}</GreyBox>
378
+ <GreyBox
379
+ style={{
380
+ backgroundColor:
381
+ rowKey?.RECYCLE > 0
382
+ ? 'rgba(99, 150, 229, 0.1)'
383
+ : 'rgba(153, 153, 153, 0.1)',
384
+ }}
385
+ >
386
+ {rowKey?.RECYCLE ?? 0}
387
+ </GreyBox>
304
388
  </ColumStyle>
305
389
  </td>
306
- <td style={{ textAlign: 'center' }}>
390
+ <td
391
+ style={{
392
+ color: rowKey?.UNKNOWN > 0 ? '#0099ff' : 'inherit',
393
+ fontWeight: rowKey?.UNKNOWN > 0 ? 600 : 'normal',
394
+ cursor: rowKey?.UNKNOWN > 0 ? 'pointer' : 'default',
395
+ textAlign: 'center',
396
+ }}
397
+ onClick={
398
+ rowKey?.UNKNOWN > 0
399
+ ? () => handleRedirectRTS(rowKey?.customer_id, 'UNKNOWN')
400
+ : undefined
401
+ }
402
+ >
307
403
  <ColumStyle>
308
- <GreyBox>{rowKey?.UNKNOWN ?? 0}</GreyBox>
404
+ <GreyBox
405
+ style={{
406
+ backgroundColor:
407
+ rowKey?.UNKNOWN > 0
408
+ ? 'rgba(99, 150, 229, 0.1)'
409
+ : 'rgba(153, 153, 153, 0.1)',
410
+ }}
411
+ >
412
+ {rowKey?.UNKNOWN ?? 0}
413
+ </GreyBox>
309
414
  </ColumStyle>
310
415
  </td>
311
416
  </tr>
@@ -2,18 +2,30 @@ import React from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { useCustomerInfo, useGlobalEscData } from '../../store';
4
4
 
5
+ import { Skeleton } from 'antd';
6
+
5
7
  const Details = () => {
6
8
  // const [orderDetails] = useOrderDetails();
7
9
  const [customerInfo] = useCustomerInfo();
8
10
  const recipient = customerInfo?.recipient_name || '';
9
11
  const postcodeShow = customerInfo?.postcode || '';
12
+ const returnActionString = customerInfo?.return_action?.length
13
+ ? `${customerInfo.return_action.join(', ')} - `
14
+ : '';
15
+
10
16
  const [globalEscData] = useGlobalEscData();
11
17
 
18
+ const isLoading = !recipient && !postcodeShow;
19
+
12
20
  return (
13
21
  <DetailsContainer>
14
22
  <Typo>
15
- CUSTOMER RETURN - {recipient} , {postcodeShow} {}
16
- {globalEscData?.length > 0 && (
23
+ {isLoading ? (
24
+ <Skeleton.Input active size="small" style={{ width: 350, borderRadius: 8 }} />
25
+ ) : (
26
+ `RETURN - ${returnActionString}${recipient} - ${postcodeShow}`
27
+ )}
28
+ {globalEscData?.length > 0 && !isLoading && (
17
29
  <EscInfo>
18
30
  {`${globalEscData[0]?.escalation_type?.level} (${globalEscData[0]?.escalation_type?.name})`}
19
31
  </EscInfo>
@@ -218,6 +218,7 @@ function OrderView({ locationloading }: any) {
218
218
  recipient_name:
219
219
  requiredData[0]?.order_recipient?.recipient_name ?? null,
220
220
  postcode: requiredData[0]?.order_recipient?.postcode ?? null,
221
+ return_action: requiredData[0]?.return_action ?? null,
221
222
  });
222
223
 
223
224
  setPrevOrderDetails(requiredData[0]);
@@ -197,6 +197,8 @@ function OrderDetailsFooter() {
197
197
  setCustomerInfo({
198
198
  recipient_name: response?.data[0]?.order_recipient?.recipient_name,
199
199
  postcode: response?.data[0]?.order_recipient?.postcode,
200
+ return_action: response?.data[0]?.return_action,
201
+
200
202
  });
201
203
  setRecallAuditLog(true);
202
204
  } else {
@@ -26,6 +26,7 @@ const orderStaticDataAtom = atom<any>({});
26
26
  interface OrderRecipient {
27
27
  recipient_name: string | null;
28
28
  postcode: string | null;
29
+ return_action?: string[] | null;
29
30
  }
30
31
 
31
32
  const customerInfoAtom = atom<OrderRecipient>({
@@ -221,6 +221,7 @@ export interface OrdersType {
221
221
  order_customs_details?: OrderCustomsDetails;
222
222
  show_customs_details?: false;
223
223
  import_reference: string | null;
224
+ return_action?: string[] | null;
224
225
  }
225
226
 
226
227
  export type DeleteProds = {