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
@@ -3,7 +3,7 @@ import { ExclamationCircleOutlined } from "@ant-design/icons";
3
3
  import { useCallback, useEffect } from "react";
4
4
  import { useForms } from "../../../../../../context/Forms/index.js";
5
5
  import Users from "../Users/index.jsx";
6
- import AdminService from "../../../../../../../services/AdminService.js";
6
+
7
7
  export default function Edit({
8
8
  t,
9
9
  goTo,
@@ -37,17 +37,14 @@ export default function Edit({
37
37
  }, [isChanged, addCheck, removeCheck]);
38
38
 
39
39
  const deleteUser = useCallback(
40
- async (id) => {
41
- try {
42
- await AdminService.removeUserFromAccount({ accountId: data.id, userId: id });
43
- message.success(t("User removed successfully"));
44
- fetchData();
45
- } catch (err) {
46
- handleError(err);
47
- }
40
+ (id) => {
41
+ // TODO: add call
42
+ console.log("DELETE", id);
43
+ fetchData();
48
44
  },
49
- [fetchData, data.id, t, handleError],
45
+ [fetchData],
50
46
  );
47
+
51
48
  const updateUser = useCallback((id, val) => {
52
49
  setIsChanged(true);
53
50
  setData((prev) => ({
@@ -74,9 +71,9 @@ export default function Edit({
74
71
 
75
72
  const onSuspend = () => {
76
73
  Modal.confirm({
77
- title: t("Are-you-sure-you-want-to-suspend-this-account?"),
74
+ title: t("sbg-admin::suspend-title"),
78
75
  icon: <ExclamationCircleOutlined />,
79
- content: <span style={{ color: "#888" }}>{t("Associated-users-will-lose-access-to-the-application-and-to-all-data-created-for-this-account.")}</span>,
76
+ content: t("sbg-admin::suspend-content"),
80
77
  okText: t("Yes"),
81
78
  cancelText: t("No"),
82
79
  onOk: async () => {
@@ -34,7 +34,6 @@ export default function Users({
34
34
  inviteCompanyAccount = () => {},
35
35
  companyId,
36
36
  handleError = () => {},
37
-
38
37
  }) {
39
38
  const [hasError, setHasError] = useState(false);
40
39
  const [showFilters, setShowFilters] = useState(false);
@@ -73,9 +72,9 @@ export default function Users({
73
72
  const onDeleteUserClick = useCallback(
74
73
  (id) => {
75
74
  Modal.confirm({
76
- title: t("Are-you-sure-you-want-to-remove-the-user-from-this-account?"),
75
+ title: t("sbg-admin::remove-user-title"),
77
76
  icon: <ExclamationCircleOutlined />,
78
- content: <span style={{ color: "#888" }}>{t("The-user-will-lose-access-to-the-application-and-to-all-data-created-for-this-account.")}</span>,
77
+ content: t("sbg-admin::remove-user-body"),
79
78
  okText: t("Yes"),
80
79
  cancelText: t("No"),
81
80
  onOk: () => {
@@ -88,15 +87,8 @@ export default function Users({
88
87
  );
89
88
 
90
89
  const data = useMemo(() => {
91
- const { users = [], pendingUsers = [] } = accountData;
92
- let filtered = [
93
- ...users,
94
- ...pendingUsers.map(u => ({
95
- ...u,
96
- status: 'pending',
97
- id: u.invitationToken || u.email // ensure pending users have an ID
98
- }))
99
- ];
90
+ const { users = [] } = accountData;
91
+ let filtered = [...users];
100
92
 
101
93
  if (!isEmptyOrSpaces(activeFilters.search)) {
102
94
  const search = activeFilters.search.toLowerCase();
@@ -194,10 +186,6 @@ export default function Users({
194
186
  inviteCompanyAccount={inviteCompanyAccount}
195
187
  companyId={companyId}
196
188
  handleError={handleError}
197
- existingEmails={[
198
- ...(accountData?.users || []).map(u => u.email?.toLowerCase()),
199
- ...(accountData?.pendingUsers || []).map(u => u.email?.toLowerCase()),
200
- ].filter(Boolean)}
201
189
  />
202
190
  </div>
203
191
  );
@@ -1,15 +1,23 @@
1
1
  import { Tag } from "antd";
2
2
 
3
3
  export const renderStatus = ({ val, t = (s) => s }) => {
4
- if (val === 'pending') {
5
- return <Tag color="orange">{t("Pending")}</Tag>;
6
- }
7
- if (val === 'unsaved') {
8
- return <Tag color="red">{t("Unsaved")}</Tag>;
9
- }
10
- if (val === 'active' || val === true) {
4
+ // switch (val) {
5
+ // case "active":
6
+ // return <Tag color="green">{t("Active")}</Tag>;
7
+ // case "unsaved":
8
+ // return <Tag color="red">{t("Unsaved")}</Tag>;
9
+ // case "inactive":
10
+ // case "suspended":
11
+ // return <Tag color="red">{t("Suspended")}</Tag>;
12
+ // case "pending":
13
+ // return <Tag color="orange">{t("Pending")}</Tag>;
14
+ // default:
15
+ // return <Tag color="default">{t("Unknown")}</Tag>;
16
+ // }
17
+
18
+ if (val) {
11
19
  return <Tag color="green">{t("Active")}</Tag>;
20
+ } else {
21
+ return <Tag color="red">{t("Suspended")}</Tag>;
12
22
  }
13
-
14
- return <Tag color="red">{t("Suspended")}</Tag>;
15
23
  };
@@ -172,15 +172,14 @@ function AdminView({
172
172
  try {
173
173
  const { pendingCompanyId, status, ...userDataToInvite } = user;
174
174
  console.log('Sending invitation for:', user.email, userDataToInvite);
175
- // Use the standalone invite function, don't mix it with updateAccount
176
- // await inviteCompanyAccount({
177
- // companyId: editData.id,
178
- // data: {
179
- // ...userDataToInvite,
180
- // pendingCompanyId,
181
- // },
182
- // });
183
- // console.log('Invitation sent successfully for:', user.email);
175
+ await inviteCompanyAccount({
176
+ companyId: editData.id,
177
+ data: {
178
+ ...userDataToInvite,
179
+ pendingCompanyId,
180
+ },
181
+ });
182
+ console.log('Invitation sent successfully for:', user.email);
184
183
  } catch (inviteError) {
185
184
  console.error('Failed to invite user:', user.email, inviteError);
186
185
  handleError(inviteError);
@@ -1,30 +1,30 @@
1
1
  import React, { useState, useEffect } from "react";
2
- import { Checkbox, message } from 'antd';
2
+ import { Checkbox, Form, Input, message } from 'antd';
3
3
  import DafButton from '../../../Button/index.jsx';
4
4
  import Loading from "../../../Loading/index.jsx";
5
- import AuthForm from "../../../AuthForm/index.jsx";
6
5
 
7
-
8
-
9
- const theme = window.theme;
10
6
  export default function AppInvitation({
7
+ // Redux State
11
8
  errors,
12
9
  user,
13
10
  invitationSuccess,
11
+ // Actions
14
12
  confirmInvitation,
15
13
  getUserFromInvitation,
16
- theme,
14
+ // Configuration
17
15
  Layout,
18
16
  redirectPath = "/",
19
17
  loginPath = "/login",
20
18
  appRedirectPath = "/app",
21
19
  params: propParams = {},
22
- goTo,
23
- isMobile = false,
24
- t,
25
20
  }) {
26
- const { app, companyCode, userCode } = propParams;
21
+ const { t } = useTranslation();
22
+ const routeParams = useParams();
23
+ const { app, companyCode, userCode } = { ...routeParams, ...propParams };
24
+ const [passwords] = Form.useForm();
27
25
  const [checking, setChecking] = useState(true);
26
+ const goTo = useNavigate();
27
+ const [termsAgreed, setTermsAgreed] = useState(false);
28
28
  const [passwordReseted, setPasswordReseted] = useState(false);
29
29
 
30
30
  useEffect(() => {
@@ -46,125 +46,36 @@ export default function AppInvitation({
46
46
  localStorage.setItem('token', data.token);
47
47
  }
48
48
  message.success(t('Invitation accepted'));
49
- if (goTo && typeof goTo === 'function') {
50
- goTo(redirectPath);
51
- } else {
52
- window.location.href = redirectPath;
53
- }
49
+ // Fix: ensure we don't rely on a variable from useParams that might not exist
50
+ // Just use the configured redirectPath
51
+ goTo(redirectPath);
54
52
  },
55
53
  { companyCode, userCode }
56
54
  );
57
55
  }
58
56
  }, [invitationSuccess, user, confirmInvitation, goTo, redirectPath, companyCode, userCode, t]);
59
57
 
60
-
61
- useEffect(() => {
62
-
63
- const isInInvitationFlow = checking ||
64
- (invitationSuccess && user && user.inviteToken) ||
65
- (invitationSuccess && user && !user.inviteToken);
66
-
67
- if (!isInInvitationFlow) {
68
- if (user) {
69
- if (goTo && typeof goTo === 'function') {
70
- goTo(appRedirectPath);
71
- } else {
72
- window.location.href = appRedirectPath;
73
- }
74
- } else {
75
- if (goTo && typeof goTo === 'function') {
76
- goTo(redirectPath);
77
- } else {
78
- window.location.href = redirectPath;
79
- }
80
- }
81
- }
82
- }, [user, goTo, appRedirectPath, redirectPath, checking, invitationSuccess]);
58
+ const displayError = (name) => {
59
+ return errors && errors[name] && errors[name].length > 0 && {
60
+ help: errors[name][0],
61
+ validateStatus: 'error',
62
+ };
63
+ };
83
64
 
84
65
  const subTitle = !passwordReseted ? 'Set up your password and agree with out terms and conditions.' :
85
66
  isMobile ? 'Your account has been successfully set up. To log in use a desktop device.'
86
67
  : 'Your account has been successfully set up. Please click the button below to log in.';
87
68
  const title = passwordReseted ? 'Thank You!' : undefined;
88
69
 
89
- const fields = [
90
- {
91
- name: 'email',
92
- label: t("Email"),
93
- type: 'input',
94
- disabled: true,
95
- },
96
- {
97
- name: 'password',
98
- label: t("Password"),
99
- type: 'password',
100
- required: true,
101
- rules: [{
102
- required: true,
103
- message: t("errors::password should not be empty")
104
- }],
105
- placeholder: t("Password"),
106
- },
107
- {
108
- name: 'confirmPassword',
109
- label: t("Confirm Password"),
110
- type: 'password',
111
- required: true,
112
- dependencies: ['password'],
113
- rules: [
114
- {
115
- required: true,
116
- message: t("errors::password should not be empty"),
117
- },
118
- ({ getFieldValue }) => ({
119
- validator(rule, value) {
120
- if (!value || getFieldValue('password') === value) {
121
- return Promise.resolve();
122
- }
123
- return Promise.reject(t('errors::passwordNotMatch'));
124
- },
125
- }),
126
- ],
127
- placeholder: t("Confirm Password"),
128
- },
129
- {
130
- name: 'mailUpdates',
131
- type: 'custom',
132
- valuePropName: 'checked',
133
- component: <Checkbox>{t("Sign up to receive updates")}</Checkbox>,
134
- },
135
- {
136
- name: 'agreeTerms',
137
- type: 'custom',
138
- valuePropName: 'checked',
139
- rules: [{
140
- validator: (_, value) => value ? Promise.resolve() : Promise.reject(new Error(t('You must agree to the terms and conditions')))
141
- }],
142
- component: (
143
- <Checkbox>
144
- <p className="mb-0">
145
- {t('Agree to the Terms of Use of this application and the Privacy Policy')}
146
- </p>
147
- </Checkbox>
148
- ),
149
- }
150
- ];
151
-
152
- const handleSubmit = (values) => {
153
- const { password, mailUpdates } = values;
154
- confirmInvitation(
155
- { password, mailUpdates },
156
- () => { },
157
- { companyCode, userCode }
158
- );
159
- setPasswordReseted(true);
160
- };
161
-
162
70
  if (checking && !invitationSuccess) {
163
71
  return <Loading />;
164
72
  }
165
73
 
74
+ // If auto-confirming (inviteToken present), we might want to show loading or nothing until redirect
166
75
  if (invitationSuccess && user && user.inviteToken) {
167
-
76
+ // The useEffect will handle the redirect/confirm.
77
+ // We can show loading here too or just return null.
78
+ // Original code: checks invitationSuccess && !user.inviteToken for form, else redirect.
168
79
  return <Loading />;
169
80
  }
170
81
 
@@ -177,7 +88,6 @@ export default function AppInvitation({
177
88
  <DafButton
178
89
  type="primary"
179
90
  className="normal-br"
180
- style={theme || window.theme ? { backgroundColor: (theme || window.theme).colorPrimary, borderColor: (theme || window.theme).colorPrimary } : {}}
181
91
  onClick={() => {
182
92
  window.location.href = loginPath;
183
93
  }}
@@ -187,21 +97,86 @@ export default function AppInvitation({
187
97
  )}
188
98
  </div>
189
99
  ) : (
190
- <AuthForm
191
- fields={fields}
192
- onSubmit={handleSubmit}
193
- submitText={t("Confirm")}
194
- initialValues={{ email: user?.email }}
195
- errors={errors}
196
- t={t}
197
- executeRecaptcha={() => Promise.resolve(true)}
198
- theme={theme || window.theme}
199
- />
100
+ <>
101
+ <Form name="password" layout="vertical" form={passwords} >
102
+ <Form.Item
103
+ required
104
+ name="password"
105
+ {...displayError('password')}
106
+ label={t("Password")}
107
+ rules={[{
108
+ required: true,
109
+ message: t("errors::password should not be empty")
110
+ }]}>
111
+ <Input.Password size="large" placeholder={t("Password")} />
112
+ </Form.Item>
113
+ <Form.Item
114
+ required
115
+ name="confirmPassword"
116
+ {...displayError('confirmPassword')}
117
+ label={t("Confirm Password")}
118
+ dependencies={['password']}
119
+ rules={[
120
+ {
121
+ required: true,
122
+ message: t("errors::password should not be empty"),
123
+ },
124
+ ({ getFieldValue }) => ({
125
+ validator(rule, value) {
126
+ if (!value || getFieldValue('password') === value) {
127
+ return Promise.resolve();
128
+ }
129
+ return Promise.reject(t('errors::passwordNotMatch'));
130
+ },
131
+ }),
132
+ ]}>
133
+ <Input.Password size="large" placeholder={t("Confirm Password")} />
134
+ </Form.Item>
135
+ <Form.Item
136
+ name="mailUpdates" valuePropName="checked" noStyle>
137
+ <Checkbox>{t("Sign up to receive updates")}</Checkbox>
138
+ </Form.Item>
139
+ <Form.Item
140
+ name="agreeTerms" valuePropName="checked" noStyle>
141
+ <Checkbox
142
+ checked={termsAgreed}
143
+ onChange={(e) => setTermsAgreed(e.target.checked)}
144
+ >
145
+ <p className="mb-0">
146
+ {t('Agree to the Terms of Use of this application and the Privacy Policy')}
147
+ </p>
148
+ </Checkbox>
149
+ </Form.Item>
150
+ </Form>
151
+ <div className="buttons">
152
+ <DafButton
153
+ className="normal-br"
154
+ type="primary"
155
+ block
156
+ size="large"
157
+ disabled={!termsAgreed}
158
+ onClick={() => {
159
+ passwords.validateFields().then(data => {
160
+ const { password, mailUpdates } = data;
161
+ confirmInvitation(
162
+ { password, mailUpdates },
163
+ () => { },
164
+ { companyCode, userCode }
165
+ );
166
+ setPasswordReseted(true);
167
+ });
168
+ }}
169
+ >
170
+ {t("Confirm")}
171
+ </DafButton>
172
+ </div>
173
+ </>
200
174
  )}
201
175
  </>
202
176
  );
203
177
 
204
178
  if (Layout) {
179
+ // Assuming Layout accepts these props as per Nashiriki AuthLayout
205
180
  return <Layout app={app} step={1} subTitle={subTitle} title={title}>{Content}</Layout>;
206
181
  }
207
182
 
@@ -214,5 +189,5 @@ export default function AppInvitation({
214
189
  );
215
190
  }
216
191
 
217
- return null;
192
+ return user ? <Navigate to={appRedirectPath} /> : <Navigate to={redirectPath} />;
218
193
  }
@@ -6,8 +6,7 @@ import AdminAccountsViewScreen from "./AdminScreens/AccountsView.jsx";
6
6
  import AdminSubjectsScreen from "./AdminScreens/Subjects.jsx";
7
7
  import AdminLocationScreen from "./AdminScreens/Location.jsx";
8
8
  import AdminSubjectsViewScreen from "./AdminScreens/SubjectsView.jsx";
9
- import AdminEventsScreen from "./AdminScreens/Events.jsx";
10
- import AdminDocumentsScreen from "./AdminScreens/Documents.jsx";
9
+
11
10
  export function getAdminRoutes(config) {
12
11
  const {
13
12
  appName,
@@ -19,8 +18,6 @@ export function getAdminRoutes(config) {
19
18
  useAdminLocationConfig,
20
19
  useAdminSubjectsViewConfig,
21
20
  useAdminLocationViewConfig,
22
- useAdminDocumentsConfig,
23
- useAdminEventsConfig,
24
21
  userIsAdmin,
25
22
  } = config;
26
23
 
@@ -94,31 +91,11 @@ export function getAdminRoutes(config) {
94
91
  return <AdminSubjectsViewScreen config={{ ...stakeholderViewConfig, subject: "stakeholder", mode: "edit" }} />;
95
92
  }
96
93
 
97
- function DocumentsWrapper() {
98
- const documentsConfig =
99
- typeof useAdminDocumentsConfig === "function"
100
- ? useAdminDocumentsConfig()
101
- : undefined;
102
- return <AdminDocumentsScreen config={documentsConfig} />;
103
- }
104
-
105
- function EventsWrapper() {
106
- const eventsConfig =
107
- typeof useAdminEventsConfig === "function"
108
- ? useAdminEventsConfig()
109
- : undefined;
110
- return <AdminEventsScreen config={eventsConfig} />;
111
- }
112
-
113
94
  const subjectsIndexComponent =
114
95
  typeof useAdminLocationConfig === "function"
115
96
  ? <LocationWrapper />
116
97
  : typeof useAdminSubjectsConfig === "function"
117
98
  ? <SubjectsWrapper />
118
- : typeof useAdminDocumentsConfig === "function"
119
- ? <DocumentsWrapper />
120
- : typeof useAdminEventsConfig === "function"
121
- ? <EventsWrapper />
122
99
  : <div />;
123
100
 
124
101
  const routes = [
@@ -179,30 +156,6 @@ export function getAdminRoutes(config) {
179
156
  visible: (user) => userIsAdmin(user),
180
157
  component: <SubjectsWrapper />,
181
158
  },
182
-
183
- ]
184
-
185
- : []),
186
- ...(typeof useAdminDocumentsConfig === "function"
187
- ? [
188
- {
189
- path: "management/subjects/document",
190
- key: `${APP_PREFIX}_ADMIN_SUBJECTS_DOCUMENTS`,
191
- exact: true,
192
- visible: (user) => userIsAdmin(user),
193
- component: <DocumentsWrapper />,
194
- },
195
- ]
196
- : []),
197
- ...(typeof useAdminEventsConfig === "function"
198
- ? [
199
- {
200
- path: "management/subjects/event",
201
- key: `${APP_PREFIX}_ADMIN_SUBJECTS_EVENTS`,
202
- exact: true,
203
- visible: (user) => userIsAdmin(user),
204
- component: <EventsWrapper />,
205
- },
206
159
  ]
207
160
  : []),
208
161
  ];
@@ -36,7 +36,12 @@ export default function DAFTable({
36
36
  doEmptyRows,
37
37
  ...rest
38
38
  }) {
39
- const [source, setSource] = useState([]);
39
+ const source = useMemo(() => {
40
+ if (data && Array.isArray(data)) {
41
+ return data;
42
+ }
43
+ return [];
44
+ }, [data]);
40
45
  const projectData = (projects || []).find(p => p.id === selectedProject);
41
46
  const [filtersInit, setFiltersInit] = useState(!loading);
42
47
 
@@ -85,11 +90,11 @@ export default function DAFTable({
85
90
  } : filtersConfig;
86
91
  }, [sourcesKey, sources, filtersConfig, t]);
87
92
 
88
- useEffect(() => {
89
- if (data && Array.isArray(data)) {
90
- setSource(data);
91
- }
92
- }, [data, data.length]);
93
+ // useEffect(() => {
94
+ // if (data && Array.isArray(data)) {
95
+ // setSource(data);
96
+ // }
97
+ // }, [data, data.length]);
93
98
 
94
99
  const paginationPageSize = pagination?.pageSize;
95
100
  const dataSource = useMemo(() => {
@@ -46,20 +46,15 @@ export function useAdminDashboard({ dashboardService, onError }) {
46
46
  }, [dashboardService, onError]);
47
47
 
48
48
  const fetchUserGrowth = useCallback(
49
- async (activeFilter) => {
49
+ async (params) => {
50
50
  if (!dashboardService?.getUserGrowth) {
51
51
  console.warn("dashboardService.getUserGrowth not provided");
52
52
  return;
53
53
  }
54
54
 
55
- if (activeFilter === undefined || activeFilter === null) {
56
- console.warn("activeFilter not provided to fetchUserGrowth");
57
- return;
58
- }
59
-
60
55
  setUserGrowthDataLoading(true);
61
56
  try {
62
- const response = await dashboardService.getUserGrowth(activeFilter);
57
+ const response = await dashboardService.getUserGrowth(params);
63
58
  setUserGrowthData(response || []);
64
59
  } catch (err) {
65
60
  if (onError) {
@@ -73,9 +68,11 @@ export function useAdminDashboard({ dashboardService, onError }) {
73
68
  },
74
69
  [dashboardService, onError]
75
70
  );
71
+
76
72
  useEffect(() => {
77
73
  fetchDashboardData();
78
74
  }, [fetchDashboardData]);
75
+
79
76
  return {
80
77
  data,
81
78
  loading,
@@ -117,19 +117,23 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
117
117
  },
118
118
  },
119
119
  {
120
- title: t("Sources"),
121
- dataIndex: "sources",
122
- key: "sources",
123
- show: activeTab !== "own",
124
- render: (val, all) => {
125
- if (all.empty) {
126
- return <div className="daf-default-cell" />;
127
- }
120
+ title: t("Sources"),
121
+ dataIndex: "sources",
122
+ key: "sources",
123
+ show: activeTab !== "own",
124
+ render: (val, all) => {
125
+ if (all.empty) {
126
+ return <div className="daf-default-cell" />;
127
+ }
128
128
 
129
- const sources = sourceAvatarConfig(val, user, applications);
129
+ if (!val || val?.length === 0) {
130
+ return "-";
131
+ }
130
132
 
131
- return <AvatarGroup items={sources}></AvatarGroup>;
132
- },
133
+ const sources = sourceAvatarConfig(val, user, applications);
134
+
135
+ return <AvatarGroup items={sources} />;
136
+ },
133
137
  },
134
138
  {
135
139
  title: t("Status"),
@@ -117,19 +117,23 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
117
117
  },
118
118
  },
119
119
  {
120
- title: t("Sources"),
121
- dataIndex: "sources",
122
- key: "sources",
123
- show: activeTab !== "own",
124
- render: (val, all) => {
125
- if (all.empty) {
126
- return <div className="daf-default-cell" />;
127
- }
120
+ title: t("Sources"),
121
+ dataIndex: "sources",
122
+ key: "sources",
123
+ show: activeTab !== "own",
124
+ render: (val, all) => {
125
+ if (all.empty) {
126
+ return <div className="daf-default-cell" />;
127
+ }
128
128
 
129
- const sources = sourceAvatarConfig(val, user, applications);
129
+ if (!val || val?.length === 0) {
130
+ return "-";
131
+ }
130
132
 
131
- return <AvatarGroup items={sources}></AvatarGroup>;
132
- },
133
+ const sources = sourceAvatarConfig(val, user, applications);
134
+
135
+ return <AvatarGroup items={sources} />;
136
+ },
133
137
  },
134
138
  {
135
139
  title: t("Status"),