datastake-daf 0.6.813 → 0.6.815

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 (70) hide show
  1. package/build/favicon.ico +0 -0
  2. package/build/logo192.png +0 -0
  3. package/build/logo512.png +0 -0
  4. package/build/manifest.json +25 -0
  5. package/build/robots.txt +3 -0
  6. package/dist/components/index.js +3181 -4417
  7. package/dist/hooks/index.js +4 -11
  8. package/dist/layouts/index.js +478 -464
  9. package/dist/pages/index.js +1123 -742
  10. package/dist/services/index.js +6 -56
  11. package/dist/utils/index.js +511 -492
  12. package/package.json +1 -1
  13. package/src/@daf/core/components/AuthForm/index.jsx +3 -12
  14. package/src/@daf/core/components/Dashboard/Map/ChainIcon/index.js +123 -104
  15. package/src/@daf/core/components/Icon/configs/index.js +3 -1
  16. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/index.jsx +1 -0
  17. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/hook.js +1 -0
  18. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/index.jsx +3 -1
  19. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/index.jsx +51 -51
  20. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineSubjects/index.jsx +1 -6
  21. package/src/@daf/core/components/Screens/Admin/AdminModals/NewAccount/index.jsx +31 -56
  22. package/src/@daf/core/components/Screens/Admin/AdminModals/NewUser/index.jsx +10 -36
  23. package/src/@daf/core/components/Screens/Admin/AdminModals/TransferRights/index.jsx +1 -1
  24. package/src/@daf/core/components/Screens/Admin/AdminScreens/Accounts.jsx +10 -37
  25. package/src/@daf/core/components/Screens/Admin/AdminScreens/Dashboard.jsx +2 -2
  26. package/src/@daf/core/components/Screens/Admin/AdminScreens/index.js +0 -2
  27. package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/helper.js +30 -22
  28. package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/index.jsx +13 -25
  29. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/index.jsx +2 -17
  30. package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/index.jsx +13 -27
  31. package/src/@daf/core/components/Screens/Admin/AdminTables/UserTable/index.jsx +1 -0
  32. package/src/@daf/core/components/Screens/Admin/AdminTables/components/index.jsx +2 -4
  33. package/src/@daf/core/components/Screens/Admin/AdminTables/hook.js +0 -3
  34. package/src/@daf/core/components/Screens/Admin/AdminViews/components/Edit/index.jsx +9 -12
  35. package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/index.jsx +4 -16
  36. package/src/@daf/core/components/Screens/Admin/AdminViews/components/View/helpers.js +17 -9
  37. package/src/@daf/core/components/Screens/Admin/AdminViews/index.jsx +8 -9
  38. package/src/@daf/core/components/Screens/Admin/AppInvitation/index.jsx +99 -124
  39. package/src/@daf/core/components/Screens/Admin/adminRoutes.js +1 -48
  40. package/src/@daf/core/components/Table/index.jsx +11 -6
  41. package/src/@daf/hooks/useAdminDashboard.js +4 -7
  42. package/src/@daf/pages/Events/Activities/columns.js +15 -11
  43. package/src/@daf/pages/Events/Incidents/columns.js +15 -11
  44. package/src/@daf/pages/Events/Testimonials/columns.js +173 -0
  45. package/src/@daf/pages/Events/Testimonials/config.js +175 -0
  46. package/src/@daf/pages/Events/columns.js +7 -3
  47. package/src/@daf/pages/Locations/MineSite/columns.js +16 -11
  48. package/src/@daf/pages/Locations/columns.js +7 -3
  49. package/src/@daf/pages/Stakeholders/Operators/columns.js +16 -12
  50. package/src/@daf/pages/Stakeholders/Workers/columns.js +16 -12
  51. package/src/@daf/pages/Stakeholders/columns.js +8 -4
  52. package/src/@daf/pages/TablePage/helper.js +15 -0
  53. package/src/@daf/pages/View/hooks/useViewActions.js +0 -13
  54. package/src/@daf/pages/View/hooks/useViewPermissions.js +0 -16
  55. package/src/@daf/pages/View/index.jsx +4 -29
  56. package/src/@daf/services/AdminService.js +5 -47
  57. package/src/@daf/services/DashboardService.js +3 -3
  58. package/src/@daf/utils/filters.js +15 -13
  59. package/src/constants/locales/en/translation.js +0 -13
  60. package/src/helpers/copyToClipboard.js +0 -60
  61. package/src/helpers/errorHandling.js +142 -74
  62. package/src/utils.js +1 -1
  63. package/src/@daf/core/components/Screens/Admin/AdminScreens/Documents.jsx +0 -81
  64. package/src/@daf/core/components/Screens/Admin/AdminScreens/Events.jsx +0 -77
  65. package/src/@daf/core/components/Screens/Admin/AdminTables/DocumentsTable/column.js +0 -127
  66. package/src/@daf/core/components/Screens/Admin/AdminTables/DocumentsTable/helper.js +0 -43
  67. package/src/@daf/core/components/Screens/Admin/AdminTables/DocumentsTable/index.jsx +0 -201
  68. package/src/@daf/core/components/Screens/Admin/AdminTables/EventsTable/column.js +0 -146
  69. package/src/@daf/core/components/Screens/Admin/AdminTables/EventsTable/helper.js +0 -58
  70. package/src/@daf/core/components/Screens/Admin/AdminTables/EventsTable/index.jsx +0 -176
@@ -1,11 +1,11 @@
1
- import React, { useMemo, useState, useEffect, useCallback } from 'react'
1
+ import React, { useMemo, useState, useEffect } from 'react'
2
2
  import { useViewUrlParams } from './hooks/useViewUrlParams.js'
3
3
  import { usePrepareForm } from './hooks/usePrepareForm.js'
4
4
  import { useViewPermissions } from './hooks/useViewPermissions.js'
5
5
  import { useSubmitSubject } from './hooks/useSubmitSubject.js'
6
6
  import { useCallToGetData } from './hooks/useCallToGetData.js'
7
7
  import { useViewActions } from './hooks/useViewActions.js'
8
- import AdminService from '../../services/AdminService.js'
8
+
9
9
  import { groupSubsections } from '../../../@daf/core/components/ViewForm/helper.js'
10
10
  import Loading from '../../../@daf/core/components/Loading/index.jsx'
11
11
  import Header from '../../../@daf/core/components/Header/index.jsx'
@@ -14,8 +14,7 @@ import ViewFormNavigation from '../../../@daf/core/components/ViewForm/navigatio
14
14
  import ViewForm from '../../../@daf/core/components/ViewForm/content.jsx'
15
15
  import Records from '../../../@daf/core/components/ViewForm/components/Records/index.jsx'
16
16
  import { Template } from '../Template/index.jsx'
17
- import {message} from 'antd'
18
- import { handleError } from '../../services/ErrorService.js'
17
+
19
18
  const View = ({
20
19
  push,
21
20
  getRedirectLink,
@@ -103,7 +102,7 @@ const View = ({
103
102
  viewConfig,
104
103
  });
105
104
 
106
- const { canEdit, isSupported, canDelete } = useViewPermissions({
105
+ const { canEdit, isSupported } = useViewPermissions({
107
106
  data,
108
107
  id,
109
108
  namespace,
@@ -133,28 +132,6 @@ const View = ({
133
132
  serviceMap,
134
133
  });
135
134
 
136
-
137
- const subjects = {
138
- "management-location": "location",
139
- "management-stakeholder": "stakeholder",
140
- }
141
-
142
-
143
- const handleDeleteSubject = useCallback(async () => {
144
- try {
145
- await AdminService.deleteSubject({
146
- subject: subjects[namespace],
147
- id: id,
148
- })
149
- message.success(t("Subject deleted successfully"))
150
- goTo(getRedirectLink(`/app/management/subject/${subjects[namespace]}`))
151
- } catch (error) {
152
- handleError(error)
153
- message.error(t("Failed to delete subject"))
154
- }
155
-
156
- }, [namespace, id, t])
157
-
158
135
  const { pageActions, extraPageActions } = useViewActions({
159
136
  namespace,
160
137
  data,
@@ -172,8 +149,6 @@ const View = ({
172
149
  t,
173
150
  viewConfig,
174
151
  buttonActions,
175
- canDelete,
176
- deleteSubject: handleDeleteSubject
177
152
  });
178
153
 
179
154
  useEffect(() => {
@@ -17,8 +17,6 @@ class AdminService extends BaseService {
17
17
  }
18
18
 
19
19
 
20
-
21
-
22
20
  inviteCompanyAccount({ companyId, data }) {
23
21
  return this.apiPost({
24
22
  url: `/accounts/${companyId}/invite`,
@@ -26,21 +24,6 @@ class AdminService extends BaseService {
26
24
  })
27
25
  }
28
26
 
29
- resendInvitation({invitationToken
30
- }){
31
- return this.apiPost({
32
- url: `/accounts/resendInvitation/${invitationToken}`,
33
- })
34
- }
35
-
36
- copyInvitation({invitationToken
37
- }){
38
- return this.apiPost({
39
- url: `/accounts/copyInvitation/${invitationToken}`,
40
- })
41
- }
42
-
43
-
44
27
  inviteAccount(data) {
45
28
  return this.apiPost({
46
29
  url: `/accounts/inviteAccount`,
@@ -55,14 +38,7 @@ class AdminService extends BaseService {
55
38
  })
56
39
  }
57
40
 
58
- updateAccount({ data, id, isPending=false }) {
59
- if (isPending) {
60
- return this.apiPut({
61
- data,
62
- url: `/accounts/invitation/${id}`,
63
- })
64
- }
65
-
41
+ updateAccount({ data, id }) {
66
42
  return this.apiPut({
67
43
  data,
68
44
  url: `/accounts/${id}`,
@@ -171,19 +147,6 @@ class AdminService extends BaseService {
171
147
  url: `/management/subject/${subject}/${id}`,
172
148
  });
173
149
  }
174
-
175
- getItems({ item }) {
176
- return this.apiGet({
177
- url: `/management/items/${item}`,
178
- });
179
- }
180
-
181
- getItemData({ item, id }) {
182
- return this.apiGet({
183
- url: `/management/item/${item}/${id}`,
184
- });
185
- }
186
-
187
150
 
188
151
 
189
152
  viewLocation({ id }) {
@@ -203,7 +166,7 @@ class AdminService extends BaseService {
203
166
  const type = subject === 'location' ? 'location' : 'stakeholder';
204
167
  return this.apiPut({
205
168
  url: `/management/subject/${type}/${id}`,
206
- data: data,
169
+ data: filterCreateData(data),
207
170
  });
208
171
  }
209
172
 
@@ -214,20 +177,15 @@ class AdminService extends BaseService {
214
177
  });
215
178
  }
216
179
 
217
- async getUserGrowth(activeFilter) {
218
- const { data } = await this.apiGet({
180
+ getUserGrowth(activeFilter) {
181
+ return this.apiGet({
219
182
  url: `/accounts/dashboard/user-growth`,
220
183
  isUserManager: true,
221
184
  params: { activeFilter },
222
185
  });
223
- return data;
224
186
  }
225
187
 
226
- removeUserFromAccount({ accountId, userId }) {
227
- return this.apiPut({
228
- url: `/companies/${accountId}/remove-user/${userId}`,
229
- })
230
- }
188
+
231
189
  }
232
190
 
233
191
  export default createLazyService(AdminService);
@@ -9,13 +9,13 @@ class DashboardService extends BaseService {
9
9
  isApp: true,
10
10
  });
11
11
  }
12
- async getUserGrowth(activeFilter) {
13
- const { data } = await this.apiGet({
12
+
13
+ getUserGrowth(activeFilter) {
14
+ return this.apiGet({
14
15
  url: `/accounts/dashboard/user-growth`,
15
16
  isUserManager: true,
16
17
  params: { activeFilter },
17
18
  });
18
- return data;
19
19
  }
20
20
 
21
21
  getAdminDashboard() {
@@ -63,19 +63,29 @@ export const getDefaultActiveFilters = (
63
63
  };
64
64
 
65
65
  const NEW_PAGINATION_APPS = ["nashiriki"];
66
+
66
67
  export const filterParams = (value, module) => {
67
68
  const { activeFilters, ...rest } = value;
68
69
 
69
- const { page, pageSize, sortDir, sortBy, search, searchParams, ...filters } =
70
- activeFilters || {};
70
+ const {
71
+ page = 1,
72
+ pageSize = 20,
73
+ sortDir,
74
+ sortBy,
75
+ search,
76
+ searchParams,
77
+ ...filters
78
+ } = activeFilters || {};
71
79
 
72
80
  const params = {};
73
-
81
+
74
82
  params.pagination = JSON.stringify({
75
- [NEW_PAGINATION_APPS.includes(module) ? "skip" : "page"]: page,
76
- [NEW_PAGINATION_APPS.includes(module) ? "take" : "pageSize"]: pageSize,
83
+ page,
84
+ pageSize,
77
85
  });
78
86
 
87
+ params.filters = JSON.stringify(filters);
88
+
79
89
  if (search && searchParams) {
80
90
  params.search = JSON.stringify({
81
91
  qs: search,
@@ -90,14 +100,6 @@ export const filterParams = (value, module) => {
90
100
  });
91
101
  }
92
102
 
93
- if (Object.keys(filters).length) {
94
- if (value.sourceId && value.sourceId === "overview") {
95
- params.filters = JSON.stringify(filters);
96
- } else {
97
- params.filters = JSON.stringify({ ...filters, authorId: undefined });
98
- }
99
- }
100
-
101
103
  return { ...rest, ...params };
102
104
  };
103
105
 
@@ -1,17 +1,4 @@
1
1
  const en = {
2
- "admin::events": "Events",
3
- "admin::document": "Documents",
4
- "events": "Events",
5
- "merge-locations": "Merge Locations",
6
- "edit-account": "Edit Account",
7
- "Are-you-sure-you-want-to-remove-the-user-from-this-account?": "Are you sure you want to remove the user from this account?",
8
- "The-user-will-lose-access-to-the-application-and-to-all-data-created-for-this-account.": "The user will lose access to the application and to all data created for this account.",
9
- "merge": "Merge",
10
- "Are-you-sure-you-want-to-suspend-this-account?": "Are you sure you want to suspend this account?",
11
- "Associated-users-will-lose-access-to-the-application-and-to-all-data-created-for-this-account.": "Associated users will lose access to the application and to all data created for this account.",
12
- "current_subjects": "Current Subjects",
13
- "merged_output": "Merged Output",
14
- "merge-subjects": "Merge Subjects",
15
2
  "All Data": "All Data",
16
3
  "sbg-admin::remove-user-title":"Remove User Title",
17
4
  "sbg-admin::remove-user-body":"Remove User Body",
@@ -41,63 +41,3 @@ export const copyToClipboard = (id) => {
41
41
  }
42
42
  }
43
43
  }
44
-
45
- /**
46
- * Copies a string directly to the clipboard.
47
- *
48
- * This function takes a string and copies it to the clipboard.
49
- * It handles browser compatibility issues between IE and modern browsers.
50
- *
51
- * @param {string} text - The string to copy to clipboard
52
- * @returns {Promise<boolean>} - Returns true if copying succeeded, false otherwise
53
- *
54
- * @example
55
- * copyStringToClipboard('Text to copy'); // Copies "Text to copy" to clipboard
56
- */
57
- export const copyStringToClipboard = async (text) => {
58
- if (!text) {
59
- console.warn("No text provided to copy");
60
- return false;
61
- }
62
-
63
- // Try modern Clipboard API first
64
- if (navigator.clipboard && navigator.clipboard.writeText) {
65
- try {
66
- await navigator.clipboard.writeText(text);
67
- return true;
68
- } catch (ex) {
69
- console.warn("Clipboard API failed, trying fallback:", ex);
70
- // Fall through to fallback methods
71
- }
72
- }
73
-
74
- // Fallback for older browsers or when Clipboard API fails
75
- if (window.clipboardData && window.clipboardData.setData) {
76
- // IE: prevent textarea being shown while dialog is visible
77
- return window.clipboardData.setData("Text", text);
78
- } else if (document.queryCommandSupported &&
79
- document.queryCommandSupported("copy")) {
80
- var textarea = document.createElement("textarea");
81
- textarea.textContent = text;
82
- // Prevent scrolling to bottom of page in MS Edge
83
- textarea.style.position = "fixed";
84
- textarea.style.opacity = "0";
85
- textarea.style.left = "-9999px";
86
- document.body.appendChild(textarea);
87
- textarea.select();
88
- try {
89
- // Security exception may be thrown by some browsers
90
- const success = document.execCommand("copy");
91
- return success;
92
- } catch (ex) {
93
- console.warn("Copy to clipboard failed.", ex);
94
- return false;
95
- } finally {
96
- document.body.removeChild(textarea);
97
- }
98
- }
99
-
100
- return false;
101
- }
102
-
103
-
@@ -1,67 +1,135 @@
1
1
  import { message } from 'antd';
2
2
 
3
+ /**
4
+ * Check if a successful response contains embedded error data
5
+ */
6
+ export const isErrorResponse = (data) => {
7
+ if (!data) return false;
8
+
9
+ return (
10
+ // Check for Exception names
11
+ (data.name && data.name.includes('Exception')) ||
12
+ // Check for nested response with error status
13
+ (data.response?.statusCode && data.response.statusCode >= 400) ||
14
+ // Check for top-level error status
15
+ (data.statusCode && data.statusCode >= 400) ||
16
+ // Check for explicit error flag
17
+ data.error === true ||
18
+ // Check for nested error property
19
+ (data.response?.error && data.response.error !== null)
20
+ );
21
+ };
22
+
23
+ /**
24
+ * Extract error message from various error response formats
25
+ */
26
+ export const getErrorMessage = (data) => {
27
+ return (
28
+ data?.message ||
29
+ data?.response?.message ||
30
+ data?.response?.error ||
31
+ 'An error occurred'
32
+ );
33
+ };
34
+
3
35
  /**
4
36
  * Generic error handler factory for axios requests
5
37
  * Highly configurable to adapt to different project needs
6
38
  */
7
39
  export const createErrorHandler = (config = {}) => {
8
- const {
9
- onUnauthorized,
10
- handleError,
11
- getStorageManager,
12
- checkTokenValidity = true,
13
- unauthorizedRedirect = '/',
14
- tokenStorageKey = 'token',
15
- handleNetworkError = true,
16
- } = config;
17
-
18
- return (error, customOnUnauthorized) => {
19
- // Handle cases where error.response doesn't exist (network errors)
20
- if (!error.response) {
21
- if (handleNetworkError && handleError) {
22
- handleError({
23
- status: 0,
24
- statusText: "Network Error",
25
- data: ["Please check your internet connection."],
26
- });
27
- }
28
- return Promise.reject(error);
40
+ const {
41
+ onUnauthorized,
42
+ handleError,
43
+ getStorageManager,
44
+ checkTokenValidity = true,
45
+ unauthorizedRedirect = '/',
46
+ tokenStorageKey = 'token',
47
+ handleNetworkError = true,
48
+ } = config;
49
+
50
+ return (error, customOnUnauthorized) => {
51
+ // Handle cases where error.response doesn't exist (network errors)
52
+ if (!error.response) {
53
+ if (handleNetworkError && handleError) {
54
+ handleError({
55
+ status: 0,
56
+ statusText: "Network Error",
57
+ data: ["Please check your internet connection."],
58
+ });
29
59
  }
30
-
31
- const { status, statusText, data: { errors, message } = {} } = error.response || { data: {} };
32
-
33
- // Handle 401 Unauthorized
34
- if (status === 401) {
35
- if (checkTokenValidity && getStorageManager) {
36
- const token = getStorageManager().get(tokenStorageKey);
37
- if (token) {
38
- if (typeof customOnUnauthorized === 'function') {
39
- customOnUnauthorized();
40
- } else if (typeof onUnauthorized === 'function') {
41
- onUnauthorized();
42
- } else {
43
- getStorageManager().clearOne(tokenStorageKey);
44
- if (typeof window !== 'undefined') {
45
- window.location.href = unauthorizedRedirect;
46
- }
60
+ return Promise.reject(error);
61
+ }
62
+
63
+ const { status, statusText, data: { errors, message } = {} } = error.response || { data: {} };
64
+
65
+ // Handle 401 Unauthorized
66
+ if (status === 401) {
67
+ if (checkTokenValidity && getStorageManager) {
68
+ const token = getStorageManager().get(tokenStorageKey);
69
+ if (token) {
70
+ if (typeof customOnUnauthorized === 'function') {
71
+ customOnUnauthorized();
72
+ } else if (typeof onUnauthorized === 'function') {
73
+ onUnauthorized();
74
+ } else {
75
+ getStorageManager().clearOne(tokenStorageKey);
76
+ if (typeof window !== 'undefined') {
77
+ window.location.href = unauthorizedRedirect;
47
78
  }
48
79
  }
49
80
  }
50
81
  }
51
-
52
- // Handle 4xx and 5xx errors
53
- if (status >= 400 && status <= 500) {
54
- if (handleError) {
55
- handleError({
56
- status,
57
- statusText: message || statusText,
58
- data: errors || []
59
- });
82
+ }
83
+
84
+ // Handle 4xx and 5xx errors
85
+ if (status >= 400 && status <= 500) {
86
+ if (handleError) {
87
+ handleError({
88
+ status,
89
+ statusText: message || statusText,
90
+ data: errors || []
91
+ });
92
+ }
93
+ }
94
+
95
+ return Promise.reject(error);
96
+ };
97
+ };
98
+
99
+ /**
100
+ * Create axios response interceptor to catch embedded errors in successful responses
101
+ */
102
+ export const createResponseInterceptor = (config = {}) => {
103
+ const { showNotification = true } = config;
104
+
105
+ return {
106
+ onSuccess: (response) => {
107
+ // Check if the response data contains an error
108
+ if (isErrorResponse(response.data)) {
109
+ const errorMessage = getErrorMessage(response.data);
110
+
111
+ if (showNotification) {
112
+ message.error(errorMessage);
60
113
  }
114
+
115
+ // Convert to a rejected promise so catch blocks handle it
116
+ const error = new Error(errorMessage);
117
+ error.response = {
118
+ data: response.data,
119
+ status: response.data.statusCode || response.data.response?.statusCode || 200,
120
+ statusText: errorMessage,
121
+ };
122
+ error.isEmbeddedError = true; // Flag to identify these special errors
123
+
124
+ return Promise.reject(error);
61
125
  }
62
126
 
127
+ return response;
128
+ },
129
+ onError: (error) => {
63
130
  return Promise.reject(error);
64
- };
131
+ }
132
+ };
65
133
  };
66
134
 
67
135
  /**
@@ -69,29 +137,29 @@ export const createErrorHandler = (config = {}) => {
69
137
  * Useful for quick error notifications
70
138
  */
71
139
  export const handleError = (err) => {
72
- const errorMessage = err?.response?.data?.message ||
73
- err?.message ||
74
- 'An error occurred';
75
- message.error(errorMessage);
76
- };
77
-
78
- /**
79
- * Success message handler
80
- */
81
- export const handleSuccess = (msg) => {
82
- message.success(msg || 'Operation successful');
83
- };
84
-
85
- /**
86
- * Warning message handler
87
- */
88
- export const handleWarning = (msg) => {
89
- message.warning(msg || 'Warning');
90
- };
91
-
92
- /**
93
- * Info message handler
94
- */
95
- export const handleInfo = (msg) => {
96
- message.info(msg);
97
- };
140
+ const errorMessage = err?.response?.data?.message ||
141
+ err?.message ||
142
+ 'An error occurred';
143
+ message.error(errorMessage);
144
+ };
145
+
146
+ /**
147
+ * Success message handler
148
+ */
149
+ export const handleSuccess = (msg) => {
150
+ message.success(msg || 'Operation successful');
151
+ };
152
+
153
+ /**
154
+ * Warning message handler
155
+ */
156
+ export const handleWarning = (msg) => {
157
+ message.warning(msg || 'Warning');
158
+ };
159
+
160
+ /**
161
+ * Info message handler
162
+ */
163
+ export const handleInfo = (msg) => {
164
+ message.info(msg);
165
+ };
package/src/utils.js CHANGED
@@ -46,7 +46,7 @@ export { StorageManager } from './helpers/StorageManager.js';
46
46
 
47
47
  export { assignParamsToUrl, buildQueryString } from './helpers/urlHelpers.js';
48
48
 
49
- export { createErrorHandler, handleError, handleSuccess, handleWarning, handleInfo } from './helpers/errorHandling.js';
49
+ export { createErrorHandler, handleError, handleSuccess, handleWarning, handleInfo, isErrorResponse, getErrorMessage } from './helpers/errorHandling.js';
50
50
 
51
51
  export { createTheme, createAdminTheme } from './helpers/theme.js';
52
52
 
@@ -1,81 +0,0 @@
1
- import React, { useCallback } from "react";
2
- import { message } from "antd";
3
- import DocumentsTable from "../AdminTables/DocumentsTable/index.jsx";
4
- /**
5
- * Admin Location Screen Wrapper
6
- * This is a ready-to-use route component that can be configured per application
7
- *
8
- * @param {Object} config - Application configuration
9
- * @param {string} config.appName - Application name
10
- * @param {string} config.module - Module identifier (APP constant)
11
- * @param {Function} config.goTo - Navigation function
12
- * @param {Function} config.t - Translation function
13
- * @param {Object} config.location - Router location object
14
- * @param {boolean} config.isMobile - Is mobile viewport
15
- * @param {Function} config.getRedirectLink - Function to get redirect links
16
- * @param {Object} config.AdminService - Admin service with methods
17
- * @param {Object} config.options - Options object with categories, countries, etc.
18
- * @param {Function} config.handleError - Error handling function
19
- * @param {number} config.defaultPageSize - Default pagination page size
20
- * @param {string} config.view - View identifier
21
- * @param {string} config.headerTitle - Header title for the table
22
- * @param {Array} config.breadcrumbs - Breadcrumbs configuration
23
- * @param {any} config.refetchTrigger - Trigger to refetch data
24
- * @param {Function} config.getData - Optional custom getData function
25
- */
26
- export default function AdminLocationScreen({ config }) {
27
- const {
28
- appName = "app",
29
- module,
30
- goTo,
31
- t,
32
- location,
33
- isMobile,
34
- getRedirectLink,
35
- AdminService,
36
- options,
37
- handleError,
38
- defaultPageSize = 20,
39
- view,
40
- headerTitle = "documents",
41
- breadcrumbs,
42
- refetchTrigger,
43
- getData,
44
- user,
45
- } = config;
46
-
47
-
48
-
49
- const getSubjects = useCallback((params) => {
50
- if (getData) {
51
- return getData(params);
52
- }
53
- return AdminService.getItems({ item: 'document', params });
54
- }, [getData, AdminService]);
55
-
56
- return (
57
- <DocumentsTable
58
- t={t}
59
- goTo={goTo}
60
- getRedirectLink={getRedirectLink}
61
- location={location}
62
- module={module}
63
- headerTitle={headerTitle}
64
- getData={getSubjects}
65
- isMobile={isMobile}
66
- defaultPageSize={defaultPageSize}
67
- view={view}
68
- breadcrumbs={breadcrumbs}
69
- refetchTrigger={refetchTrigger}
70
- config={{
71
- options: {
72
- category: options?.category,
73
- countries: options?.countries,
74
- },
75
- }}
76
- user={user}
77
- options={options}
78
- />
79
- );
80
- }
81
-