datastake-daf 0.6.809 → 0.6.810
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/build/favicon.ico +0 -0
- package/build/logo192.png +0 -0
- package/build/logo512.png +0 -0
- package/build/manifest.json +25 -0
- package/build/robots.txt +3 -0
- package/dist/components/index.js +215 -527
- package/dist/hooks/index.js +4 -11
- package/dist/pages/index.js +228 -224
- package/dist/services/index.js +5 -19
- package/dist/utils/index.js +5 -24
- package/package.json +1 -1
- package/src/@daf/core/components/AuthForm/index.jsx +3 -12
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/index.jsx +1 -0
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/hook.js +1 -0
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/index.jsx +3 -1
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/index.jsx +51 -51
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineSubjects/index.jsx +1 -6
- package/src/@daf/core/components/Screens/Admin/AdminModals/NewAccount/index.jsx +12 -47
- package/src/@daf/core/components/Screens/Admin/AdminModals/NewUser/index.jsx +10 -36
- package/src/@daf/core/components/Screens/Admin/AdminModals/TransferRights/index.jsx +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Accounts.jsx +0 -1
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Dashboard.jsx +2 -2
- package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/helper.js +30 -22
- package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/index.jsx +3 -4
- package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/index.jsx +2 -6
- package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/index.jsx +12 -14
- package/src/@daf/core/components/Screens/Admin/AdminTables/UserTable/index.jsx +1 -0
- package/src/@daf/core/components/Screens/Admin/AdminTables/hook.js +0 -3
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Edit/index.jsx +9 -12
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/index.jsx +4 -16
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/View/helpers.js +17 -9
- package/src/@daf/core/components/Screens/Admin/AdminViews/index.jsx +8 -9
- package/src/@daf/core/components/Screens/Admin/AppInvitation/index.jsx +99 -124
- package/src/@daf/hooks/useAdminDashboard.js +4 -7
- package/src/@daf/pages/Locations/MineSite/columns.js +18 -1
- package/src/@daf/pages/Locations/MineSite/config.js +2 -2
- package/src/@daf/services/AdminService.js +4 -15
- package/src/@daf/services/DashboardService.js +3 -3
- package/src/@daf/utils/filters.js +15 -13
- package/src/constants/locales/en/translation.js +0 -9
|
@@ -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
|
-
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
|
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("
|
|
74
|
+
title: t("sbg-admin::suspend-title"),
|
|
78
75
|
icon: <ExclamationCircleOutlined />,
|
|
79
|
-
content:
|
|
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("
|
|
75
|
+
title: t("sbg-admin::remove-user-title"),
|
|
77
76
|
icon: <ExclamationCircleOutlined />,
|
|
78
|
-
content:
|
|
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 = []
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
|
192
|
+
return user ? <Navigate to={appRedirectPath} /> : <Navigate to={redirectPath} />;
|
|
218
193
|
}
|
|
@@ -46,20 +46,15 @@ export function useAdminDashboard({ dashboardService, onError }) {
|
|
|
46
46
|
}, [dashboardService, onError]);
|
|
47
47
|
|
|
48
48
|
const fetchUserGrowth = useCallback(
|
|
49
|
-
async (
|
|
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(
|
|
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,
|
|
@@ -39,7 +39,24 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
|
|
|
39
39
|
|
|
40
40
|
return <Tooltip title={v}>{v}</Tooltip>;
|
|
41
41
|
},
|
|
42
|
-
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
dataIndex: 'category',
|
|
45
|
+
title: t('Category'),
|
|
46
|
+
ellipsis: true,
|
|
47
|
+
show: true,
|
|
48
|
+
render: (v, all) => {
|
|
49
|
+
if (all.empty) {
|
|
50
|
+
return <div className="daf-default-cell" />
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const locationCategories = [...(data?.options?.locationCategories || []), ...(options?.productionSiteCategories || [])]
|
|
54
|
+
|
|
55
|
+
const category = findOptions(v, locationCategories);
|
|
56
|
+
|
|
57
|
+
return category ? <Tooltip title={category}>{category}</Tooltip> : '-';
|
|
58
|
+
},
|
|
59
|
+
},
|
|
43
60
|
{
|
|
44
61
|
dataIndex: 'region',
|
|
45
62
|
title: findOptions(user?.company?.country, options?.administrativeLevel1)?.length > 2 ? findOptions(user?.company?.country, options?.administrativeLevel1) : t("Province"),
|
|
@@ -85,8 +85,8 @@ export const getFiltersConfig = ({t}) => {
|
|
|
85
85
|
},
|
|
86
86
|
category: {
|
|
87
87
|
type: 'select',
|
|
88
|
-
label: '
|
|
89
|
-
placeholder: () => `${t('Filter by')} ${t('
|
|
88
|
+
label: 'Category',
|
|
89
|
+
placeholder: () => `${t('Filter by')} ${t('Category').toLowerCase()}`,
|
|
90
90
|
style: { flex: 1 },
|
|
91
91
|
labelStyle: { flex: 1 },
|
|
92
92
|
getLabel: (option) => option.label,
|
|
@@ -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,10 +24,6 @@ class AdminService extends BaseService {
|
|
|
26
24
|
})
|
|
27
25
|
}
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
27
|
inviteAccount(data) {
|
|
34
28
|
return this.apiPost({
|
|
35
29
|
url: `/accounts/inviteAccount`,
|
|
@@ -172,7 +166,7 @@ class AdminService extends BaseService {
|
|
|
172
166
|
const type = subject === 'location' ? 'location' : 'stakeholder';
|
|
173
167
|
return this.apiPut({
|
|
174
168
|
url: `/management/subject/${type}/${id}`,
|
|
175
|
-
data: data,
|
|
169
|
+
data: filterCreateData(data),
|
|
176
170
|
});
|
|
177
171
|
}
|
|
178
172
|
|
|
@@ -183,20 +177,15 @@ class AdminService extends BaseService {
|
|
|
183
177
|
});
|
|
184
178
|
}
|
|
185
179
|
|
|
186
|
-
|
|
187
|
-
|
|
180
|
+
getUserGrowth(activeFilter) {
|
|
181
|
+
return this.apiGet({
|
|
188
182
|
url: `/accounts/dashboard/user-growth`,
|
|
189
183
|
isUserManager: true,
|
|
190
184
|
params: { activeFilter },
|
|
191
185
|
});
|
|
192
|
-
return data;
|
|
193
186
|
}
|
|
194
187
|
|
|
195
|
-
|
|
196
|
-
return this.apiDelete({
|
|
197
|
-
url: `/accounts/${accountId}/users/${userId}`,
|
|
198
|
-
})
|
|
199
|
-
}
|
|
188
|
+
|
|
200
189
|
}
|
|
201
190
|
|
|
202
191
|
export default createLazyService(AdminService);
|
|
@@ -9,13 +9,13 @@ class DashboardService extends BaseService {
|
|
|
9
9
|
isApp: true,
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
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 {
|
|
70
|
-
|
|
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
|
-
|
|
76
|
-
|
|
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,13 +1,4 @@
|
|
|
1
1
|
const en = {
|
|
2
|
-
"edit-account": "Edit Account",
|
|
3
|
-
"Are-you-sure-you-want-to-remove-the-user-from-this-account?": "Are you sure you want to remove the user from this account?",
|
|
4
|
-
"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.",
|
|
5
|
-
"merge": "Merge",
|
|
6
|
-
"Are-you-sure-you-want-to-suspend-this-account?": "Are you sure you want to suspend this account?",
|
|
7
|
-
"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.",
|
|
8
|
-
"current_subjects": "Current Subjects",
|
|
9
|
-
"merged_output": "Merged Output",
|
|
10
|
-
"merge-subjects": "Merge Subjects",
|
|
11
2
|
"All Data": "All Data",
|
|
12
3
|
"sbg-admin::remove-user-title":"Remove User Title",
|
|
13
4
|
"sbg-admin::remove-user-body":"Remove User Body",
|