@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
@@ -1,54 +0,0 @@
1
- import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
2
- import { notification } from 'antd';
3
- import { getCookie } from '../utils';
4
- import {
5
- selectedCategoryIdAtom,
6
- selectedDocumentTypeAtom,
7
- selectedTypeAtom,
8
- selectedVisibilityAtom,
9
- } from '../order-actions/store';
10
- import { useAtom } from 'jotai';
11
- import { useOrderId } from '../store';
12
-
13
- function useUploadFiles() {
14
- const ssoToken = getCookie('id_token');
15
-
16
- const [selectedCategoryId] = useAtom(selectedCategoryIdAtom);
17
- const [selectedDocumentType] = useAtom(selectedDocumentTypeAtom);
18
- const [selectedType] = useAtom(selectedTypeAtom);
19
- const [orderId] = useOrderId();
20
- const [selectedVisibility] = useAtom(selectedVisibilityAtom);
21
-
22
- const create = async (formData: FormData) => {
23
- const endpoint = `${getBaseEndpoint()}/orders/${orderId}/order_resources/?document_type=${selectedDocumentType}&type=${selectedType}&category=${selectedCategoryId}&visibility=${selectedVisibility}`;
24
-
25
- try {
26
- const requestOptions = {
27
- headers: {
28
- Authorization: `Bearer ${ssoToken}`,
29
- },
30
- method: 'POST',
31
- body: formData,
32
- };
33
-
34
- const response = await fetch(endpoint, requestOptions);
35
- if (!response.ok) {
36
- throw new Error('Failed to upload files');
37
- }
38
-
39
- const json = await response.json();
40
- return json;
41
- } catch (err) {
42
- notification.error({
43
- message: 'Error',
44
- //@ts-ignore
45
- description: `${err.message}` || 'Upload error:', // Using err.message for clearer output
46
- });
47
- throw err;
48
- }
49
- };
50
-
51
- return create;
52
- }
53
-
54
- export default useUploadFiles;
@@ -1,60 +0,0 @@
1
- import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
2
- import { getCookie } from '../utils';
3
- import { notification } from 'antd';
4
- // import { useOrderDetails, useOrderProductSystemLogs } from '../store';
5
-
6
- function useGetEventNotes() {
7
- const ssoToken = getCookie('id_token');
8
-
9
- const perform = async () => {
10
- const endpoint = `${getBaseEndpoint()}/events/get/event_information/`;
11
- // setLoading(true);
12
- try {
13
- const headers = {
14
- accept: 'application/json',
15
- 'Content-Type': 'application/json',
16
- Authorization: `Bearer ${ssoToken}`,
17
- 'x-pagination': JSON.stringify({
18
- is_pagination: false,
19
- }),
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
- // console.error('Error response:', msg);
30
-
31
- notification.error({
32
- message: 'Error',
33
- description:
34
- `${msg}` || 'An error has occurred. Please try again later.',
35
- });
36
- // setLoading(false);
37
- return [];
38
- }
39
- const json = await response.json();
40
- if (json.code === 200) {
41
- return json?.data;
42
- }
43
- return [];
44
- } catch (err) {
45
- // console.error('Error fetching data:', err);
46
- notification.error({
47
- message: 'Error',
48
- description:
49
- `${err}` || 'An error has occurred. Please try again later.',
50
- });
51
-
52
- return [];
53
- } finally {
54
- // setLoading(false);
55
- }
56
- };
57
- return perform;
58
- }
59
-
60
- export default useGetEventNotes;
@@ -1,71 +0,0 @@
1
- import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
2
- import { getCookie } from '../utils';
3
- import { useOrderDetails, useOrderProductSystemLogs } from '../store';
4
- import { notification } from 'antd';
5
-
6
- function useSystemLogs() {
7
- const ssoToken = getCookie('id_token');
8
- const [orderDetails] = useOrderDetails();
9
- const gsitId = orderDetails?.gsit_order_id;
10
- const [, setSystemLogsEvents] = useOrderProductSystemLogs();
11
-
12
- const perform = async () => {
13
- const endpoint = `${getBaseEndpoint()}/events/get/event/`;
14
- // setLoading(true);
15
- try {
16
- const headers = {
17
- accept: 'application/json',
18
- 'Content-Type': 'application/json',
19
- Authorization: `Bearer ${ssoToken}`,
20
- 'x-pagination': JSON.stringify({
21
- is_pagination: false,
22
- }),
23
- 'x-filters': JSON.stringify([
24
- {
25
- field: 'object_id',
26
- op: '=',
27
- value: `${gsitId}`,
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
-
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
- setSystemLogsEvents(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
- return [];
64
- } finally {
65
- // setLoading(false);
66
- }
67
- };
68
- return perform;
69
- }
70
-
71
- export default useSystemLogs;
@@ -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;