@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.
- package/dist/components/order-view/flags-action-modal/Actions.d.ts +1 -1
- package/dist/components/order-view/flags-action-modal/Header.d.ts +1 -1
- package/dist/dms-client-return.cjs.development.js +1166 -1927
- package/dist/dms-client-return.cjs.development.js.map +1 -1
- package/dist/dms-client-return.cjs.production.min.js +1 -1
- package/dist/dms-client-return.cjs.production.min.js.map +1 -1
- package/dist/dms-client-return.esm.js +1168 -1929
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +0 -3
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +1 -4
- package/src/components/order-daily-overview/table/ReturnTable.tsx +0 -2
- package/src/components/order-view/flags-action-modal/Actions.tsx +33 -17
- package/src/components/order-view/flags-action-modal/Header.tsx +34 -9
- package/src/components/order-view/flags-action-modal/index.tsx +44 -27
- package/src/components/order-view/index.tsx +28 -16
- package/src/components/order-view/notes/AddNote.tsx +18 -22
- package/src/components/order-view/notification/index.tsx +76 -56
- package/src/components/order-view/order-actions/actions/add-resources/index.tsx +40 -11
- package/src/components/order-view/order-actions/actions/confirm-order/index.tsx +17 -5
- package/src/components/order-view/order-actions/actions/create-task-reminder/CreateTaskModal.tsx +0 -4
- package/src/components/order-view/order-actions/actions/create-task-reminder/TaskModal.tsx +54 -14
- package/src/components/order-view/order-actions/actions/create-task-reminder/index.tsx +57 -22
- package/src/components/order-view/order-actions/actions/order-lock/index.tsx +34 -9
- package/src/components/order-view/order-details/expanded-content/footer/index.tsx +22 -5
- package/src/components/order-view/order-resources/columns/actions/index.tsx +1 -1
- package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +1 -7
- package/src/components/order-view/system-event-logs/expanded-content/index.tsx +23 -26
- package/src/components/order-view/view-reminder/ViewReminder.tsx +157 -118
- package/dist/components/order-view/hooks/AddResources.d.ts +0 -2
- package/dist/components/order-view/hooks/useGetEventNotes.d.ts +0 -2
- package/dist/components/order-view/hooks/useGetSystemLogs.d.ts +0 -2
- package/dist/components/order-view/hooks/useUpdateOrder.d.ts +0 -2
- package/dist/components/order-view/order-actions/hooks/useAllReminderData.d.ts +0 -2
- package/dist/components/order-view/order-actions/hooks/useAllTaskData.d.ts +0 -2
- package/dist/components/order-view/order-actions/hooks/useCreateReminder.d.ts +0 -3
- package/dist/components/order-view/order-actions/hooks/useCreateTask.d.ts +0 -3
- package/dist/components/order-view/order-actions/hooks/useFetchSingleFlagData.d.ts +0 -2
- package/dist/components/order-view/order-actions/hooks/useFetchSingleReminder.d.ts +0 -2
- package/dist/components/order-view/order-actions/hooks/useUpdateFlag.d.ts +0 -3
- package/dist/components/order-view/order-actions/hooks/useUpdateReminder.d.ts +0 -3
- package/src/components/order-view/hooks/AddResources.tsx +0 -54
- package/src/components/order-view/hooks/useGetEventNotes.tsx +0 -60
- package/src/components/order-view/hooks/useGetSystemLogs.tsx +0 -71
- package/src/components/order-view/hooks/useUpdateOrder.ts +0 -62
- package/src/components/order-view/order-actions/hooks/useAllReminderData.ts +0 -70
- package/src/components/order-view/order-actions/hooks/useAllTaskData.ts +0 -72
- package/src/components/order-view/order-actions/hooks/useCreateReminder.ts +0 -58
- package/src/components/order-view/order-actions/hooks/useCreateTask.ts +0 -58
- package/src/components/order-view/order-actions/hooks/useFetchSingleFlagData.ts +0 -58
- package/src/components/order-view/order-actions/hooks/useFetchSingleReminder.ts +0 -56
- package/src/components/order-view/order-actions/hooks/useUpdateFlag.ts +0 -54
- package/src/components/order-view/order-actions/hooks/useUpdateReminder.ts +0 -52
|
@@ -1,21 +1,20 @@
|
|
|
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,
|
|
14
14
|
useReminderNotiData,
|
|
15
15
|
useRouteDetails,
|
|
16
|
-
useTaskLoading,
|
|
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,11 +28,9 @@ 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
|
-
const [flagLoading] = useTaskLoading();
|
|
33
|
+
// const [flagLoading] = useTaskLoading();
|
|
37
34
|
const [reminderData, setReminderData] = useReminderNotiData();
|
|
38
35
|
const routeId = OrderData?.order_routes?.route_id;
|
|
39
36
|
const [, setRouteData] = useRouteDetails();
|
|
@@ -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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
if (fetchedUnresolvedData && fetchedUnresolvedData?.data) {
|
|
79
|
+
setNotififcationData(fetchedUnresolvedData?.data);
|
|
80
|
+
}
|
|
81
|
+
}, [unresolvedLoading]);
|
|
56
82
|
|
|
57
|
-
//reminder
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
75
|
-
|
|
101
|
+
callReminderApi();
|
|
102
|
+
callUnresolvedTaskApi();
|
|
76
103
|
}
|
|
77
104
|
}, [OrderData.id]);
|
|
78
105
|
|
|
@@ -154,14 +181,7 @@ function Notification() {
|
|
|
154
181
|
</StyledTab>
|
|
155
182
|
</TabsData>
|
|
156
183
|
</Container>
|
|
157
|
-
{
|
|
158
|
-
<Loader>
|
|
159
|
-
<Spinner />
|
|
160
|
-
<Text>Fetching Notifications...</Text>
|
|
161
|
-
</Loader>
|
|
162
|
-
) : notificationData.length > 0 ||
|
|
163
|
-
reminderData.length > 0 ||
|
|
164
|
-
OrderData ? (
|
|
184
|
+
{notificationData.length > 0 || reminderData.length > 0 || OrderData ? (
|
|
165
185
|
<TabsWrapper>
|
|
166
186
|
<Tabs
|
|
167
187
|
activeNotifications={activeNotifications}
|
|
@@ -188,31 +208,31 @@ const Container = styled.div`
|
|
|
188
208
|
border-bottom: 1px solid #ccc;
|
|
189
209
|
`;
|
|
190
210
|
|
|
191
|
-
const Loader = styled.div`
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
`;
|
|
211
|
+
// const Loader = styled.div`
|
|
212
|
+
// align-items: center;
|
|
213
|
+
// justify-content: center;
|
|
214
|
+
// display: flex;
|
|
215
|
+
// flex-direction: column;
|
|
216
|
+
// gap: 10px;
|
|
217
|
+
// `;
|
|
198
218
|
|
|
199
|
-
const Spinner = styled.div`
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
`;
|
|
219
|
+
// const Spinner = styled.div`
|
|
220
|
+
// border: 4px solid rgba(0, 0, 0, 0.1);
|
|
221
|
+
// border-left-color: #3a3630;
|
|
222
|
+
// border-radius: 50%;
|
|
223
|
+
// width: 40px;
|
|
224
|
+
// height: 40px;
|
|
225
|
+
// animation: spin 1s linear infinite;
|
|
226
|
+
|
|
227
|
+
// @keyframes spin {
|
|
228
|
+
// 0% {
|
|
229
|
+
// transform: rotate(0deg);
|
|
230
|
+
// }
|
|
231
|
+
// 100% {
|
|
232
|
+
// transform: rotate(360deg);
|
|
233
|
+
// }
|
|
234
|
+
// }
|
|
235
|
+
// `;
|
|
216
236
|
|
|
217
237
|
const FlagContainer = styled.div`
|
|
218
238
|
padding: 8px;
|
|
@@ -299,11 +319,11 @@ const TabsWrapper = styled.div`
|
|
|
299
319
|
}
|
|
300
320
|
`;
|
|
301
321
|
|
|
302
|
-
const Text = styled.div`
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
`;
|
|
322
|
+
// const Text = styled.div`
|
|
323
|
+
// color: var(--tonal-brown-651, #6a7378);
|
|
324
|
+
// font-family: Lato;
|
|
325
|
+
// font-size: 13px;
|
|
326
|
+
// font-style: normal;
|
|
327
|
+
// font-weight: 600;
|
|
328
|
+
// `;
|
|
309
329
|
export default Notification;
|
|
@@ -9,29 +9,33 @@ import {
|
|
|
9
9
|
useAtom,
|
|
10
10
|
useCurrentAction,
|
|
11
11
|
useCustomerInfo,
|
|
12
|
+
useOrderId,
|
|
12
13
|
useOrderStaticData,
|
|
13
14
|
} from '../../../store';
|
|
14
15
|
import {
|
|
15
16
|
selectedCategoryIdAtom,
|
|
16
17
|
selectedDocumentTypeAtom,
|
|
17
18
|
selectedTypeAtom,
|
|
19
|
+
selectedVisibilityAtom,
|
|
18
20
|
setResourcesCall,
|
|
19
21
|
} from '../../store';
|
|
20
22
|
import OrderActionsDropdown from '../../Dropdown';
|
|
21
23
|
import { notification } from 'antd';
|
|
22
|
-
import
|
|
24
|
+
import { ApiResponse } from '../../../types';
|
|
25
|
+
import { useAxios } from '@bjsdistribution/dms-component-library';
|
|
23
26
|
|
|
24
27
|
function AddResources() {
|
|
25
28
|
const [, setCurrentAction] = useCurrentAction();
|
|
26
29
|
const [staticOrderData] = useOrderStaticData();
|
|
27
30
|
const [, setSelectedType] = useAtom(selectedTypeAtom);
|
|
28
31
|
const [uploadedFiles, setUploadedFiles] = useAtom(uploadedFilesAtom);
|
|
29
|
-
const uploadFiles = useUploadFiles();
|
|
30
32
|
const [isFormValid, setIsFormValid] = useState(false);
|
|
31
33
|
const [selectedCategoryId] = useAtom(selectedCategoryIdAtom);
|
|
32
34
|
const [selectedDocumentType] = useAtom(selectedDocumentTypeAtom);
|
|
33
35
|
const [selectedType] = useAtom(selectedTypeAtom);
|
|
34
36
|
const [, setResources] = useAtom(setResourcesCall);
|
|
37
|
+
const [orderId] = useOrderId();
|
|
38
|
+
const [selectedVisibility] = useAtom(selectedVisibilityAtom);
|
|
35
39
|
|
|
36
40
|
const onClose = () => {
|
|
37
41
|
setCurrentAction(undefined);
|
|
@@ -54,6 +58,17 @@ function AddResources() {
|
|
|
54
58
|
setSelectedType(selectedOption.value);
|
|
55
59
|
}
|
|
56
60
|
};
|
|
61
|
+
|
|
62
|
+
// upload files
|
|
63
|
+
const { fetchData: callUploadFile } = useAxios<{
|
|
64
|
+
data: ApiResponse[];
|
|
65
|
+
}>({
|
|
66
|
+
endpoint: `/orders/${orderId}/order_resources/?document_type=${selectedDocumentType}&type=${selectedType}&category=${selectedCategoryId}&visibility=${selectedVisibility}`,
|
|
67
|
+
method: 'POST',
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
//upload files
|
|
71
|
+
|
|
57
72
|
const handleSubmit = async () => {
|
|
58
73
|
if (!uploadedFiles) {
|
|
59
74
|
notification.error({ message: 'No files selected' });
|
|
@@ -68,15 +83,29 @@ function AddResources() {
|
|
|
68
83
|
}
|
|
69
84
|
|
|
70
85
|
try {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
86
|
+
let response = (await callUploadFile({
|
|
87
|
+
payload: formData,
|
|
88
|
+
})) as {
|
|
89
|
+
code: number | null;
|
|
90
|
+
error?: string | null | undefined;
|
|
91
|
+
[key: string]: any;
|
|
92
|
+
};
|
|
93
|
+
if (response?.code == 200 && response?.data?.length > 0) {
|
|
94
|
+
notification.success({
|
|
95
|
+
message: 'Success',
|
|
96
|
+
description: `${response?.message}`,
|
|
97
|
+
});
|
|
98
|
+
onClose(); // Close modal after successful upload
|
|
99
|
+
setResources(false);
|
|
100
|
+
setTimeout(() => {
|
|
101
|
+
setResources(true);
|
|
102
|
+
}, 1000);
|
|
103
|
+
} else {
|
|
104
|
+
notification.error({
|
|
105
|
+
message: 'Error',
|
|
106
|
+
description: `${response?.error}`,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
80
109
|
} catch (error) {
|
|
81
110
|
console.error('Upload failed:', error);
|
|
82
111
|
}
|
|
@@ -5,7 +5,7 @@ import CustomerInformation from './customer-info';
|
|
|
5
5
|
import ProductTable from './tables/ProductTable';
|
|
6
6
|
import NotesTable from './tables/NotesTable';
|
|
7
7
|
import SlotAndInstructions from './slot-and-instructions';
|
|
8
|
-
import { useApiHook } from '@bjsdistribution/dms-component-library';
|
|
8
|
+
import { useApiHook, useAxios } from '@bjsdistribution/dms-component-library';
|
|
9
9
|
import {
|
|
10
10
|
useCurrentAction,
|
|
11
11
|
useCustomerInfo,
|
|
@@ -23,9 +23,7 @@ import {
|
|
|
23
23
|
import { ApiResponse } from '../../../types';
|
|
24
24
|
import { notification } from 'antd';
|
|
25
25
|
import { compareOrderDetailsStates, filterObject } from '../../../utils';
|
|
26
|
-
import useUpdateOrder from '../../../hooks/useUpdateOrder';
|
|
27
26
|
import { format } from 'date-fns';
|
|
28
|
-
// import { filterObject } from '../../../utils';
|
|
29
27
|
|
|
30
28
|
function ConfirmOrder() {
|
|
31
29
|
const [, setCurrentAction] = useCurrentAction();
|
|
@@ -41,13 +39,21 @@ function ConfirmOrder() {
|
|
|
41
39
|
const [, setRecalling] = useLiveRecalling();
|
|
42
40
|
const [orderId] = useOrderId();
|
|
43
41
|
const [errorState] = useErrorConfirmOrder();
|
|
44
|
-
const updateOrder = useUpdateOrder();
|
|
42
|
+
// const updateOrder = useUpdateOrder();
|
|
45
43
|
const [, setRecallOrders] = useGlobalStateHitOrder();
|
|
46
44
|
|
|
47
45
|
const onClose = () => {
|
|
48
46
|
setCurrentAction(undefined);
|
|
49
47
|
};
|
|
50
48
|
|
|
49
|
+
//update Order API
|
|
50
|
+
const { fetchData: callUpdateOrderAPI } = useAxios<{
|
|
51
|
+
data: ApiResponse[];
|
|
52
|
+
}>({
|
|
53
|
+
endpoint: `/orders/update/`,
|
|
54
|
+
method: 'PUT',
|
|
55
|
+
});
|
|
56
|
+
|
|
51
57
|
useEffect(() => {
|
|
52
58
|
const clone = JSON.parse(JSON.stringify(orderDetails));
|
|
53
59
|
setOrderDetailsConfirmOrder(clone);
|
|
@@ -129,7 +135,13 @@ function ConfirmOrder() {
|
|
|
129
135
|
|
|
130
136
|
const notUpdateOrder = hasOnlyIdKey(payload);
|
|
131
137
|
if (!notUpdateOrder) {
|
|
132
|
-
|
|
138
|
+
let response = (await callUpdateOrderAPI({
|
|
139
|
+
payload: [payload],
|
|
140
|
+
})) as {
|
|
141
|
+
code: number | null;
|
|
142
|
+
error?: string | null | undefined;
|
|
143
|
+
[key: string]: any;
|
|
144
|
+
};
|
|
133
145
|
if (response && response?.data?.length > 0) {
|
|
134
146
|
setOrderDetails(response?.data[0]);
|
|
135
147
|
setPrevOrderDetails(response?.data[0]);
|
package/src/components/order-view/order-actions/actions/create-task-reminder/CreateTaskModal.tsx
CHANGED
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
useCategoryData,
|
|
4
4
|
useCreateTaskPayload,
|
|
5
5
|
useNotiifcationLabel,
|
|
6
|
-
useTaskLoading,
|
|
7
6
|
useTaskTypeData,
|
|
8
7
|
useTaskTypeExtended,
|
|
9
8
|
} from '../../store';
|
|
@@ -18,7 +17,6 @@ import RadioButtonGroup from '../../../../../common/radio-group/RadioButtonGroup
|
|
|
18
17
|
import styled from 'styled-components';
|
|
19
18
|
import { isValid } from 'date-fns';
|
|
20
19
|
import { TextArea } from '@bjsdistribution/dms-component-library';
|
|
21
|
-
import Loader from '../../../../order-daily-overview/header/loader/Loader';
|
|
22
20
|
import { StandardOptionsType } from '../../../../../common/radio-group/types';
|
|
23
21
|
import { DatePicker } from 'antd';
|
|
24
22
|
import dayjs from 'dayjs';
|
|
@@ -33,7 +31,6 @@ function CreateTaskModal() {
|
|
|
33
31
|
const [subCategory] = useTaskTypeExtended();
|
|
34
32
|
const [createTask, setPayload] = useCreateTaskPayload();
|
|
35
33
|
const [, setLabel] = useNotiifcationLabel();
|
|
36
|
-
const [loading] = useTaskLoading();
|
|
37
34
|
|
|
38
35
|
const handleSelectChange = () => console.log('');
|
|
39
36
|
|
|
@@ -132,7 +129,6 @@ function CreateTaskModal() {
|
|
|
132
129
|
|
|
133
130
|
return (
|
|
134
131
|
<Wrapper>
|
|
135
|
-
{loading && <Loader />}
|
|
136
132
|
<SplitContainer>
|
|
137
133
|
<FormRow label="Task Type" required>
|
|
138
134
|
<StyledAntSelect
|
|
@@ -2,6 +2,7 @@ import React, { useEffect } from 'react';
|
|
|
2
2
|
import {
|
|
3
3
|
RadioButtonGroup,
|
|
4
4
|
useApiHook,
|
|
5
|
+
useAxios,
|
|
5
6
|
} from '@bjsdistribution/dms-component-library';
|
|
6
7
|
import 'react-datepicker/dist/react-datepicker.css';
|
|
7
8
|
import {
|
|
@@ -10,22 +11,20 @@ import {
|
|
|
10
11
|
useCategoryData,
|
|
11
12
|
useCreateTaskPayload,
|
|
12
13
|
useDepartmentData,
|
|
14
|
+
useNotificationData,
|
|
13
15
|
useNotiifcationLabel,
|
|
14
|
-
useTaskLoading,
|
|
15
16
|
useTaskPriority,
|
|
16
17
|
useTaskTypeData,
|
|
17
18
|
useTaskTypeExtended,
|
|
18
19
|
} from '../../store';
|
|
19
|
-
import Loader from '../../../../order-daily-overview/header/loader/Loader';
|
|
20
20
|
import { allTypes } from '../../types';
|
|
21
21
|
import { ContentContainer } from './SharedComponents';
|
|
22
22
|
import { useCurrentAction, useOrderDetails } from '../../../store';
|
|
23
23
|
import OrderActionModal from '../../../../../common/modals/order-action-modal/OrderActionModal';
|
|
24
24
|
import styled from 'styled-components';
|
|
25
|
-
import useFetchUnresolvedTasks from '../../hooks/useAllTaskData';
|
|
26
25
|
import CreateTaskModal from './CreateTaskModal';
|
|
27
|
-
import useCreateTask from '../../hooks/useCreateTask';
|
|
28
26
|
import { CustomOptions } from '../../../../fakeData';
|
|
27
|
+
import { notification } from 'antd';
|
|
29
28
|
|
|
30
29
|
interface ApiResponse {
|
|
31
30
|
message: string;
|
|
@@ -36,17 +35,15 @@ interface ApiResponse {
|
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
function TaskModal() {
|
|
39
|
-
const createTaskAPI = useCreateTask();
|
|
40
38
|
const [, setCurrentAction] = useCurrentAction();
|
|
41
39
|
const [createTask, setPayload] = useCreateTaskPayload();
|
|
42
|
-
const [loading, setLoading] = useTaskLoading();
|
|
43
40
|
const [staticData, setStaticData] = useAllStaticData();
|
|
44
41
|
const [, setPriority] = useTaskPriority();
|
|
45
42
|
const [, setTaskCategory] = useCategoryData();
|
|
46
43
|
const [, setTaskTypes] = useTaskTypeData();
|
|
47
44
|
const [, setTaskTypeExtended] = useTaskTypeExtended();
|
|
48
45
|
const [, setDepartmentData] = useDepartmentData();
|
|
49
|
-
const
|
|
46
|
+
const [, setNotififcationData] = useNotificationData();
|
|
50
47
|
const [, setLabel] = useNotiifcationLabel();
|
|
51
48
|
const [orderDetails] = useOrderDetails();
|
|
52
49
|
|
|
@@ -56,12 +53,32 @@ function TaskModal() {
|
|
|
56
53
|
method: 'GET',
|
|
57
54
|
});
|
|
58
55
|
|
|
56
|
+
//create task API
|
|
57
|
+
const { fetchData: createFlagAPI } = useAxios<{
|
|
58
|
+
data: ApiResponse[];
|
|
59
|
+
}>({
|
|
60
|
+
endpoint: `/tasks/`,
|
|
61
|
+
method: 'POST',
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
//Unresolved API
|
|
65
|
+
const {
|
|
66
|
+
fetchData: callUnresolvedTaskApi,
|
|
67
|
+
data: fetchedUnresolvedData,
|
|
68
|
+
loading: unresolvedLoading,
|
|
69
|
+
} = useAxios<{
|
|
70
|
+
data: ApiResponse[];
|
|
71
|
+
}>({
|
|
72
|
+
endpoint: `/tasks/`,
|
|
73
|
+
method: 'GET',
|
|
74
|
+
pagination: { is_pagination: false },
|
|
75
|
+
filters: [{ field: 'order_id', op: '=', value: orderDetails?.id }],
|
|
76
|
+
});
|
|
77
|
+
|
|
59
78
|
useEffect(() => {
|
|
60
|
-
setLoading(true);
|
|
61
79
|
if (fetchedStaticData) {
|
|
62
80
|
setStaticData(fetchedStaticData.data);
|
|
63
81
|
}
|
|
64
|
-
setLoading(false);
|
|
65
82
|
}, [fetchedStaticData]);
|
|
66
83
|
|
|
67
84
|
//extracted types from whole static data
|
|
@@ -92,12 +109,36 @@ function TaskModal() {
|
|
|
92
109
|
};
|
|
93
110
|
|
|
94
111
|
const handleTaskSubmit = async () => {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
112
|
+
let response = (await createFlagAPI({
|
|
113
|
+
payload: { flags: [createTask] },
|
|
114
|
+
})) as {
|
|
115
|
+
code: number | null;
|
|
116
|
+
error?: string | null | undefined;
|
|
117
|
+
[key: string]: any;
|
|
118
|
+
};
|
|
119
|
+
if (response?.code == 200 && response?.data) {
|
|
120
|
+
notification.success({
|
|
121
|
+
message: 'Success',
|
|
122
|
+
description: `${response.message}`,
|
|
123
|
+
});
|
|
124
|
+
callUnresolvedTaskApi();
|
|
125
|
+
closeModal();
|
|
126
|
+
}
|
|
127
|
+
if (response?.code == null && response.error) {
|
|
128
|
+
return notification.error({
|
|
129
|
+
message: 'Failure',
|
|
130
|
+
description: `${response.error}`,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
99
133
|
};
|
|
100
134
|
|
|
135
|
+
//flags data set
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
if (fetchedUnresolvedData && fetchedUnresolvedData.data) {
|
|
138
|
+
setNotififcationData(fetchedUnresolvedData?.data);
|
|
139
|
+
}
|
|
140
|
+
}, [unresolvedLoading]);
|
|
141
|
+
|
|
101
142
|
const isSubmitDisabled = () => {
|
|
102
143
|
const { description, due_datetime, task_type_id } = createTask;
|
|
103
144
|
return !description || !due_datetime || !task_type_id;
|
|
@@ -117,7 +158,6 @@ function TaskModal() {
|
|
|
117
158
|
|
|
118
159
|
return (
|
|
119
160
|
<>
|
|
120
|
-
{loading && <Loader />}
|
|
121
161
|
<OrderModal
|
|
122
162
|
headerTitle={'CREATE TASK'}
|
|
123
163
|
onCloseHeader={closeModal}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
|
-
import { useApiHook } from '@bjsdistribution/dms-component-library';
|
|
2
|
+
import { useApiHook, useAxios } from '@bjsdistribution/dms-component-library';
|
|
3
3
|
import 'react-datepicker/dist/react-datepicker.css';
|
|
4
4
|
import CreateReminder from './CreateReminderModal';
|
|
5
5
|
import {
|
|
@@ -8,21 +8,17 @@ import {
|
|
|
8
8
|
useCategoryData,
|
|
9
9
|
useCreateReminderPayload,
|
|
10
10
|
useDepartmentData,
|
|
11
|
-
|
|
11
|
+
useReminderNotiData,
|
|
12
12
|
useTaskPriority,
|
|
13
13
|
useTaskTypeData,
|
|
14
14
|
useTaskTypeExtended,
|
|
15
15
|
} from '../../store';
|
|
16
|
-
import Loader from '../../../../order-daily-overview/header/loader/Loader';
|
|
17
|
-
import useCreateReminder from '../../hooks/useCreateReminder';
|
|
18
16
|
import { allTypes } from '../../types';
|
|
19
|
-
|
|
20
17
|
import { ContentContainer } from './SharedComponents';
|
|
21
|
-
import { useCurrentAction } from '../../../store';
|
|
18
|
+
import { useCurrentAction, useOrderDetails } from '../../../store';
|
|
22
19
|
import OrderActionModal from '../../../../../common/modals/order-action-modal/OrderActionModal';
|
|
23
20
|
import styled from 'styled-components';
|
|
24
|
-
import
|
|
25
|
-
import useFetchReminders from '../../hooks/useAllReminderData';
|
|
21
|
+
import { notification } from 'antd';
|
|
26
22
|
|
|
27
23
|
interface ApiResponse {
|
|
28
24
|
message: string;
|
|
@@ -33,19 +29,38 @@ interface ApiResponse {
|
|
|
33
29
|
}
|
|
34
30
|
|
|
35
31
|
function TaskReminderModal() {
|
|
36
|
-
const createReminderAPI = useCreateReminder();
|
|
37
32
|
const [, setCurrentAction] = useCurrentAction();
|
|
38
|
-
// const [modalType, setModalTypeState] = useState<string>('task');
|
|
39
33
|
const [createReminder, setReminderPayload] = useCreateReminderPayload();
|
|
40
|
-
const [loading, setLoading] = useTaskLoading();
|
|
41
34
|
const [staticData, setStaticData] = useAllStaticData();
|
|
42
35
|
const [, setPriority] = useTaskPriority();
|
|
43
36
|
const [, setTaskCategory] = useCategoryData();
|
|
44
37
|
const [, setTaskTypes] = useTaskTypeData();
|
|
45
38
|
const [, setTaskTypeExtended] = useTaskTypeExtended();
|
|
46
39
|
const [, setDepartmentData] = useDepartmentData();
|
|
47
|
-
const
|
|
48
|
-
const
|
|
40
|
+
const [, setReminderData] = useReminderNotiData();
|
|
41
|
+
const [OrderData] = useOrderDetails();
|
|
42
|
+
|
|
43
|
+
//create reminder API
|
|
44
|
+
const { fetchData: createReminderAPI } = useAxios<{
|
|
45
|
+
data: ApiResponse[];
|
|
46
|
+
}>({
|
|
47
|
+
endpoint: `/tasks/reminders/create/`,
|
|
48
|
+
method: 'POST',
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
//reminder get
|
|
52
|
+
const {
|
|
53
|
+
fetchData: callReminderApi,
|
|
54
|
+
data: fetchedReminderData,
|
|
55
|
+
loading: reminderLoading,
|
|
56
|
+
} = useAxios<{
|
|
57
|
+
data: ApiResponse[];
|
|
58
|
+
}>({
|
|
59
|
+
endpoint: `/tasks/reminder/get/`,
|
|
60
|
+
method: 'GET',
|
|
61
|
+
pagination: { is_pagination: false },
|
|
62
|
+
filters: [{ field: 'order_id', op: '=', value: OrderData.id }],
|
|
63
|
+
});
|
|
49
64
|
|
|
50
65
|
// API Call
|
|
51
66
|
const { data: fetchedStaticData } = useApiHook<ApiResponse>({
|
|
@@ -54,11 +69,9 @@ function TaskReminderModal() {
|
|
|
54
69
|
});
|
|
55
70
|
|
|
56
71
|
useEffect(() => {
|
|
57
|
-
setLoading(true);
|
|
58
72
|
if (fetchedStaticData) {
|
|
59
|
-
setStaticData(fetchedStaticData
|
|
73
|
+
setStaticData(fetchedStaticData?.data);
|
|
60
74
|
}
|
|
61
|
-
setLoading(false);
|
|
62
75
|
}, [fetchedStaticData]);
|
|
63
76
|
|
|
64
77
|
//extracted types from whole static data
|
|
@@ -81,13 +94,36 @@ function TaskReminderModal() {
|
|
|
81
94
|
};
|
|
82
95
|
|
|
83
96
|
const handleReminderSubmit = async () => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
97
|
+
let response = (await createReminderAPI({
|
|
98
|
+
payload: { reminder: createReminder },
|
|
99
|
+
})) as {
|
|
100
|
+
code: number | null;
|
|
101
|
+
error?: string | null | undefined;
|
|
102
|
+
[key: string]: any;
|
|
103
|
+
};
|
|
104
|
+
if (response.code == 200 && response.data) {
|
|
105
|
+
notification.success({
|
|
106
|
+
message: 'Success',
|
|
107
|
+
description: `${response.message}`,
|
|
108
|
+
});
|
|
109
|
+
callReminderApi();
|
|
110
|
+
closeModal();
|
|
111
|
+
}
|
|
112
|
+
if (response?.code == null && response.error) {
|
|
113
|
+
return notification.error({
|
|
114
|
+
message: 'Failure',
|
|
115
|
+
description: `${response.error}`,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
89
118
|
};
|
|
90
119
|
|
|
120
|
+
//reminder data set
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
if (fetchedReminderData && fetchedReminderData?.data) {
|
|
123
|
+
setReminderData(fetchedReminderData?.data);
|
|
124
|
+
}
|
|
125
|
+
}, [reminderLoading]);
|
|
126
|
+
|
|
91
127
|
const isSubmitDisabled = () => {
|
|
92
128
|
const { details, due } = createReminder;
|
|
93
129
|
return !details || !due;
|
|
@@ -97,7 +133,6 @@ function TaskReminderModal() {
|
|
|
97
133
|
|
|
98
134
|
return (
|
|
99
135
|
<>
|
|
100
|
-
{loading && <Loader />}
|
|
101
136
|
<OrderModal
|
|
102
137
|
headerTitle={'CREATE REMINDER'}
|
|
103
138
|
onCloseHeader={closeModal}
|