@bjsdistribution/dms-client-return 0.0.88 → 0.0.90

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 (56) hide show
  1. package/dist/assets/icons/DownloadIcon.d.ts +3 -0
  2. package/dist/components/order-view/flags-action-modal/Actions.d.ts +1 -1
  3. package/dist/components/order-view/flags-action-modal/Header.d.ts +1 -1
  4. package/dist/dms-client-return.cjs.development.js +1169 -1904
  5. package/dist/dms-client-return.cjs.development.js.map +1 -1
  6. package/dist/dms-client-return.cjs.production.min.js +1 -1
  7. package/dist/dms-client-return.cjs.production.min.js.map +1 -1
  8. package/dist/dms-client-return.esm.js +1171 -1906
  9. package/dist/dms-client-return.esm.js.map +1 -1
  10. package/package.json +2 -2
  11. package/src/assets/icons/DownloadIcon.tsx +36 -0
  12. package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +0 -3
  13. package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +1 -4
  14. package/src/components/order-daily-overview/table/ReturnTable.tsx +0 -2
  15. package/src/components/order-view/flags-action-modal/Actions.tsx +33 -17
  16. package/src/components/order-view/flags-action-modal/Header.tsx +34 -9
  17. package/src/components/order-view/flags-action-modal/index.tsx +44 -27
  18. package/src/components/order-view/index.tsx +28 -16
  19. package/src/components/order-view/notes/AddNote.tsx +1 -1
  20. package/src/components/order-view/notification/index.tsx +42 -15
  21. package/src/components/order-view/order-actions/actions/add-resources/index.tsx +40 -11
  22. package/src/components/order-view/order-actions/actions/confirm-order/index.tsx +17 -5
  23. package/src/components/order-view/order-actions/actions/create-task-reminder/CreateTaskModal.tsx +0 -4
  24. package/src/components/order-view/order-actions/actions/create-task-reminder/TaskModal.tsx +54 -14
  25. package/src/components/order-view/order-actions/actions/create-task-reminder/index.tsx +57 -22
  26. package/src/components/order-view/order-actions/actions/order-lock/index.tsx +34 -9
  27. package/src/components/order-view/order-details/expanded-content/footer/index.tsx +22 -5
  28. package/src/components/order-view/order-details/expanded-content/orders-section/DeliveryDate.tsx +2 -4
  29. package/src/components/order-view/order-resources/columns/actions/index.tsx +3 -3
  30. package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +1 -7
  31. package/src/components/order-view/system-event-logs/expanded-content/index.tsx +23 -26
  32. package/src/components/order-view/view-reminder/ViewReminder.tsx +157 -118
  33. package/dist/components/order-view/hooks/AddResources.d.ts +0 -2
  34. package/dist/components/order-view/hooks/useGetEventNotes.d.ts +0 -2
  35. package/dist/components/order-view/hooks/useGetSystemLogs.d.ts +0 -2
  36. package/dist/components/order-view/hooks/useUpdateOrder.d.ts +0 -2
  37. package/dist/components/order-view/order-actions/hooks/useAllReminderData.d.ts +0 -2
  38. package/dist/components/order-view/order-actions/hooks/useAllTaskData.d.ts +0 -2
  39. package/dist/components/order-view/order-actions/hooks/useCreateReminder.d.ts +0 -3
  40. package/dist/components/order-view/order-actions/hooks/useCreateTask.d.ts +0 -3
  41. package/dist/components/order-view/order-actions/hooks/useFetchSingleFlagData.d.ts +0 -2
  42. package/dist/components/order-view/order-actions/hooks/useFetchSingleReminder.d.ts +0 -2
  43. package/dist/components/order-view/order-actions/hooks/useUpdateFlag.d.ts +0 -3
  44. package/dist/components/order-view/order-actions/hooks/useUpdateReminder.d.ts +0 -3
  45. package/src/components/order-view/hooks/AddResources.tsx +0 -54
  46. package/src/components/order-view/hooks/useGetEventNotes.tsx +0 -60
  47. package/src/components/order-view/hooks/useGetSystemLogs.tsx +0 -71
  48. package/src/components/order-view/hooks/useUpdateOrder.ts +0 -62
  49. package/src/components/order-view/order-actions/hooks/useAllReminderData.ts +0 -70
  50. package/src/components/order-view/order-actions/hooks/useAllTaskData.ts +0 -72
  51. package/src/components/order-view/order-actions/hooks/useCreateReminder.ts +0 -58
  52. package/src/components/order-view/order-actions/hooks/useCreateTask.ts +0 -58
  53. package/src/components/order-view/order-actions/hooks/useFetchSingleFlagData.ts +0 -58
  54. package/src/components/order-view/order-actions/hooks/useFetchSingleReminder.ts +0 -56
  55. package/src/components/order-view/order-actions/hooks/useUpdateFlag.ts +0 -54
  56. 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.88",
2
+ "version": "0.0.90",
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.78",
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",
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+
3
+ export const DownloadIcon = () => {
4
+ return (
5
+ <svg
6
+ width="21"
7
+ height="21"
8
+ viewBox="0 0 21 21"
9
+ fill="none"
10
+ xmlns="http://www.w3.org/2000/svg"
11
+ >
12
+ <g id="icon/import">
13
+ <rect
14
+ width="20"
15
+ height="20"
16
+ transform="translate(0.5 0.243164)"
17
+ fill="white"
18
+ />
19
+ <path
20
+ id="Vector"
21
+ opacity="0.6"
22
+ d="M5.12684 17.7165C4.83921 17.7084 4.55614 17.6426 4.29443 17.523C4.03273 17.4034 3.79774 17.2324 3.60341 17.0202C3.40908 16.808 3.25938 16.5589 3.16319 16.2877C3.06701 16.0165 3.02631 15.7287 3.04351 15.4415C3.03351 13.6473 3.04351 11.8532 3.04351 10.059C3.04351 9.94849 3.08741 9.84251 3.16555 9.76437C3.24369 9.68623 3.34967 9.64233 3.46017 9.64233C3.57068 9.64233 3.67666 9.68623 3.7548 9.76437C3.83294 9.84251 3.87684 9.94849 3.87684 10.059C3.87684 11.8923 3.85017 13.7257 3.87684 15.559C3.89017 16.4815 4.58351 16.8832 5.40851 16.8832H15.7943C16.0566 16.8896 16.3146 16.8158 16.5338 16.6717C16.753 16.5275 16.923 16.3199 17.021 16.0765C17.1009 15.789 17.1291 15.4897 17.1043 15.1923V10.059C17.1043 9.94849 17.1482 9.84251 17.2264 9.76437C17.3045 9.68623 17.4105 9.64233 17.521 9.64233C17.6315 9.64233 17.7375 9.68623 17.8156 9.76437C17.8938 9.84251 17.9377 9.94849 17.9377 10.059C17.9377 11.9123 18.0085 13.7798 17.9377 15.6315C17.9305 15.9151 17.867 16.1944 17.7509 16.4532C17.6348 16.7119 17.4683 16.9451 17.2613 17.1389C17.0542 17.3328 16.8107 17.4836 16.5448 17.5824C16.279 17.6813 15.9961 17.7263 15.7127 17.7148L5.12684 17.7165Z"
23
+ fill="#3A3630"
24
+ />
25
+ <path
26
+ id="Vector_2"
27
+ opacity="0.6"
28
+ d="M10.1916 13.4248C10.2602 13.4951 10.3533 13.5363 10.4516 13.5398C10.4632 13.5398 10.4741 13.5439 10.4866 13.5448C10.4991 13.5456 10.5091 13.5448 10.5207 13.5398C10.619 13.5364 10.7121 13.4952 10.7807 13.4248L13.8382 10.3673C13.9141 10.2887 13.9561 10.1834 13.9552 10.0742C13.9542 9.96495 13.9104 9.86044 13.8331 9.78319C13.7559 9.70594 13.6514 9.66212 13.5421 9.66117C13.4329 9.66022 13.3276 9.70222 13.2491 9.77812L10.9032 12.1239V3.17228C10.9032 3.06178 10.8593 2.95579 10.7812 2.87765C10.703 2.79951 10.5971 2.75562 10.4866 2.75562C10.376 2.75562 10.2701 2.79951 10.1919 2.87765C10.1138 2.95579 10.0699 3.06178 10.0699 3.17228V12.1239L7.72322 9.77812C7.64464 9.70222 7.53938 9.66022 7.43014 9.66117C7.32089 9.66212 7.21638 9.70594 7.13913 9.78319C7.06188 9.86044 7.01805 9.96495 7.01711 10.0742C7.01616 10.1834 7.05815 10.2887 7.13405 10.3673L10.1916 13.4248Z"
29
+ fill="#3A3630"
30
+ />
31
+ </g>
32
+ </svg>
33
+ );
34
+ };
35
+
36
+ export default DownloadIcon;
@@ -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
  }>({
@@ -54,7 +54,7 @@ function AddNote() {
54
54
  },
55
55
  ],
56
56
  };
57
-
57
+ //to change
58
58
  try {
59
59
  const response = await fetch(endpoint, {
60
60
  method: 'POST',
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  SectionHeader,
3
3
  useApiHook,
4
+ useAxios,
4
5
  } from '@bjsdistribution/dms-component-library';
5
6
  import React, { useEffect, useState } from 'react';
6
7
  import Tabs from './Tabs';
7
8
  import styled from 'styled-components';
8
9
  import { useInfoType, useOrderDetails, useTabType } from '../store';
9
10
  import NotifyFlag from '../../../assets/icons/NotifyFlag';
10
- import useFetchUnresolvedTasks from '../order-actions/hooks/useAllTaskData';
11
11
  import {
12
12
  useNotificationData,
13
13
  useOrderNotify,
@@ -15,7 +15,6 @@ import {
15
15
  useRouteDetails,
16
16
  useTaskLoading,
17
17
  } from '../order-actions/store';
18
- import useFetchReminders from '../order-actions/hooks/useAllReminderData';
19
18
 
20
19
  interface ApiResponse {
21
20
  message: string;
@@ -29,8 +28,6 @@ interface ApiResponse {
29
28
  function Notification() {
30
29
  const [activeTab, setActiveTab] = useTabType();
31
30
  const [, setShowMoreInfo] = useInfoType();
32
- const TaskData = useFetchUnresolvedTasks();
33
- const ReminderData = useFetchReminders();
34
31
  const [OrderData] = useOrderDetails();
35
32
  const [notificationData, setNotififcationData] = useNotificationData();
36
33
  const [flagLoading] = useTaskLoading();
@@ -43,22 +40,52 @@ function Notification() {
43
40
  const [activeReminders, setActiveReminders] = useState([]);
44
41
  const [closedReminders, setCloseReminders] = useState([]);
45
42
 
43
+ //Unresolved API
44
+ const {
45
+ data: fetchedUnresolvedData,
46
+ loading: unresolvedLoading,
47
+ fetchData: callUnresolvedTaskApi,
48
+ } = useAxios<{
49
+ data: ApiResponse[];
50
+ }>({
51
+ endpoint: `/tasks/`,
52
+ method: 'GET',
53
+ pagination: { is_pagination: false },
54
+ filters: [{ field: 'order_id', op: '=', value: OrderData.id }],
55
+ });
56
+
57
+ //reminder get
58
+ const {
59
+ data: fetchedReminderData,
60
+ loading: reminderLoading,
61
+ fetchData: callReminderApi,
62
+ } = useAxios<{
63
+ data: ApiResponse[];
64
+ }>({
65
+ endpoint: `/tasks/reminder/get/`,
66
+ method: 'GET',
67
+ pagination: { is_pagination: false },
68
+ filters: [{ field: 'order_id', op: '=', value: OrderData.id }],
69
+ });
70
+
46
71
  const handleTabChange = (tab: string) => {
47
72
  setActiveTab(tab);
48
73
  setShowMoreInfo(false);
49
74
  };
50
75
 
51
76
  //flags notification data
52
- const fetchTaskData = async () => {
53
- const result = await TaskData();
54
- setNotififcationData(result);
55
- };
77
+ useEffect(() => {
78
+ if (fetchedUnresolvedData && fetchedUnresolvedData?.data) {
79
+ setNotififcationData(fetchedUnresolvedData?.data);
80
+ }
81
+ }, [unresolvedLoading]);
56
82
 
57
- //reminder noitification
58
- const fetchReminderData = async () => {
59
- const result = await ReminderData();
60
- setReminderData(result);
61
- };
83
+ //reminder data set
84
+ useEffect(() => {
85
+ if (fetchedReminderData && fetchedReminderData?.data) {
86
+ setReminderData(fetchedReminderData?.data);
87
+ }
88
+ }, [reminderLoading]);
62
89
 
63
90
  //route API calling...
64
91
  const { data: fetchedData, setShouldPerformAction } = useApiHook<{
@@ -71,8 +98,8 @@ function Notification() {
71
98
 
72
99
  useEffect(() => {
73
100
  if (OrderData.id) {
74
- fetchTaskData();
75
- fetchReminderData();
101
+ callReminderApi();
102
+ callUnresolvedTaskApi();
76
103
  }
77
104
  }, [OrderData.id]);
78
105