@bjsdistribution/dms-client-return 0.1.68-prod → 0.1.69-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.68-prod",
2
+ "version": "0.1.69-prod",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -1,5 +1,5 @@
1
1
  import { Checkbox, useApiHook } from '@bjsdistribution/dms-component-library';
2
- import { Empty, notification, Skeleton } from 'antd';
2
+ import { Empty, notification, Skeleton, Tooltip } from 'antd';
3
3
  import { format } from 'date-fns';
4
4
  import { useAtom } from 'jotai';
5
5
  import React, { useEffect, useMemo, useRef, useState } from 'react';
@@ -278,7 +278,7 @@ const ReturnOrderTable = () => {
278
278
 
279
279
  setSelectAll(
280
280
  updatedSelectedLocations?.length > 0 &&
281
- updatedSelectedLocations?.length === totalItemsOfAction
281
+ updatedSelectedLocations?.length === totalItemsOfAction
282
282
  );
283
283
  return updatedSelectedLocations;
284
284
  } else {
@@ -419,29 +419,44 @@ const ReturnOrderTable = () => {
419
419
  sortedData?.map((item: any, index: any) => (
420
420
  <tr key={item.id}>
421
421
  <td>
422
- {isSelectableItem(item) ? (
423
- <Checkbox
424
- className="custom-check"
425
- disabled={
426
- selectedReturnOrder.length > 0 &&
427
- selectedReturnOrder[0]?.product_return_action !==
428
- item?.product_return_action
429
- }
430
- checked={selectedReturnOrder.some(
431
- (selectedInvoice: any) =>
432
- selectedInvoice?.id === item?.id
433
- )}
434
- onChange={() =>
435
- handleSelectOrderReturn(
436
- item?.id,
437
- item?.return_location,
438
- item?.return_location_name,
439
- item?.product_return_action,
440
- item?.legacy_product_id
441
- )
442
- }
443
- />
444
- ) : null}
422
+ {isSelectableItem(item) ? (() => {
423
+ const isDisabled =
424
+ selectedReturnOrder?.length > 0 &&
425
+ selectedReturnOrder[0]?.product_return_action !==
426
+ item?.product_return_action;
427
+
428
+ return (
429
+ <Tooltip
430
+ title={
431
+ isDisabled
432
+ ? 'Cannot select different return actions'
433
+ : ''
434
+ }
435
+ >
436
+ <span
437
+ className={isDisabled ? 'disabled-wrapper' : ''}
438
+ >
439
+ <Checkbox
440
+ className="custom-check"
441
+ disabled={isDisabled}
442
+ checked={selectedReturnOrder.some(
443
+ (selectedInvoice: any) =>
444
+ selectedInvoice?.id === item?.id
445
+ )}
446
+ onChange={() =>
447
+ handleSelectOrderReturn(
448
+ item?.id,
449
+ item?.return_location,
450
+ item?.return_location_name,
451
+ item?.product_return_action,
452
+ item?.legacy_product_id
453
+ )
454
+ }
455
+ />
456
+ </span>
457
+ </Tooltip>
458
+ );
459
+ })() : null}
445
460
  </td>
446
461
 
447
462
  <td>
@@ -253,7 +253,7 @@ export const StyledTable = styled.table`
253
253
  }
254
254
  }
255
255
  .custom-check {
256
- position: absloute;
256
+ position: absolute;
257
257
  }
258
258
  .emailInvoiceNo {
259
259
  padding-left: 0px;
@@ -305,6 +305,13 @@ export const StyledTable = styled.table`
305
305
  border-right: none;
306
306
  border-left: none;
307
307
  position: relative;
308
+ .disabled-wrapper {
309
+ cursor: not-allowed !important;
310
+ display: inline-block;
311
+ * {
312
+ pointer-events: none !important;
313
+ }
314
+ }
308
315
  .actionbox {
309
316
  display: flex;
310
317
  gap: 5px;
@@ -26,6 +26,7 @@ import { useNavigate } from 'react-router-dom';
26
26
 
27
27
  const ModalManager = () => {
28
28
  const [popupName, dispatch] = useAtom(countReducerAtom);
29
+ const [hasStartedLoading, setHasStartedLoading] = useState(false);
29
30
  const [selectedRows] = useDeleteProdsID();
30
31
  const [, setIsFormValid] = useState(false);
31
32
  const [newGrouped] = useFinalPayload();
@@ -60,7 +61,7 @@ const ModalManager = () => {
60
61
  data: response,
61
62
  setShouldPerformAction,
62
63
  loading: confirmLoading,
63
- // error: apiError,
64
+ error: apiError,
64
65
  setError,
65
66
  } = useApiHook<{
66
67
  data: ApiResponse[];
@@ -90,13 +91,24 @@ const ModalManager = () => {
90
91
  });
91
92
 
92
93
  useEffect(() => {
94
+ if (confirmLoading) {
95
+ setHasStartedLoading(true);
96
+ }
97
+ }, [confirmLoading]);
98
+
99
+ useEffect(() => {
100
+ if (!hasStartedLoading) return;
101
+ if (confirmLoading || postLoading) return;
102
+
93
103
  // @ts-ignore
94
- if ((response && response?.code == 500) || response?.code == 400) {
104
+ if (apiError || (response && (response?.code == 500 || response?.code == 400))) {
105
+ setHasStartedLoading(false);
106
+
95
107
  // @ts-ignore
108
+ const errorMessage = apiError?.message || response?.message || 'Failed to create return';
96
109
  notification.error({
97
110
  message: 'Failure',
98
- // @ts-ignore
99
- description: `${response?.message}`,
111
+ description: errorMessage,
100
112
  });
101
113
  dispatch({ type: 'close' });
102
114
  setSendEmailNotification(true);
@@ -109,6 +121,7 @@ const ModalManager = () => {
109
121
  setError(null);
110
122
  // @ts-ignore
111
123
  } else if (response?.code === 201 || response?.code === 200) {
124
+ setHasStartedLoading(false);
112
125
  notification.success({
113
126
  message: 'Success',
114
127
  // @ts-ignore
@@ -150,7 +163,7 @@ const ModalManager = () => {
150
163
  // for dev
151
164
  //navigate('/orders/view/return/overview');
152
165
  }
153
- }, [postLoading]);
166
+ }, [postLoading, confirmLoading, hasStartedLoading, response]);
154
167
 
155
168
  return (
156
169
  <>