@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.
- package/dist/assets/icons/DownloadIcon.d.ts +3 -0
- 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 +1169 -1904
- 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 +1171 -1906
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/assets/icons/DownloadIcon.tsx +36 -0
- 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 +1 -1
- package/src/components/order-view/notification/index.tsx +42 -15
- 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-details/expanded-content/orders-section/DeliveryDate.tsx +2 -4
- package/src/components/order-view/order-resources/columns/actions/index.tsx +3 -3
- 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,62 +0,0 @@
|
|
|
1
|
-
import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
|
|
2
|
-
import { getCookie } from '../utils';
|
|
3
|
-
import { notification } from 'antd';
|
|
4
|
-
import { useUpdateApiCall } from '../store';
|
|
5
|
-
|
|
6
|
-
function useUpdateOrder() {
|
|
7
|
-
let controller: AbortController;
|
|
8
|
-
const ssoToken = getCookie('id_token');
|
|
9
|
-
const [, setCallApi] = useUpdateApiCall(); //single detail
|
|
10
|
-
|
|
11
|
-
const update = async (data: any) => {
|
|
12
|
-
const endpoint = `${getBaseEndpoint()}/orders/update/`;
|
|
13
|
-
|
|
14
|
-
if (controller) {
|
|
15
|
-
controller.abort();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Create new AbortController
|
|
19
|
-
controller = new AbortController();
|
|
20
|
-
const signal = controller.signal;
|
|
21
|
-
// setLoading(true); // Set loading to true
|
|
22
|
-
try {
|
|
23
|
-
const requestOptions = {
|
|
24
|
-
headers: {
|
|
25
|
-
'Content-Type': 'application/json',
|
|
26
|
-
Authorization: `Bearer ${ssoToken}`,
|
|
27
|
-
},
|
|
28
|
-
method: 'PUT',
|
|
29
|
-
body: JSON.stringify(data),
|
|
30
|
-
signal,
|
|
31
|
-
};
|
|
32
|
-
const response = await fetch(endpoint, requestOptions);
|
|
33
|
-
if (!response.ok) {
|
|
34
|
-
// setLoading(false);
|
|
35
|
-
throw new Error('response is not ok');
|
|
36
|
-
}
|
|
37
|
-
const json = await response.json();
|
|
38
|
-
// alert('Order has been updated');
|
|
39
|
-
notification.success({
|
|
40
|
-
message: 'Success',
|
|
41
|
-
description: 'Order has been updated.',
|
|
42
|
-
});
|
|
43
|
-
setCallApi(true);
|
|
44
|
-
return json;
|
|
45
|
-
} catch (err) {
|
|
46
|
-
// setLoading(false);
|
|
47
|
-
// console.log(err, 'error');
|
|
48
|
-
|
|
49
|
-
notification.error({
|
|
50
|
-
message: 'Error',
|
|
51
|
-
description:
|
|
52
|
-
`${err}` || 'An error has occurred. Please try again later.',
|
|
53
|
-
});
|
|
54
|
-
} finally {
|
|
55
|
-
// setLoading(false); // Set loading to false after fetching
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
return update;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export default useUpdateOrder;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
|
|
2
|
-
import { useOrderDetails } from '../../store';
|
|
3
|
-
import { getCookie } from '../../utils';
|
|
4
|
-
import { useReminderNotiData } from '../store';
|
|
5
|
-
import { notification } from 'antd';
|
|
6
|
-
|
|
7
|
-
function useFetchReminders() {
|
|
8
|
-
const ssoToken = getCookie('id_token');
|
|
9
|
-
const [, setReminderData] = useReminderNotiData();
|
|
10
|
-
const [OrderData] = useOrderDetails();
|
|
11
|
-
|
|
12
|
-
const perform = async () => {
|
|
13
|
-
const endpoint = `${getBaseEndpoint()}/tasks/reminder/get/`;
|
|
14
|
-
try {
|
|
15
|
-
const headers = {
|
|
16
|
-
accept: 'application/json',
|
|
17
|
-
'Content-Type': 'application/json',
|
|
18
|
-
Authorization: `Bearer ${ssoToken}`,
|
|
19
|
-
'x-pagination': JSON.stringify({
|
|
20
|
-
page: 1,
|
|
21
|
-
per_page: 100,
|
|
22
|
-
}),
|
|
23
|
-
'x-filters': JSON.stringify([
|
|
24
|
-
{
|
|
25
|
-
field: 'order_id',
|
|
26
|
-
op: '=',
|
|
27
|
-
value: `${OrderData.id}`,
|
|
28
|
-
},
|
|
29
|
-
]),
|
|
30
|
-
};
|
|
31
|
-
const response = await fetch(endpoint, {
|
|
32
|
-
method: 'GET',
|
|
33
|
-
headers,
|
|
34
|
-
});
|
|
35
|
-
if (!response.ok) {
|
|
36
|
-
const json = await response.json();
|
|
37
|
-
const detail = json?.detail;
|
|
38
|
-
const msg = detail[0]?.msg;
|
|
39
|
-
// console.error('Error response:', msg);
|
|
40
|
-
notification.error({
|
|
41
|
-
message: 'Error',
|
|
42
|
-
description:
|
|
43
|
-
`${msg}` || 'An error has occurred. Please try again later.',
|
|
44
|
-
});
|
|
45
|
-
// setLoading(false);
|
|
46
|
-
return [];
|
|
47
|
-
}
|
|
48
|
-
const json = await response.json();
|
|
49
|
-
if (json.code === 200) {
|
|
50
|
-
// setLoading(false);
|
|
51
|
-
setReminderData(json.data);
|
|
52
|
-
return json.data;
|
|
53
|
-
}
|
|
54
|
-
return [];
|
|
55
|
-
} catch (err) {
|
|
56
|
-
// console.error('Error fetching data:', err);
|
|
57
|
-
notification.error({
|
|
58
|
-
message: 'Error',
|
|
59
|
-
description:
|
|
60
|
-
`${err}` || 'An error has occurred. Please try again later.',
|
|
61
|
-
});
|
|
62
|
-
return [];
|
|
63
|
-
} finally {
|
|
64
|
-
// setLoading(false);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
return perform;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export default useFetchReminders;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
|
|
2
|
-
import { useNotificationData, useTaskLoading } from '../store';
|
|
3
|
-
import { useOrderDetails } from '../../store';
|
|
4
|
-
import { getCookie } from '../../utils';
|
|
5
|
-
import { notification } from 'antd';
|
|
6
|
-
|
|
7
|
-
function useFetchUnresolvedTasks() {
|
|
8
|
-
const ssoToken = getCookie('id_token');
|
|
9
|
-
const [, setNotificationData] = useNotificationData();
|
|
10
|
-
const [, setLoading] = useTaskLoading();
|
|
11
|
-
const [OrderData] = useOrderDetails();
|
|
12
|
-
|
|
13
|
-
const perform = async () => {
|
|
14
|
-
const endpoint = `${getBaseEndpoint()}/tasks/`;
|
|
15
|
-
try {
|
|
16
|
-
const headers = {
|
|
17
|
-
accept: 'application/json',
|
|
18
|
-
'Content-Type': 'application/json',
|
|
19
|
-
Authorization: `Bearer ${ssoToken}`,
|
|
20
|
-
'x-pagination': JSON.stringify({
|
|
21
|
-
page: 1,
|
|
22
|
-
per_page: 100,
|
|
23
|
-
}),
|
|
24
|
-
'x-filters': JSON.stringify([
|
|
25
|
-
{
|
|
26
|
-
field: 'order_id',
|
|
27
|
-
op: '=',
|
|
28
|
-
value: `${OrderData.id}`,
|
|
29
|
-
},
|
|
30
|
-
]),
|
|
31
|
-
};
|
|
32
|
-
const response = await fetch(endpoint, {
|
|
33
|
-
method: 'GET',
|
|
34
|
-
headers,
|
|
35
|
-
});
|
|
36
|
-
if (!response.ok) {
|
|
37
|
-
const json = await response.json();
|
|
38
|
-
const detail = json?.detail;
|
|
39
|
-
const msg = detail[0]?.msg;
|
|
40
|
-
// console.error('Error response:', msg);
|
|
41
|
-
notification.error({
|
|
42
|
-
message: 'Error',
|
|
43
|
-
description:
|
|
44
|
-
`${msg}` || 'An error has occurred. Please try again later.',
|
|
45
|
-
});
|
|
46
|
-
setLoading(false);
|
|
47
|
-
return [];
|
|
48
|
-
}
|
|
49
|
-
const json = await response.json();
|
|
50
|
-
if (json.code === 200) {
|
|
51
|
-
setLoading(false);
|
|
52
|
-
setNotificationData(json.data);
|
|
53
|
-
return json.data;
|
|
54
|
-
}
|
|
55
|
-
return [];
|
|
56
|
-
} catch (err) {
|
|
57
|
-
// console.error('Error fetching data:', err);
|
|
58
|
-
notification.error({
|
|
59
|
-
message: 'Error',
|
|
60
|
-
description:
|
|
61
|
-
`${err}` || 'An error has occurred. Please try again later.',
|
|
62
|
-
});
|
|
63
|
-
setLoading(false);
|
|
64
|
-
return [];
|
|
65
|
-
} finally {
|
|
66
|
-
setLoading(false);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
return perform;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export default useFetchUnresolvedTasks;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
|
|
2
|
-
import { useFlagsLoading } from '../store';
|
|
3
|
-
import { CreateReminderPayload } from '../types';
|
|
4
|
-
import { getCookie } from '../../utils';
|
|
5
|
-
import { notification } from 'antd';
|
|
6
|
-
|
|
7
|
-
function useCreateReminder() {
|
|
8
|
-
const ssoToken = getCookie('id_token');
|
|
9
|
-
const [, setLoading] = useFlagsLoading();
|
|
10
|
-
|
|
11
|
-
const create = async (data: CreateReminderPayload[]) => {
|
|
12
|
-
const endpoint = `${getBaseEndpoint()}/tasks/reminders/create/`;
|
|
13
|
-
setLoading(true);
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
const requestOptions = {
|
|
17
|
-
headers: {
|
|
18
|
-
'Content-Type': 'application/json',
|
|
19
|
-
Authorization: `Bearer ${ssoToken}`,
|
|
20
|
-
},
|
|
21
|
-
method: 'POST',
|
|
22
|
-
body: JSON.stringify({ reminders: data }),
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const response = await fetch(endpoint, requestOptions);
|
|
26
|
-
|
|
27
|
-
if (!response.ok) {
|
|
28
|
-
setLoading(false);
|
|
29
|
-
notification.error({
|
|
30
|
-
message: 'Error',
|
|
31
|
-
description: 'response is not ok',
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
notification.success({
|
|
35
|
-
message: 'Success',
|
|
36
|
-
description: 'Reminder Created Successfully',
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const json = await response.json();
|
|
40
|
-
return json;
|
|
41
|
-
} catch (err) {
|
|
42
|
-
setLoading(false);
|
|
43
|
-
|
|
44
|
-
notification.error({
|
|
45
|
-
message: 'Error',
|
|
46
|
-
description:
|
|
47
|
-
`${err}` || 'An error has occurred. Please try again later.',
|
|
48
|
-
});
|
|
49
|
-
} finally {
|
|
50
|
-
setLoading(false);
|
|
51
|
-
}
|
|
52
|
-
setLoading(false);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
return create;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export default useCreateReminder;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
|
|
2
|
-
import { useFlagsLoading } from '../store';
|
|
3
|
-
import { CreateTaskPayload } from '../types';
|
|
4
|
-
import { getCookie } from '../../utils';
|
|
5
|
-
import { notification } from 'antd';
|
|
6
|
-
|
|
7
|
-
function useCreateTask() {
|
|
8
|
-
const ssoToken = getCookie('id_token');
|
|
9
|
-
const [, setLoading] = useFlagsLoading();
|
|
10
|
-
|
|
11
|
-
const create = async (data: CreateTaskPayload[]) => {
|
|
12
|
-
const endpoint = `${getBaseEndpoint()}/tasks/`;
|
|
13
|
-
setLoading(true);
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
const requestOptions = {
|
|
17
|
-
headers: {
|
|
18
|
-
'Content-Type': 'application/json',
|
|
19
|
-
Authorization: `Bearer ${ssoToken}`,
|
|
20
|
-
},
|
|
21
|
-
method: 'POST',
|
|
22
|
-
body: JSON.stringify({ flags: data }),
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const response = await fetch(endpoint, requestOptions);
|
|
26
|
-
|
|
27
|
-
if (!response.ok) {
|
|
28
|
-
setLoading(false);
|
|
29
|
-
throw new Error('response is not ok');
|
|
30
|
-
}
|
|
31
|
-
// alert('Task Created Successfully');
|
|
32
|
-
|
|
33
|
-
notification.success({
|
|
34
|
-
message: 'Success',
|
|
35
|
-
description: 'Task Created Successfully',
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const json = await response.json();
|
|
39
|
-
return json;
|
|
40
|
-
} catch (err) {
|
|
41
|
-
setLoading(false);
|
|
42
|
-
// alert(err);
|
|
43
|
-
// console.error('Error:', err);
|
|
44
|
-
notification.error({
|
|
45
|
-
message: 'Error',
|
|
46
|
-
description:
|
|
47
|
-
`${err}` || 'An error has occurred. Please try again later.',
|
|
48
|
-
});
|
|
49
|
-
} finally {
|
|
50
|
-
setLoading(false);
|
|
51
|
-
}
|
|
52
|
-
setLoading(false);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
return create;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export default useCreateTask;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
|
|
2
|
-
|
|
3
|
-
import { useFlagRefId, useFlagsLoading } from '../store';
|
|
4
|
-
import { getCookie } from '../../utils';
|
|
5
|
-
import { notification } from 'antd';
|
|
6
|
-
|
|
7
|
-
function useFetchSingleFlagsData() {
|
|
8
|
-
const [selectedFlagId] = useFlagRefId();
|
|
9
|
-
const [loading, setLoading] = useFlagsLoading();
|
|
10
|
-
const ssoToken = getCookie('id_token');
|
|
11
|
-
console.log(loading, 'loading loading');
|
|
12
|
-
const res = async () => {
|
|
13
|
-
const endpoint = `${getBaseEndpoint()}/tasks/${selectedFlagId}`;
|
|
14
|
-
try {
|
|
15
|
-
const headers = {
|
|
16
|
-
accept: 'application/json',
|
|
17
|
-
'Content-Type': 'application/json',
|
|
18
|
-
Authorization: `Bearer ${ssoToken}`,
|
|
19
|
-
};
|
|
20
|
-
const response = await fetch(endpoint, {
|
|
21
|
-
method: 'GET',
|
|
22
|
-
headers,
|
|
23
|
-
});
|
|
24
|
-
if (!response.ok) {
|
|
25
|
-
const json = await response.json();
|
|
26
|
-
const detail = json?.detail;
|
|
27
|
-
const msg = detail[0]?.msg;
|
|
28
|
-
// alert(`${msg}`);
|
|
29
|
-
notification.error({
|
|
30
|
-
message: 'Error',
|
|
31
|
-
description:
|
|
32
|
-
`${msg}` || 'An error has occurred. Please try again later.',
|
|
33
|
-
});
|
|
34
|
-
setLoading(false);
|
|
35
|
-
return [];
|
|
36
|
-
}
|
|
37
|
-
const json = await response.json();
|
|
38
|
-
if (json.code === 200) {
|
|
39
|
-
setLoading(false);
|
|
40
|
-
return { ...json.data[0] };
|
|
41
|
-
}
|
|
42
|
-
return [];
|
|
43
|
-
} catch (err) {
|
|
44
|
-
setLoading(false);
|
|
45
|
-
// console.error('Error fetching data:', err);
|
|
46
|
-
|
|
47
|
-
notification.error({
|
|
48
|
-
message: 'Error',
|
|
49
|
-
description:
|
|
50
|
-
`${err}` || 'An error has occurred. Please try again later.',
|
|
51
|
-
});
|
|
52
|
-
return [];
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
return res;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export default useFetchSingleFlagsData;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
|
|
2
|
-
import { useFlagsLoading, useReminderRefId } from '../store';
|
|
3
|
-
import { getCookie } from '../../utils';
|
|
4
|
-
import { notification } from 'antd';
|
|
5
|
-
|
|
6
|
-
function useFetchSingleReminderData() {
|
|
7
|
-
const [reminderRefId] = useReminderRefId();
|
|
8
|
-
|
|
9
|
-
const [, setLoading] = useFlagsLoading();
|
|
10
|
-
const ssoToken = getCookie('id_token');
|
|
11
|
-
|
|
12
|
-
const res = async () => {
|
|
13
|
-
const endpoint = `${getBaseEndpoint()}/tasks/reminder/${reminderRefId}`;
|
|
14
|
-
setLoading(true);
|
|
15
|
-
try {
|
|
16
|
-
const headers = {
|
|
17
|
-
accept: 'application/json',
|
|
18
|
-
'Content-Type': 'application/json',
|
|
19
|
-
Authorization: `Bearer ${ssoToken}`,
|
|
20
|
-
};
|
|
21
|
-
const response = await fetch(endpoint, {
|
|
22
|
-
method: 'GET',
|
|
23
|
-
headers,
|
|
24
|
-
});
|
|
25
|
-
if (!response.ok) {
|
|
26
|
-
const json = await response.json();
|
|
27
|
-
const detail = json?.detail;
|
|
28
|
-
const msg = detail[0]?.msg;
|
|
29
|
-
notification.error({
|
|
30
|
-
message: 'Error',
|
|
31
|
-
description: msg || 'An error has occurred. Please try again later.',
|
|
32
|
-
});
|
|
33
|
-
setLoading(false);
|
|
34
|
-
return [];
|
|
35
|
-
}
|
|
36
|
-
const json = await response.json();
|
|
37
|
-
if (json.code === 200) {
|
|
38
|
-
setLoading(false);
|
|
39
|
-
|
|
40
|
-
return { ...json.data[0] };
|
|
41
|
-
}
|
|
42
|
-
return [];
|
|
43
|
-
} catch (err) {
|
|
44
|
-
//setloading(false);
|
|
45
|
-
notification.error({
|
|
46
|
-
message: 'Error',
|
|
47
|
-
description:
|
|
48
|
-
`${err}` || 'An error has occurred. Please try again later.',
|
|
49
|
-
});
|
|
50
|
-
return [];
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
return res;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export default useFetchSingleReminderData;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
|
|
2
|
-
import { useFlagsLoading } from '../store';
|
|
3
|
-
import { SingleFlagPayload } from '../types';
|
|
4
|
-
import { getCookie } from '../../utils';
|
|
5
|
-
import { notification } from 'antd';
|
|
6
|
-
|
|
7
|
-
function useUpdateFlag() {
|
|
8
|
-
const ssoToken = getCookie('id_token');
|
|
9
|
-
const [, setLoading] = useFlagsLoading();
|
|
10
|
-
|
|
11
|
-
const create = async (data: SingleFlagPayload[]) => {
|
|
12
|
-
const endpoint = `${getBaseEndpoint()}/tasks/update/`;
|
|
13
|
-
setLoading(true);
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
const requestOptions = {
|
|
17
|
-
headers: {
|
|
18
|
-
'Content-Type': 'application/json',
|
|
19
|
-
Authorization: `Bearer ${ssoToken}`,
|
|
20
|
-
},
|
|
21
|
-
method: 'PUT',
|
|
22
|
-
body: JSON.stringify(data),
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const response = await fetch(endpoint, requestOptions);
|
|
26
|
-
|
|
27
|
-
if (!response.ok) {
|
|
28
|
-
throw new Error('response is not ok');
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const json = await response.json();
|
|
32
|
-
// alert('Flag has been updated');
|
|
33
|
-
notification.success({
|
|
34
|
-
message: 'Success',
|
|
35
|
-
description: 'Flag has been updated',
|
|
36
|
-
});
|
|
37
|
-
return json;
|
|
38
|
-
} catch (err) {
|
|
39
|
-
// console.error('Error:', err);
|
|
40
|
-
notification.error({
|
|
41
|
-
message: 'Error',
|
|
42
|
-
description:
|
|
43
|
-
`${err}` || 'An error has occurred. Please try again later.',
|
|
44
|
-
});
|
|
45
|
-
} finally {
|
|
46
|
-
setLoading(false);
|
|
47
|
-
}
|
|
48
|
-
setLoading(false);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
return create;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export default useUpdateFlag;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
|
|
2
|
-
import { useFlagsLoading } from '../store';
|
|
3
|
-
import { UpdateReminderPayload } from '../types';
|
|
4
|
-
import { getCookie } from '../../utils';
|
|
5
|
-
import { notification } from 'antd';
|
|
6
|
-
|
|
7
|
-
function useUpdateReminder() {
|
|
8
|
-
const ssoToken = getCookie('id_token');
|
|
9
|
-
const [, setLoading] = useFlagsLoading();
|
|
10
|
-
|
|
11
|
-
const update = async (data: UpdateReminderPayload[]) => {
|
|
12
|
-
const endpoint = `${getBaseEndpoint()}/tasks/reminder/update/`;
|
|
13
|
-
setLoading(true);
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
const requestOptions = {
|
|
17
|
-
headers: {
|
|
18
|
-
'Content-Type': 'application/json',
|
|
19
|
-
Authorization: `Bearer ${ssoToken}`,
|
|
20
|
-
},
|
|
21
|
-
method: 'PUT',
|
|
22
|
-
body: JSON.stringify(data),
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const response = await fetch(endpoint, requestOptions);
|
|
26
|
-
|
|
27
|
-
if (!response.ok) {
|
|
28
|
-
throw new Error('response is not ok');
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const json = await response.json();
|
|
32
|
-
notification.success({
|
|
33
|
-
message: 'Success',
|
|
34
|
-
description: 'Reminder has been updated.',
|
|
35
|
-
});
|
|
36
|
-
return json;
|
|
37
|
-
} catch (err) {
|
|
38
|
-
notification.error({
|
|
39
|
-
message: 'Error',
|
|
40
|
-
description:
|
|
41
|
-
`${err}` || 'An error has occurred. Please try again later.',
|
|
42
|
-
});
|
|
43
|
-
} finally {
|
|
44
|
-
setLoading(false);
|
|
45
|
-
}
|
|
46
|
-
setLoading(false);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
return update;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export default useUpdateReminder;
|