@bjsdistribution/dms-client-return 0.0.53 → 0.0.55

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.0.53",
2
+ "version": "0.0.55",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -93,12 +93,30 @@ export const TableData = [
93
93
  },
94
94
  ];
95
95
 
96
- export const optionsPrint = [
97
- { icon: 'runSheet', label: 'Print Runsheet' },
98
- { icon: 'loadSheet', label: 'Print Loadsheet' },
99
- { icon: 'deliveryLables', label: 'Print Delivery Labels' },
100
- { icon: 'customerLables', label: 'Print Customer Labels' },
101
- { icon: 'collectionLables', label: 'Print Collection Labels' },
96
+ interface PrintOption {
97
+ icon: string;
98
+ label: string;
99
+ type: string;
100
+ }
101
+
102
+ export const optionsPrint: PrintOption[] = [
103
+ { icon: 'runSheet', label: 'Print Runsheet', type: 'runsheet_url' },
104
+ { icon: 'loadSheet', label: 'Print Loadsheet', type: 'loadsheet_url' },
105
+ {
106
+ icon: 'deliveryLables',
107
+ label: 'Print Delivery Labels',
108
+ type: 'delivery_label_url',
109
+ },
110
+ {
111
+ icon: 'customerLables',
112
+ label: 'Print Customer Labels',
113
+ type: 'customer_label_url',
114
+ },
115
+ {
116
+ icon: 'collectionLables',
117
+ label: 'Print Return Labels',
118
+ type: 'return_label_url',
119
+ },
102
120
  ];
103
121
 
104
122
  export const optionsForReturnPrint = [
@@ -372,9 +372,9 @@ const OrderTable = ({ loadingskeleton }: any) => {
372
372
  <PrinterIcon />
373
373
  <DownIcon />
374
374
 
375
- {printToogle == index && (
375
+ {printToogle === index && (
376
376
  <div ref={dropdownRef}>
377
- <PrintDropDown legacyProductId={item.id} />
377
+ <PrintDropDown legacyProductId={item} />
378
378
  </div>
379
379
  )}
380
380
  </li>
@@ -383,13 +383,6 @@ const OrderTable = ({ loadingskeleton }: any) => {
383
383
  <LoadIcon />
384
384
  </li>
385
385
  </ul>
386
- {/* <div className="shareIconContainer">
387
- <PrinterIcon />
388
- <DownIcon />
389
- </div>
390
- <div className="downloadcontainer">
391
- <LoadIcon />
392
- </div> */}
393
386
  </td>
394
387
  </tr>
395
388
  );
@@ -8,43 +8,30 @@ const PrintDropDown = ({
8
8
  }: {
9
9
  legacyProductId: Record<string, any>;
10
10
  }) => {
11
- const downloadFiles = (label: string) => {
12
- const url =
13
- legacyProductId?.[
14
- `${label
15
- .replace('Print ', '')
16
- .toLowerCase()
17
- .replace(' ', '_')}_url`
18
- ];
11
+ const downloadFiles = (type: string) => {
12
+ let url: string | undefined;
13
+
14
+ if (type) {
15
+ url = legacyProductId[type];
16
+ }
19
17
 
20
18
  if (url) {
21
19
  window.open(url, '_blank');
22
20
  } else {
23
- console.log('URL not available for', label);
21
+ console.log('URL not available for', type);
24
22
  }
25
23
  };
26
24
 
27
- const isOptionDisabled = (label: string) => {
28
- const url =
29
- legacyProductId?.[
30
- `${label
31
- .replace('Print ', '')
32
- .toLowerCase()
33
- .replace(' ', '_')}_url`
34
- ];
35
- return !url;
36
- };
37
-
38
25
  return (
39
26
  <OptionsList>
40
- {optionsPrint.map((item, index) => {
27
+ {optionsPrint?.map((item, index) => {
41
28
  const IconComponent = PrintIconMap[item.icon];
42
- const isDisabled = isOptionDisabled(item.label);
29
+ const isDisabled = !legacyProductId[item.type];
43
30
 
44
31
  return (
45
32
  <OptionsListLi
46
33
  key={index}
47
- onClick={() => !isDisabled && downloadFiles(item.label)}
34
+ onClick={() => !isDisabled && downloadFiles(item.type)}
48
35
  disabled={isDisabled}
49
36
  >
50
37
  {IconComponent && <IconComponent />}
@@ -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 = {
@@ -1,10 +1,12 @@
1
1
  import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
2
2
  import { getCookie } from '../utils';
3
3
  import { notification } from 'antd';
4
+ import { useUpdateApiCall } from '../store';
4
5
 
5
6
  function useUpdateOrder() {
6
7
  let controller: AbortController;
7
8
  const ssoToken = getCookie('id_token');
9
+ const [, setCallApi] = useUpdateApiCall(); //single detail
8
10
 
9
11
  const update = async (data: any) => {
10
12
  const endpoint = `${getBaseEndpoint()}/orders/update/`;
@@ -38,6 +40,7 @@ function useUpdateOrder() {
38
40
  message: 'Success',
39
41
  description: 'Order has been updated.',
40
42
  });
43
+ setCallApi(true);
41
44
  return json;
42
45
  } catch (err) {
43
46
  // setLoading(false);
@@ -30,7 +30,7 @@ import {
30
30
  useRouteId,
31
31
  useGsitOrderId,
32
32
  useOrderProductId,
33
- useApiCalling,
33
+ useUpdateApiCall,
34
34
  useLiveRecalling,
35
35
  } from './store';
36
36
  // import Loader from '../order-daily-overview/header/loader/Loader';
@@ -72,7 +72,7 @@ function OrderView() {
72
72
  const location = useLocation();
73
73
  const paths = splitPath(location.pathname);
74
74
  const [, setLocationOptions] = useLocationOptions();
75
- const [apiCalling] = useApiCalling();
75
+ const [apiCalling] = useUpdateApiCall();
76
76
  const [orderResources, setOrderResources] = useOrderProductsResources();
77
77
  const [orderToolbox, setOrderToolbox] = useOrderProductsToolbox();
78
78
  const [GsitCUstomerId, setGsitCUstomerId] = useGsitCUstomerId();
@@ -128,11 +128,8 @@ function OrderView() {
128
128
  }, [orderId, liveRecalling]);
129
129
 
130
130
  useEffect(() => {
131
- if (apiCalling) {
132
- orderUpdate(true);
133
- } else {
134
- orderUpdate(false);
135
- }
131
+ orderUpdate(true);
132
+ apiCalling ? orderUpdate(true) : orderUpdate(false);
136
133
  }, [apiCalling]);
137
134
 
138
135
  useEffect(() => {
@@ -1,11 +1,11 @@
1
1
  import React, { useEffect } from 'react';
2
2
  import { useDeleteProdsID, useProductDetails } from '../store';
3
+ import { Empty, Skeleton } from 'antd';
3
4
  import {
4
5
  EmptyDataContainer,
5
6
  StyledTable,
6
7
  StyledTableWrapper,
7
- } from '../all-reminder/table-view/ReminderStyles';
8
- import { Empty, Skeleton } from 'antd';
8
+ } from '../order-actions/actions/confirm-order/tables/ReminderStyles';
9
9
 
10
10
  const DeleteProduct = () => {
11
11
  const [productdata] = useProductDetails();
@@ -9,7 +9,7 @@ import {
9
9
  errorAtom,
10
10
  useCustomerInfo,
11
11
  // useLogsCallAPi,
12
- useApiCalling,
12
+ useUpdateApiCall,
13
13
  // UseNotesLoading,
14
14
  } from '../../../store';
15
15
  import useUpdateOrder from '../../../hooks/useUpdateOrder';
@@ -23,7 +23,7 @@ function OrderDetailsFooter() {
23
23
  const updateOrder = useUpdateOrder();
24
24
  const [errorState] = useAtom(errorAtom);
25
25
  // const [, setLogsCallAPi] = useLogsCallAPi();
26
- const [, setCallApi] = useApiCalling(); //single detail
26
+ const [, setCallApi] = useUpdateApiCall(); //single detail
27
27
  // const [, setNoteLoadingStore] = UseNotesLoading();
28
28
 
29
29
  const errorFound = () => {
@@ -78,12 +78,10 @@ function OrderDetailsFooter() {
78
78
  };
79
79
 
80
80
  const onSave = async () => {
81
- setCallApi(true);
82
81
  const payload = compareOrderDetailsStates(prevOrderDetails, orderDetails);
83
82
  const response = await updateOrder([payload]);
84
-
83
+ setCallApi(false);
85
84
  // setLogsCallAPi(prev => !prev);
86
-
87
85
  if (response && response?.data?.length > 0) {
88
86
  setOrderDetails(response?.data[0]);
89
87
  setPrevOrderDetails(response?.data[0]);
@@ -437,10 +437,10 @@ const returnDataAtom = atom<any[]>([]);
437
437
  export function useReturnData() {
438
438
  return useAtom(returnDataAtom);
439
439
  }
440
- const apiCalling = atom<boolean>(false);
440
+ const apiUpdateCalling = atom<boolean>(false);
441
441
 
442
- export function useApiCalling() {
443
- return useAtom(apiCalling);
442
+ export function useUpdateApiCall() {
443
+ return useAtom(apiUpdateCalling);
444
444
  }
445
445
  const liveRecalling = atom<boolean>(false);
446
446
 
@@ -448,6 +448,14 @@ const liveRecalling = atom<boolean>(false);
448
448
  export function useLiveRecalling() {
449
449
  return useAtom(liveRecalling);
450
450
  }
451
+
452
+ //delete products
453
+ const onDeleteProduct = atom<boolean>(false);
454
+
455
+ export function useDeleteRecall() {
456
+ return useAtom(onDeleteProduct);
457
+ }
458
+
451
459
  export const selectedTabKeyAtom = atom<string>('1');
452
460
  export const letselectedProductIdAtom = atom<number | null>(null);
453
461
 
@@ -475,12 +483,10 @@ const popupReducer = (state: any, action: any) => {
475
483
  } else if (action.type === 'addProduct') {
476
484
  state = 'addProduct';
477
485
  return { state };
478
- }
479
- else if (action.type === 'split-order') {
486
+ } else if (action.type === 'split-order') {
480
487
  state = 'split-order';
481
488
  return { state };
482
- }
483
- else if (action.type === 'deleteProduct') {
489
+ } else if (action.type === 'deleteProduct') {
484
490
  state = 'deleteProduct';
485
491
  return { state };
486
492
  } else if (action.type === 'defectsModal') {