@bjsdistribution/dms-client-return 0.0.89 → 0.0.91

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.
Files changed (53) hide show
  1. package/dist/components/order-view/flags-action-modal/Actions.d.ts +1 -1
  2. package/dist/components/order-view/flags-action-modal/Header.d.ts +1 -1
  3. package/dist/dms-client-return.cjs.development.js +1166 -1927
  4. package/dist/dms-client-return.cjs.development.js.map +1 -1
  5. package/dist/dms-client-return.cjs.production.min.js +1 -1
  6. package/dist/dms-client-return.cjs.production.min.js.map +1 -1
  7. package/dist/dms-client-return.esm.js +1168 -1929
  8. package/dist/dms-client-return.esm.js.map +1 -1
  9. package/package.json +2 -2
  10. package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +0 -3
  11. package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +1 -4
  12. package/src/components/order-daily-overview/table/ReturnTable.tsx +0 -2
  13. package/src/components/order-view/flags-action-modal/Actions.tsx +33 -17
  14. package/src/components/order-view/flags-action-modal/Header.tsx +34 -9
  15. package/src/components/order-view/flags-action-modal/index.tsx +44 -27
  16. package/src/components/order-view/index.tsx +28 -16
  17. package/src/components/order-view/notes/AddNote.tsx +18 -22
  18. package/src/components/order-view/notification/index.tsx +76 -56
  19. package/src/components/order-view/order-actions/actions/add-resources/index.tsx +40 -11
  20. package/src/components/order-view/order-actions/actions/confirm-order/index.tsx +17 -5
  21. package/src/components/order-view/order-actions/actions/create-task-reminder/CreateTaskModal.tsx +0 -4
  22. package/src/components/order-view/order-actions/actions/create-task-reminder/TaskModal.tsx +54 -14
  23. package/src/components/order-view/order-actions/actions/create-task-reminder/index.tsx +57 -22
  24. package/src/components/order-view/order-actions/actions/order-lock/index.tsx +34 -9
  25. package/src/components/order-view/order-details/expanded-content/footer/index.tsx +22 -5
  26. package/src/components/order-view/order-resources/columns/actions/index.tsx +1 -1
  27. package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +1 -7
  28. package/src/components/order-view/system-event-logs/expanded-content/index.tsx +23 -26
  29. package/src/components/order-view/view-reminder/ViewReminder.tsx +157 -118
  30. package/dist/components/order-view/hooks/AddResources.d.ts +0 -2
  31. package/dist/components/order-view/hooks/useGetEventNotes.d.ts +0 -2
  32. package/dist/components/order-view/hooks/useGetSystemLogs.d.ts +0 -2
  33. package/dist/components/order-view/hooks/useUpdateOrder.d.ts +0 -2
  34. package/dist/components/order-view/order-actions/hooks/useAllReminderData.d.ts +0 -2
  35. package/dist/components/order-view/order-actions/hooks/useAllTaskData.d.ts +0 -2
  36. package/dist/components/order-view/order-actions/hooks/useCreateReminder.d.ts +0 -3
  37. package/dist/components/order-view/order-actions/hooks/useCreateTask.d.ts +0 -3
  38. package/dist/components/order-view/order-actions/hooks/useFetchSingleFlagData.d.ts +0 -2
  39. package/dist/components/order-view/order-actions/hooks/useFetchSingleReminder.d.ts +0 -2
  40. package/dist/components/order-view/order-actions/hooks/useUpdateFlag.d.ts +0 -3
  41. package/dist/components/order-view/order-actions/hooks/useUpdateReminder.d.ts +0 -3
  42. package/src/components/order-view/hooks/AddResources.tsx +0 -54
  43. package/src/components/order-view/hooks/useGetEventNotes.tsx +0 -60
  44. package/src/components/order-view/hooks/useGetSystemLogs.tsx +0 -71
  45. package/src/components/order-view/hooks/useUpdateOrder.ts +0 -62
  46. package/src/components/order-view/order-actions/hooks/useAllReminderData.ts +0 -70
  47. package/src/components/order-view/order-actions/hooks/useAllTaskData.ts +0 -72
  48. package/src/components/order-view/order-actions/hooks/useCreateReminder.ts +0 -58
  49. package/src/components/order-view/order-actions/hooks/useCreateTask.ts +0 -58
  50. package/src/components/order-view/order-actions/hooks/useFetchSingleFlagData.ts +0 -58
  51. package/src/components/order-view/order-actions/hooks/useFetchSingleReminder.ts +0 -56
  52. package/src/components/order-view/order-actions/hooks/useUpdateFlag.ts +0 -54
  53. package/src/components/order-view/order-actions/hooks/useUpdateReminder.ts +0 -52
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.89",
2
+ "version": "0.0.91",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -59,7 +59,7 @@
59
59
  "testEnvironment": "jest-environment-jsdom-sixteen"
60
60
  },
61
61
  "devDependencies": {
62
- "@bjsdistribution/dms-component-library": "0.1.82",
62
+ "@bjsdistribution/dms-component-library": "0.1.87",
63
63
  "@size-limit/preset-small-lib": "^11.0.1",
64
64
  "@tippyjs/react": "^4.2.6",
65
65
  "@types/react": "^18.2.47",
@@ -24,7 +24,6 @@ import {
24
24
  import styled from 'styled-components';
25
25
  import { useApiHook } from '@bjsdistribution/dms-component-library';
26
26
  import { ApiResponse } from '../../common/interface';
27
- import Loader from '../../header/loader/Loader';
28
27
  import CaretDownFilledIcon from '../../../../common/CaretDownFilledIcon';
29
28
  import SortIcon from '../../../../common/SortIcon';
30
29
 
@@ -163,7 +162,6 @@ const OrderTable = () => {
163
162
  const {
164
163
  data: actionResponse,
165
164
  setShouldPerformAction: setAssignAction,
166
- loading: AssignLoading,
167
165
  error: apiError,
168
166
  } = useApiHook<{
169
167
  data: ApiResponse[];
@@ -212,7 +210,6 @@ const OrderTable = () => {
212
210
 
213
211
  return (
214
212
  <>
215
- {AssignLoading && <Loader />}
216
213
  <StyledTableWrapper className="fortables">
217
214
  <StyledTable>
218
215
  <thead>
@@ -7,7 +7,6 @@ import {
7
7
  useGroupedPayload,
8
8
  useLocationData,
9
9
  useNewReturnPayload,
10
- usePostLoading,
11
10
  useReturnPayload,
12
11
  useSelectAll,
13
12
  useSelectedOrders,
@@ -27,7 +26,6 @@ import { filtersReducerAtom } from '../../header-filters/filterStore';
27
26
  import { displayValueOrNA } from '../../shared/utlis';
28
27
  import PrintDropDownReturn from '../../../order-view/details-filters/left-side-filters/dropdowns/PrintDropDownReturn';
29
28
  import { format } from 'date-fns';
30
- import Loader from '../../header/loader/Loader';
31
29
  import CaretDownFilledIcon from '../../../../common/CaretDownFilledIcon';
32
30
  import SortIcon from '../../../../common/SortIcon';
33
31
  const ReturnOrderTable = () => {
@@ -38,7 +36,7 @@ const ReturnOrderTable = () => {
38
36
  const { 'x-filters': filters, 'x-pagination': pagination } = state;
39
37
  const [returnData, setReturnData] = useReturnData();
40
38
  const [load, setLoading] = useLoading();
41
- const [postLoading] = usePostLoading();
39
+ // const [postLoading] = usePostLoading();
42
40
  const dropdownRefParent = useRef<HTMLDivElement>(null);
43
41
  const dropdownRef = useRef<HTMLDivElement>(null);
44
42
  const [printToogle, setPrintToggle] = usePrintOptionTOggle();
@@ -318,7 +316,6 @@ const ReturnOrderTable = () => {
318
316
 
319
317
  return (
320
318
  <>
321
- {postLoading && <Loader />}
322
319
  <StyledTableWrapper className="fortables">
323
320
  <StyledTable>
324
321
  <thead>
@@ -19,7 +19,6 @@ import { filtersReducerAtom } from '../header-filters/filterStore';
19
19
  import { useCustomerData } from '../../store';
20
20
  import SortIcon from '../../../common/SortIcon';
21
21
  import CaretDownFilledIcon from '../../../common/CaretDownFilledIcon';
22
- import Loader from '../header/loader/Loader';
23
22
 
24
23
  interface ApiResponse {
25
24
  message: string;
@@ -177,7 +176,6 @@ const ReturnTable: React.FC = () => {
177
176
 
178
177
  return (
179
178
  <>
180
- {statsLoading && <Loader />}
181
179
  <StyledTableWrapper>
182
180
  <StyledTable>
183
181
  <thead>
@@ -3,33 +3,49 @@ import styled from 'styled-components';
3
3
  import {
4
4
  Button,
5
5
  RadioButtonGroup,
6
+ useAxios,
6
7
  } from '@bjsdistribution/dms-component-library';
7
-
8
- import {
9
- useFlagsLoading,
10
- useSingleFlagData,
11
- useSinglePayload,
12
- } from '../order-actions/store';
8
+ import { useSingleFlagData, useSinglePayload } from '../order-actions/store';
13
9
  import { useCurrentAction } from '../store';
14
10
  import Tippy from '@tippyjs/react';
15
- import useUpdateFlag from '../order-actions/hooks/useUpdateFlag';
16
- import useFetchUnresolvedTasks from '../order-actions/hooks/useAllTaskData';
11
+ import { notification } from 'antd';
12
+ import { ApiResponse } from '../types';
17
13
 
18
- function ActionSection() {
14
+ function ActionSection({ callUnresolvedTaskApi }: any) {
19
15
  const [, setCurrentAction] = useCurrentAction();
20
16
  const [payload] = useSinglePayload();
21
17
  const [dataArray] = useSingleFlagData();
22
- const fetchData = useFetchUnresolvedTasks();
23
- const [, setLoading] = useFlagsLoading();
24
18
 
25
- const updateFlag = useUpdateFlag();
19
+ //flag PUT API
20
+ const { fetchData: callFlagUpdateAPI } = useAxios<{
21
+ data: ApiResponse[];
22
+ }>({
23
+ endpoint: `/tasks/update/`,
24
+ method: 'PUT',
25
+ });
26
26
 
27
27
  const onSubmit = async () => {
28
- setLoading(true);
29
- await updateFlag([payload]);
30
- setCurrentAction(undefined);
31
- setLoading(false);
32
- await fetchData();
28
+ let response = (await callFlagUpdateAPI({
29
+ payload: [payload],
30
+ })) as {
31
+ code: number | null;
32
+ error?: string | null | undefined;
33
+ [key: string]: any;
34
+ };
35
+ if (response.code == 200 && response.data) {
36
+ notification.success({
37
+ message: 'Success',
38
+ description: `${response.message}`,
39
+ });
40
+ setCurrentAction(undefined);
41
+ await callUnresolvedTaskApi();
42
+ }
43
+ if (response?.code == null && response.error) {
44
+ return notification.error({
45
+ message: 'Failure',
46
+ description: `${response.error}`,
47
+ });
48
+ }
33
49
  };
34
50
 
35
51
  const onCancel = () => {
@@ -4,20 +4,27 @@ import {
4
4
  CancelAndCompleteAction,
5
5
  CancelationModal,
6
6
  CrossIcon,
7
+ useAxios,
7
8
  } from '@bjsdistribution/dms-component-library';
8
9
  import { useResolvedPayload, useSingleFlagData } from '../order-actions/store';
9
- import useUpdateFlag from '../order-actions/hooks/useUpdateFlag';
10
10
  import { useCurrentAction } from '../store';
11
- import useFetchUnresolvedTasks from '../order-actions/hooks/useAllTaskData';
11
+ import { notification } from 'antd';
12
+ import { ApiResponse } from '../types';
12
13
 
13
- function HeaderSection() {
14
+ function HeaderSection({ callUnresolvedTaskApi }: any) {
14
15
  const [dataArray] = useSingleFlagData();
15
16
  const [forResolvedPayload, setPayload] = useResolvedPayload();
16
17
  const [, setCurrentAction] = useCurrentAction();
17
- const updateFlag = useUpdateFlag();
18
- const fetchData = useFetchUnresolvedTasks();
19
18
  const [isModalOpen, setIsModalOpen] = useState(false);
20
19
 
20
+ //flag PUT API
21
+ const { fetchData: callFlagUpdateAPI } = useAxios<{
22
+ data: ApiResponse[];
23
+ }>({
24
+ endpoint: `/tasks/update/`,
25
+ method: 'PUT',
26
+ });
27
+
21
28
  useEffect(() => {
22
29
  if (dataArray) {
23
30
  setPayload({
@@ -37,10 +44,28 @@ function HeaderSection() {
37
44
  };
38
45
 
39
46
  const saveButton = async () => {
40
- await updateFlag([forResolvedPayload]);
41
- await fetchData();
42
- setIsModalOpen(false); // Close modal after API call
43
- onCancel()
47
+ let response = (await callFlagUpdateAPI({
48
+ payload: [forResolvedPayload],
49
+ })) as {
50
+ code: number | null;
51
+ error?: string | null | undefined;
52
+ [key: string]: any;
53
+ };
54
+ if (response.code == 200 && response.data) {
55
+ notification.success({
56
+ message: 'Success',
57
+ description: `${response?.message}`,
58
+ });
59
+ setIsModalOpen(false); // Close modal after API call
60
+ setCurrentAction(undefined);
61
+ await callUnresolvedTaskApi();
62
+ }
63
+ if (response?.code == null && response.error) {
64
+ return notification.error({
65
+ message: 'Failure',
66
+ description: `${response?.error}`,
67
+ });
68
+ }
44
69
  };
45
70
 
46
71
  const onCancel = () => {
@@ -3,6 +3,7 @@ import styled from 'styled-components';
3
3
  import {
4
4
  BackgroundModal,
5
5
  useApiHook,
6
+ useAxios,
6
7
  } from '@bjsdistribution/dms-component-library';
7
8
  import HeaderSection from './Header';
8
9
  import TextSection from './TextSection';
@@ -13,7 +14,6 @@ import {
13
14
  useCategoryData,
14
15
  useDepartmentData,
15
16
  useFlagRefId,
16
- useFlagsLoading,
17
17
  useSingleFlagData,
18
18
  useSinglePayload,
19
19
  useTaskPriority,
@@ -21,8 +21,6 @@ import {
21
21
  useTaskTypeExtended,
22
22
  } from '../order-actions/store';
23
23
  import DetailSection from './DetailSection';
24
- import Loader from '../../order-daily-overview/header/loader/Loader';
25
- import useFetchSingleFlagsData from '../order-actions/hooks/useFetchSingleFlagData';
26
24
  import { allTypes } from '../order-actions/types';
27
25
 
28
26
  interface ApiResponse {
@@ -36,10 +34,8 @@ interface ApiResponse {
36
34
  function ViewFlag() {
37
35
  const [dataArray, setSingleFlag] = useSingleFlagData();
38
36
  const [flagRefId] = useFlagRefId();
39
- //const [ssoToken] = useSsoToken();
40
- const [loading, setLoading] = useFlagsLoading();
41
37
  const [payload, setPayload] = useSinglePayload();
42
- const fetchData = useFetchSingleFlagsData();
38
+ // const fetchData = useFetchSingleFlagsData();
43
39
  const [staticData, setStaticData] = useAllStaticData();
44
40
  const [, setPriority] = useTaskPriority();
45
41
  const [, setTaskCategory] = useCategoryData();
@@ -47,6 +43,25 @@ function ViewFlag() {
47
43
  const [, setTaskTypeExtended] = useTaskTypeExtended();
48
44
  const [, setDepartmentData] = useDepartmentData();
49
45
 
46
+ //single flag data
47
+ const {
48
+ data: singleFlagData,
49
+ fetchData: fetchedSingleFlagData,
50
+ loading,
51
+ } = useAxios<ApiResponse>({
52
+ endpoint: `/tasks/${flagRefId}`,
53
+ method: 'GET',
54
+ });
55
+
56
+ //Unresolved API
57
+ const { fetchData: callUnresolvedTaskApi } = useAxios<{
58
+ data: ApiResponse[];
59
+ }>({
60
+ endpoint: `/tasks/`,
61
+ method: 'GET',
62
+ pagination: { is_pagination: false },
63
+ });
64
+
50
65
  // API Call
51
66
  const { data: fetchedStaticData } = useApiHook<ApiResponse>({
52
67
  endpoint: `/tasks/getStaticData/all/`,
@@ -72,17 +87,18 @@ function ViewFlag() {
72
87
  }
73
88
  }, [staticData]);
74
89
 
75
- const fetchAndSetSingleFlagData = async () => {
76
- setLoading(true);
77
- const result = await fetchData();
78
- setSingleFlag(result);
79
- setLoading(false);
80
- };
81
-
82
90
  useEffect(() => {
83
- fetchAndSetSingleFlagData();
91
+ if (flagRefId) {
92
+ fetchedSingleFlagData();
93
+ }
84
94
  }, [flagRefId]);
85
95
 
96
+ useEffect(() => {
97
+ if (singleFlagData && singleFlagData?.data) {
98
+ setSingleFlag(singleFlagData?.data[0]);
99
+ }
100
+ }, [loading]);
101
+
86
102
  useEffect(() => {
87
103
  setPayload({
88
104
  ...payload,
@@ -97,19 +113,20 @@ function ViewFlag() {
97
113
 
98
114
  return (
99
115
  <>
100
- <BackgroundModals>
101
- {dataArray && loading && <Loader />}
102
- <MainContainer>
103
- <HeaderSection />
104
- <DetailSection />
105
- <TextSection />
106
- <ButtonsSection />
107
- <SectionsContainer>
108
- <ActionSection />
109
- <RadioButtonsSection />
110
- </SectionsContainer>
111
- </MainContainer>
112
- </BackgroundModals>
116
+ {dataArray && (
117
+ <BackgroundModals>
118
+ <MainContainer>
119
+ <HeaderSection callUnresolvedTaskApi={callUnresolvedTaskApi} />
120
+ <DetailSection />
121
+ <TextSection />
122
+ <ButtonsSection />
123
+ <SectionsContainer>
124
+ <ActionSection callUnresolvedTaskApi={callUnresolvedTaskApi} />
125
+ <RadioButtonsSection />
126
+ </SectionsContainer>
127
+ </MainContainer>
128
+ </BackgroundModals>
129
+ )}
113
130
  </>
114
131
  );
115
132
  }
@@ -6,8 +6,7 @@ import SystemLogs from './system-event-logs/expanded-content';
6
6
  import GeneralHeader from './general-information';
7
7
  import ProductsInfo from './products-info';
8
8
  import OrderActions from './order-actions';
9
- import { useApiHook } from '@bjsdistribution/dms-component-library';
10
-
9
+ import { useApiHook, useAxios } from '@bjsdistribution/dms-component-library';
11
10
  import {
12
11
  useOrderDetails,
13
12
  useOrderStaticData,
@@ -16,7 +15,6 @@ import {
16
15
  useDepotOptions,
17
16
  usePrevOrderDetails,
18
17
  useOrderProductsResources,
19
- // useOrderProductsToolbox,
20
18
  useCustomerInfo,
21
19
  useLocationOptions,
22
20
  useOrderProductSystemLogs,
@@ -31,9 +29,7 @@ import {
31
29
  } from './store';
32
30
  import { OrdersType } from './types';
33
31
  import { useLocation } from 'react-router-dom';
34
- import useSystemLogs from './hooks/useGetSystemLogs';
35
32
  import { notification } from 'antd';
36
- // import { useAssignData } from '../store';
37
33
  import DetailsFilters from './details-filters/DetailsFilters';
38
34
  import { useSubContracterData, useVisibilityData } from '../store';
39
35
  import Notification from './notification';
@@ -65,22 +61,41 @@ function OrderView() {
65
61
  const [, setCustomerInfo] = useCustomerInfo();
66
62
  const [, setLocationOptions] = useLocationOptions();
67
63
  const [orderResources, setOrderResources] = useOrderProductsResources();
68
- // const [orderToolbox, setOrderToolbox] = useOrderProductsToolbox();
69
64
  const [GsitCUstomerId, setGsitCUstomerId] = useGsitCUstomerId();
70
65
  const [, setOrderProductId] = useOrderProductId();
71
66
  const [, setCUstomerId] = useCUstomerId();
72
67
  const [, setRouteId] = useRouteId();
73
68
  const [liveRecalling] = useLiveRecalling();
74
- const systemLogsData = useSystemLogs();
75
69
  const [, setVisibilityData] = useVisibilityData();
76
70
  const [, setSubContracterData] = useSubContracterData();
77
71
  const [recallOrders] = useGlobalStateHitOrder();
78
72
  const [, setStatusVal] = useAllOrderStatus();
73
+ const gsitId = orderDetails?.gsit_order_id;
79
74
 
80
75
  useEffect(() => {
81
76
  setStatusVal(orderDetails?.status_value);
82
77
  }, [orderDetails?.status_value]);
83
78
 
79
+ //get system event logs
80
+ const {
81
+ data: fetchedSystemLogsData,
82
+ fetchData: callSystemLogsAPI,
83
+ loading: logsLoading,
84
+ } = useAxios<{
85
+ data: any[];
86
+ }>({
87
+ endpoint: `/events/get/event/`,
88
+ method: 'GET',
89
+ pagination: { page: 1, per_page: 100 },
90
+ filters: [
91
+ {
92
+ field: 'object_id',
93
+ op: '=',
94
+ value: `${gsitId}`,
95
+ },
96
+ ],
97
+ });
98
+
84
99
  // query param
85
100
  const location = useLocation();
86
101
  const [filters, setFilters] = useState<
@@ -131,7 +146,6 @@ function OrderView() {
131
146
  }
132
147
  } else {
133
148
  const paths = location.pathname.split('/');
134
- console.log(paths[paths.length - 1], 'paths');
135
149
  setOrderId(paths[paths.length - 1]);
136
150
  }
137
151
  }, [location.search, loadingExternal]);
@@ -359,25 +373,23 @@ function OrderView() {
359
373
  setLocationOptions(locationOptions);
360
374
  }
361
375
  }, [dataLoading]);
362
- let gsitId = orderDetails?.gsit_order_id;
363
376
  const [, setSystemLogsEvents] = useOrderProductSystemLogs();
364
377
 
365
- const fetchReminderData = async () => {
366
- const result = await systemLogsData();
367
- setSystemLogsEvents(result);
368
- };
378
+ useEffect(() => {
379
+ if (fetchedSystemLogsData && fetchedSystemLogsData?.data) {
380
+ setSystemLogsEvents(fetchedSystemLogsData?.data);
381
+ }
382
+ }, [logsLoading]);
369
383
 
370
384
  useEffect(() => {
371
385
  if (gsitOrderId) {
372
- fetchReminderData();
386
+ callSystemLogsAPI();
373
387
  }
374
388
  return () => {
375
389
  setGsitOrderId(undefined);
376
390
  };
377
391
  }, [gsitId]);
378
392
 
379
- console.log(orderId, 'orderId');
380
-
381
393
  const { data: fetchedSubcontractotData, loading: apiLoading } = useApiHook<{
382
394
  data: ApiResponse[];
383
395
  }>({
@@ -1,33 +1,35 @@
1
1
  import {
2
2
  Button,
3
3
  Label,
4
+ useAxios,
4
5
  // SelectDropdown,
5
6
  } from '@bjsdistribution/dms-component-library';
6
7
  import React, { useEffect, useState } from 'react';
7
8
  import styled from 'styled-components';
8
- // import NoteType from './NoteType';
9
- import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
10
- import { getCookie } from '../utils';
11
9
  import { useLocation } from 'react-router-dom';
12
10
  import { useGlobalStateHitAuditLog, usemoduleIds, useOrderId } from '../store';
13
11
  import { notification } from 'antd';
14
12
  import NoteType from './NoteType';
15
13
  import { useSelectedData } from '../../store';
14
+ import { ApiResponse } from '../types';
16
15
 
17
16
  function AddNote() {
18
17
  const [noteText, setNoteText] = useState('');
19
18
  const [orderId] = useOrderId();
20
-
21
19
  const location = useLocation();
22
20
  const pathname = location.pathname;
23
21
  const orderIdLocaation = pathname.split('/')[1];
24
-
25
- const ssoToken = getCookie('id_token');
26
22
  const [moduleIds] = usemoduleIds();
27
23
  const [, setRecallAuditLog] = useGlobalStateHitAuditLog();
28
24
  const [selected] = useSelectedData();
29
25
 
30
26
  // Save New Note
27
+ const { fetchData: callAuditLogs } = useAxios<{
28
+ data: ApiResponse[];
29
+ }>({
30
+ endpoint: `/audit_logs/orders/`,
31
+ method: 'POST',
32
+ });
31
33
 
32
34
  const [notificationData, setNotificationData] = useState<{
33
35
  type: 'success' | 'error';
@@ -38,7 +40,6 @@ function AddNote() {
38
40
  const saveNote = async () => {
39
41
  setRecallAuditLog(false);
40
42
  if (!noteText) return;
41
- const endpoint = `${getBaseEndpoint()}/audit_logs/orders/`;
42
43
  const payload = {
43
44
  audit_logs: [
44
45
  {
@@ -54,30 +55,25 @@ function AddNote() {
54
55
  },
55
56
  ],
56
57
  };
57
-
58
58
  try {
59
- const response = await fetch(endpoint, {
60
- method: 'POST',
61
- headers: {
62
- 'Content-Type': 'application/json',
63
- Authorization: `Bearer ${ssoToken}`,
64
- },
65
- body: JSON.stringify(payload),
66
- });
67
-
68
- // setNoteLoadingStore(false);
69
-
70
- if (response.ok) {
59
+ let response = (await callAuditLogs({
60
+ payload: payload,
61
+ })) as {
62
+ code: number | null;
63
+ error?: string | null | undefined;
64
+ [key: string]: any;
65
+ };
66
+ if (response.code == 200 && response?.data) {
71
67
  notification.success({
72
68
  message: 'Success',
73
- description: 'Note saved successfully.',
69
+ description: `${response?.message}`,
74
70
  });
75
71
  setNoteText('');
76
72
  setRecallAuditLog(true);
77
73
  } else {
78
74
  notification.error({
79
75
  message: 'Error',
80
- description: 'Failed to save note.',
76
+ description: `${response?.error}`,
81
77
  });
82
78
  }
83
79
  } catch (error) {