datastake-daf 0.6.808 → 0.6.809
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/index.js +2104 -1654
- package/dist/hooks/index.js +11 -4
- package/dist/pages/index.js +222 -208
- package/dist/services/index.js +19 -5
- package/dist/utils/index.js +24 -5
- package/package.json +1 -1
- package/src/@daf/core/components/AuthForm/index.jsx +12 -3
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/index.jsx +0 -1
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/hook.js +0 -1
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/index.jsx +1 -3
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/index.jsx +51 -51
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineSubjects/index.jsx +6 -1
- package/src/@daf/core/components/Screens/Admin/AdminModals/NewAccount/index.jsx +47 -12
- package/src/@daf/core/components/Screens/Admin/AdminModals/NewUser/index.jsx +36 -10
- package/src/@daf/core/components/Screens/Admin/AdminModals/TransferRights/index.jsx +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Accounts.jsx +1 -0
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Dashboard.jsx +2 -2
- package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/helper.js +22 -30
- package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/index.jsx +4 -3
- package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/index.jsx +6 -2
- package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/index.jsx +14 -12
- package/src/@daf/core/components/Screens/Admin/AdminTables/UserTable/index.jsx +0 -1
- package/src/@daf/core/components/Screens/Admin/AdminTables/hook.js +3 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Edit/index.jsx +12 -9
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/index.jsx +16 -4
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/View/helpers.js +9 -17
- package/src/@daf/core/components/Screens/Admin/AdminViews/index.jsx +9 -8
- package/src/@daf/core/components/Screens/Admin/AppInvitation/index.jsx +124 -99
- package/src/@daf/hooks/useAdminDashboard.js +7 -4
- package/src/@daf/services/AdminService.js +15 -4
- package/src/@daf/services/DashboardService.js +3 -3
- package/src/@daf/utils/filters.js +13 -15
- package/src/constants/locales/en/translation.js +9 -0
- package/build/favicon.ico +0 -0
- package/build/logo192.png +0 -0
- package/build/logo512.png +0 -0
- package/build/manifest.json +0 -25
- package/build/robots.txt +0 -3
|
@@ -12,7 +12,6 @@ export default function useUserGrowth({ container, data: mainData = {}, t, trans
|
|
|
12
12
|
const [mainGraph, setMainGraph] = useState(null);
|
|
13
13
|
const [data, setData] = useState([]);
|
|
14
14
|
const { token } = useToken();
|
|
15
|
-
console.log("mainData", mainData);
|
|
16
15
|
const fetchData = () => {
|
|
17
16
|
const { dates = [] } = mainData;
|
|
18
17
|
const _data = [];
|
|
@@ -9,13 +9,11 @@ export default function UserGrowth({ loading, data = [], t, translationKeys, fet
|
|
|
9
9
|
const [selectValue, setSelectValue] = useState(selectOptions[0]?.value);
|
|
10
10
|
|
|
11
11
|
useUserGrowth({ container, data, t, translationKeys });
|
|
12
|
-
console.log("usergrowthhhhh", data);
|
|
13
|
-
|
|
14
12
|
useEffect(() => {
|
|
15
13
|
if (typeof fetchUserGrowth === "function") {
|
|
16
14
|
fetchUserGrowth(selectValue);
|
|
17
15
|
}
|
|
18
|
-
}, [selectValue]);
|
|
16
|
+
}, [selectValue, fetchUserGrowth]);
|
|
19
17
|
|
|
20
18
|
return (
|
|
21
19
|
<Widget
|
|
@@ -34,19 +34,19 @@ export default function CombineLocationModal({
|
|
|
34
34
|
|
|
35
35
|
const onSubmit = () => {
|
|
36
36
|
MainForm.validateFields().then((data) => {
|
|
37
|
-
const ids = selectedLocations.map((location) => location.id);
|
|
37
|
+
const ids = selectedLocations.map((location) => location.id);
|
|
38
38
|
const allowedKeys = [
|
|
39
|
-
"id",
|
|
40
|
-
"name",
|
|
41
|
-
"country",
|
|
42
|
-
"category",
|
|
43
|
-
"administrativeLevel1",
|
|
39
|
+
"id",
|
|
40
|
+
"name",
|
|
41
|
+
"country",
|
|
42
|
+
"category",
|
|
43
|
+
"administrativeLevel1",
|
|
44
44
|
"administrativeLevel2"
|
|
45
|
-
];
|
|
45
|
+
];
|
|
46
46
|
const filteredData = Object.fromEntries(
|
|
47
47
|
Object.entries(data).filter(([key]) => allowedKeys.includes(key))
|
|
48
48
|
);
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
onSuccess({
|
|
51
51
|
ids,
|
|
52
52
|
data: filteredData,
|
|
@@ -66,15 +66,15 @@ export default function CombineLocationModal({
|
|
|
66
66
|
destroyOnHidden={true}
|
|
67
67
|
onValuesChange={() => {
|
|
68
68
|
setIsDisabled(() => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
const values = MainForm.getFieldsValue();
|
|
70
|
+
|
|
71
|
+
const requiredFields = entity?.includes("location")
|
|
72
|
+
? ["id", "name", "category", "country", "administrativeLevel1", "administrativeLevel2"]
|
|
73
|
+
: ["id", "name", "category", "country"];
|
|
74
|
+
|
|
75
|
+
return requiredFields.some((field) => values[field] === undefined);
|
|
76
76
|
});
|
|
77
|
-
|
|
77
|
+
}}
|
|
78
78
|
>
|
|
79
79
|
<Container>
|
|
80
80
|
<div className="daf-table-wrapper no-pagination">
|
|
@@ -124,7 +124,7 @@ export default function CombineLocationModal({
|
|
|
124
124
|
options={selectedLocations.map((location) => {
|
|
125
125
|
return {
|
|
126
126
|
label: location?.datastakeId || "-",
|
|
127
|
-
|
|
127
|
+
value: location?.id || "-",
|
|
128
128
|
};
|
|
129
129
|
})}
|
|
130
130
|
placeholder={t("ID")}
|
|
@@ -181,41 +181,41 @@ export default function CombineLocationModal({
|
|
|
181
181
|
|
|
182
182
|
{entity?.includes("location") && (
|
|
183
183
|
<>
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
184
|
+
<Form.Item className="flex-1" name="administrativeLevel1">
|
|
185
|
+
<Select
|
|
186
|
+
placeholder={t("Province")}
|
|
187
|
+
options={selectedLocations
|
|
188
|
+
.map((location) => {
|
|
189
|
+
const _data = getAdminLevelName(location?.linking?.SCL, "level_1");
|
|
190
|
+
return {
|
|
191
|
+
label: _data?.name || "-",
|
|
192
|
+
value: _data?.id || "-",
|
|
193
|
+
};
|
|
194
|
+
})
|
|
195
|
+
.filter(
|
|
196
|
+
(option, index, self) =>
|
|
197
|
+
index === self.findIndex((o) => o.value === option.value),
|
|
198
|
+
)}
|
|
199
|
+
/>
|
|
200
|
+
</Form.Item>
|
|
201
201
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
202
|
+
<Form.Item className="flex-1" name="administrativeLevel2">
|
|
203
|
+
<Select
|
|
204
|
+
placeholder={t("Territory")}
|
|
205
|
+
options={selectedLocations
|
|
206
|
+
.map((location) => {
|
|
207
|
+
const _data = getAdminLevelName(location?.linking?.SCL, "level_2");
|
|
208
|
+
return {
|
|
209
|
+
label: _data?.name || "-",
|
|
210
|
+
value: _data?.id || "-",
|
|
211
|
+
};
|
|
212
|
+
})
|
|
213
|
+
.filter(
|
|
214
|
+
(option, index, self) =>
|
|
215
|
+
index === self.findIndex((o) => o.value === option.value),
|
|
216
|
+
)}
|
|
217
|
+
/>
|
|
218
|
+
</Form.Item>
|
|
219
219
|
</>
|
|
220
220
|
)}
|
|
221
221
|
</Form>
|
|
@@ -37,6 +37,8 @@ export default function CombineSubjectsModal({
|
|
|
37
37
|
const onSubmit = () => {
|
|
38
38
|
MainForm.validateFields().then((data) => {
|
|
39
39
|
const ids = selectedSubjects.map((subject) => subject.id);
|
|
40
|
+
console.log(ids, "ids");
|
|
41
|
+
console.log(data, "data");
|
|
40
42
|
onSuccess({
|
|
41
43
|
ids,
|
|
42
44
|
data,
|
|
@@ -112,7 +114,10 @@ export default function CombineSubjectsModal({
|
|
|
112
114
|
>
|
|
113
115
|
<Form.Item className="flex-1" name="id">
|
|
114
116
|
<Select
|
|
115
|
-
options={
|
|
117
|
+
options={selectedSubjects.map((s) => ({
|
|
118
|
+
label: s?.datastakeId || "-",
|
|
119
|
+
value: s?.id || "-",
|
|
120
|
+
}))}
|
|
116
121
|
placeholder={t("ID")}
|
|
117
122
|
></Select>
|
|
118
123
|
</Form.Item>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import Modal from "../../../../Modal/index.jsx";
|
|
2
2
|
import { Form, Select, Input, Alert } from "antd";
|
|
3
3
|
import { useState, useEffect, useMemo } from "react";
|
|
4
|
+
import AuthenticationService from "../../../../../../services/AuthenticationService.js";
|
|
5
|
+
import { StorageManager } from "../../../../../../../helpers/StorageManager.js";
|
|
4
6
|
|
|
5
7
|
export default function NewAccount({
|
|
6
8
|
t,
|
|
@@ -9,10 +11,28 @@ export default function NewAccount({
|
|
|
9
11
|
accountTypes = [],
|
|
10
12
|
fetchData,
|
|
11
13
|
inviteAccount,
|
|
14
|
+
selectOptions,
|
|
12
15
|
}) {
|
|
13
16
|
const [MainForm] = Form.useForm();
|
|
14
17
|
const [loading, setLoading] = useState(false);
|
|
15
18
|
const [accountUsed, setAccountUsed] = useState(false);
|
|
19
|
+
const [countries, setCountries] = useState([]);
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const getCountries = async () => {
|
|
23
|
+
try {
|
|
24
|
+
const language = StorageManager.get("datastakeLng") || "en";
|
|
25
|
+
const { data } = await AuthenticationService.getFormOptions({
|
|
26
|
+
references: ["countries"],
|
|
27
|
+
language,
|
|
28
|
+
});
|
|
29
|
+
setCountries(data?.countries || []);
|
|
30
|
+
} catch (e) {
|
|
31
|
+
console.error(e);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
getCountries();
|
|
35
|
+
}, []);
|
|
16
36
|
|
|
17
37
|
const isEdit = useMemo(() => isOpen && typeof isOpen === "object", [isOpen]);
|
|
18
38
|
|
|
@@ -20,7 +40,8 @@ export default function NewAccount({
|
|
|
20
40
|
if (isOpen && typeof isOpen === "object") {
|
|
21
41
|
MainForm.setFieldsValue({
|
|
22
42
|
name: isOpen.name,
|
|
23
|
-
|
|
43
|
+
country: isOpen?.country,
|
|
44
|
+
type: isOpen?.type,
|
|
24
45
|
});
|
|
25
46
|
} else {
|
|
26
47
|
MainForm.resetFields();
|
|
@@ -57,18 +78,32 @@ export default function NewAccount({
|
|
|
57
78
|
<Form.Item name="name" label={t("Name")} rules={[{ required: true }]}>
|
|
58
79
|
<Input placeholder={t("Type")} />
|
|
59
80
|
</Form.Item>
|
|
81
|
+
|
|
82
|
+
{isEdit ? (
|
|
83
|
+
<Form.Item
|
|
84
|
+
name="country"
|
|
85
|
+
label={t("Country")}
|
|
86
|
+
rules={[{ required: true, type: "country" }]}
|
|
87
|
+
>
|
|
88
|
+
<Select
|
|
89
|
+
placeholder={t("Select")}
|
|
90
|
+
options={(countries || []).map((c) => ({
|
|
91
|
+
label: c?.label,
|
|
92
|
+
value: c?.value,
|
|
93
|
+
}))}
|
|
94
|
+
/>
|
|
95
|
+
</Form.Item>
|
|
96
|
+
) : (
|
|
97
|
+
<Form.Item
|
|
98
|
+
name="email"
|
|
99
|
+
label={t("Email")}
|
|
100
|
+
rules={[{ required: true, type: "email" }]}
|
|
101
|
+
>
|
|
102
|
+
<Input placeholder={t("Type")} />
|
|
103
|
+
</Form.Item>
|
|
104
|
+
)}
|
|
60
105
|
<Form.Item name="type" label={t("Type")} rules={[{ required: true }]}>
|
|
61
|
-
<Select placeholder={t("Select")} options={accountTypes} />
|
|
62
|
-
</Form.Item>
|
|
63
|
-
<Form.Item name="email" label={t("Email")} rules={[{ required: true, type: "email" }]}>
|
|
64
|
-
<Input
|
|
65
|
-
placeholder={t("Type")}
|
|
66
|
-
onChange={() => {
|
|
67
|
-
if (accountUsed) {
|
|
68
|
-
setAccountUsed(false);
|
|
69
|
-
}
|
|
70
|
-
}}
|
|
71
|
-
/>
|
|
106
|
+
<Select placeholder={t("Select")} options={accountTypes || []} />
|
|
72
107
|
</Form.Item>
|
|
73
108
|
{accountUsed && (
|
|
74
109
|
<Alert
|
|
@@ -13,11 +13,17 @@ export default function NewUser({
|
|
|
13
13
|
inviteCompanyAccount = () => {},
|
|
14
14
|
companyId,
|
|
15
15
|
handleError = () => {},
|
|
16
|
+
existingEmails = [],
|
|
16
17
|
}) {
|
|
17
18
|
const [MainForm] = Form.useForm();
|
|
18
19
|
const [accountUsed, setAccountUsed] = useState(false);
|
|
19
20
|
const [loading, setLoading] = useState(false);
|
|
20
21
|
|
|
22
|
+
const checkEmailExists = (email) => {
|
|
23
|
+
if (!email) return false;
|
|
24
|
+
return existingEmails.includes(email.toLowerCase());
|
|
25
|
+
};
|
|
26
|
+
|
|
21
27
|
useEffect(() => {
|
|
22
28
|
if (defaultData) {
|
|
23
29
|
MainForm.setFieldsValue({
|
|
@@ -30,6 +36,12 @@ export default function NewUser({
|
|
|
30
36
|
const onSubmit = async () => {
|
|
31
37
|
try {
|
|
32
38
|
const val = await MainForm.validateFields();
|
|
39
|
+
|
|
40
|
+
if (checkEmailExists(val.email)) {
|
|
41
|
+
setAccountUsed(true);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
33
45
|
setLoading(true);
|
|
34
46
|
|
|
35
47
|
const apiPayload = {
|
|
@@ -50,6 +62,7 @@ export default function NewUser({
|
|
|
50
62
|
const localUserData = {
|
|
51
63
|
...apiPayload,
|
|
52
64
|
status: 'pending',
|
|
65
|
+
id: apiPayload.email, // Add a unique ID for the table key
|
|
53
66
|
// apps: {
|
|
54
67
|
// [module]: {
|
|
55
68
|
// role: val.role,
|
|
@@ -84,16 +97,29 @@ export default function NewUser({
|
|
|
84
97
|
<Input placeholder={t("Type")} />
|
|
85
98
|
</Form.Item>
|
|
86
99
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
100
|
+
<Form.Item name="email" label={t("Email")} rules={[{ required: true, type: "email" }]}>
|
|
101
|
+
<Input
|
|
102
|
+
placeholder={t("Type")}
|
|
103
|
+
onChange={(e) => {
|
|
104
|
+
const emailExists = checkEmailExists(e.target.value);
|
|
105
|
+
setAccountUsed(emailExists);
|
|
106
|
+
}}
|
|
107
|
+
onBlur={(e) => {
|
|
108
|
+
const emailExists = checkEmailExists(e.target.value);
|
|
109
|
+
setAccountUsed(emailExists);
|
|
110
|
+
}}
|
|
111
|
+
/>
|
|
112
|
+
</Form.Item>
|
|
113
|
+
{accountUsed && (
|
|
114
|
+
<Alert
|
|
115
|
+
message={t("This email corresponds to another account.")}
|
|
116
|
+
type="error"
|
|
117
|
+
className="mb-2"
|
|
118
|
+
showIcon
|
|
119
|
+
closable
|
|
120
|
+
onClose={() => setAccountUsed(false)}
|
|
121
|
+
/>
|
|
122
|
+
)}
|
|
97
123
|
|
|
98
124
|
<Form.Item name="role" label={t("Role")} rules={[{ required: true }]}>
|
|
99
125
|
<Select
|
|
@@ -101,6 +101,7 @@ export default function AdminAccountsScreen({ config }) {
|
|
|
101
101
|
isOpen={addAccountVisible}
|
|
102
102
|
onClose={() => setAddAccountVisible(false)}
|
|
103
103
|
accountTypes={accountTypes}
|
|
104
|
+
countriesOptions={options?.countries}
|
|
104
105
|
fetchData={() => {
|
|
105
106
|
}}
|
|
106
107
|
inviteAccount={(data) => AdminService.inviteAccount(data)}
|
|
@@ -38,8 +38,7 @@ export default function AdminDashboardScreen({ config }) {
|
|
|
38
38
|
|
|
39
39
|
const safeUserActivity = Array.isArray(data?.data?.userActivity) ? data.data.userActivity : [];
|
|
40
40
|
const safeTopContributors = Array.isArray(data?.topContributors) ? data.topContributors : [];
|
|
41
|
-
const safeUserGrowth =
|
|
42
|
-
console.log("safeUserGrowth", safeUserGrowth);
|
|
41
|
+
const safeUserGrowth = userGrowthData || data?.userGrowthData || [];
|
|
43
42
|
|
|
44
43
|
return (
|
|
45
44
|
<AdminDashboard
|
|
@@ -50,6 +49,7 @@ console.log("safeUserGrowth", safeUserGrowth);
|
|
|
50
49
|
loadingUserGrowth={userGrowthDataLoading}
|
|
51
50
|
fetchUserGrowth={fetchUserGrowth}
|
|
52
51
|
adminTranslationIdentifier={appName}
|
|
52
|
+
userGrowthData={safeUserGrowth}
|
|
53
53
|
data={{
|
|
54
54
|
keyIndicatorsData: keyIndicatorsConfig,
|
|
55
55
|
userActivityData: safeUserActivity,
|
|
@@ -270,36 +270,28 @@ export const getColumns = ({
|
|
|
270
270
|
);
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
const moreMenuItems =
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
onClick: () => onCopyInvitation(val),
|
|
296
|
-
},
|
|
297
|
-
{
|
|
298
|
-
label: t("admin::cancel-invitation"),
|
|
299
|
-
value: "cancel",
|
|
300
|
-
onClick: () => onCanelVerification(val),
|
|
301
|
-
},
|
|
302
|
-
];
|
|
273
|
+
const moreMenuItems = [
|
|
274
|
+
{
|
|
275
|
+
label: t("Edit"),
|
|
276
|
+
value: "edit",
|
|
277
|
+
onClick: () => setAddAccountVisible(val),
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
label: t("Resend Invitation"),
|
|
281
|
+
value: "resend",
|
|
282
|
+
onClick: () => onResendInvitation(val),
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
label: t("Copy Invitation Link"),
|
|
286
|
+
value: "copy",
|
|
287
|
+
onClick: () => onCopyInvitation(val),
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
label: t("admin::cancel-invitation"),
|
|
291
|
+
value: "cancel",
|
|
292
|
+
onClick: () => onCanelVerification(val),
|
|
293
|
+
},
|
|
294
|
+
];
|
|
303
295
|
|
|
304
296
|
return <MoreMenu items={moreMenuItems} />;
|
|
305
297
|
},
|
|
@@ -35,6 +35,7 @@ export default function AccountTable({
|
|
|
35
35
|
actionButton,
|
|
36
36
|
inviteAccount,
|
|
37
37
|
}) {
|
|
38
|
+
const accountTypes = config?.accountTypes;
|
|
38
39
|
const [showFilters, setShowFilters] = useState(false);
|
|
39
40
|
const [hasError, setHasError] = useState(false);
|
|
40
41
|
const [selectedAccounts, setSelectedAccounts] = useState([]);
|
|
@@ -66,9 +67,9 @@ export default function AccountTable({
|
|
|
66
67
|
const selectOptions = useMemo(() => {
|
|
67
68
|
return {
|
|
68
69
|
country: config.options?.countries,
|
|
69
|
-
type:
|
|
70
|
+
type: accountTypes,
|
|
70
71
|
};
|
|
71
|
-
}, [config.options,
|
|
72
|
+
}, [config.options, accountTypes]);
|
|
72
73
|
|
|
73
74
|
useEffect(() => {
|
|
74
75
|
if (initFetchDone) {
|
|
@@ -207,7 +208,7 @@ export default function AccountTable({
|
|
|
207
208
|
fetchData();
|
|
208
209
|
fetchPendingAccounts();
|
|
209
210
|
}}
|
|
210
|
-
accountTypes={
|
|
211
|
+
accountTypes={accountTypes}
|
|
211
212
|
inviteAccount={inviteAccount}
|
|
212
213
|
/>
|
|
213
214
|
<CombineAccountModal
|
|
@@ -64,10 +64,14 @@ export default function LocationTable({
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
const page = Number(paginationObj.page) || 1;
|
|
68
|
+
const pageSize = Number(paginationObj.pageSize) || 20;
|
|
69
|
+
const skip = (page - 1) * pageSize;
|
|
70
|
+
|
|
67
71
|
const transformedParams = {
|
|
68
72
|
pagination: {
|
|
69
|
-
skip
|
|
70
|
-
take:
|
|
73
|
+
skip,
|
|
74
|
+
take: pageSize,
|
|
71
75
|
},
|
|
72
76
|
tab: activeTab,
|
|
73
77
|
};
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
} from "./helper.js";
|
|
14
14
|
import { getColumns } from "./columns.js";
|
|
15
15
|
import CombineSubjectsModal from "../../AdminModals/CombineSubjects/index.jsx";
|
|
16
|
-
|
|
17
16
|
const { useToken } = theme;
|
|
18
17
|
|
|
19
18
|
export default function SubjectsTable({
|
|
@@ -40,10 +39,7 @@ export default function SubjectsTable({
|
|
|
40
39
|
const { token } = useToken();
|
|
41
40
|
const [isCombineModalOpen, setIsModalOpen] = useState(false);
|
|
42
41
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const getDataWithStringPagination = async ({ params }) => {
|
|
42
|
+
const getDataWithStringPagination = async ({ params }) => {
|
|
47
43
|
const { pagination, tab, filters, search, sort, ...otherParams } = params;
|
|
48
44
|
|
|
49
45
|
let paginationObj = { page: 1, pageSize: 20 };
|
|
@@ -65,10 +61,14 @@ const getDataWithStringPagination = async ({ params }) => {
|
|
|
65
61
|
}
|
|
66
62
|
}
|
|
67
63
|
|
|
64
|
+
const page = Number(paginationObj.page) || 1;
|
|
65
|
+
const pageSize = Number(paginationObj.pageSize) || 20;
|
|
66
|
+
const skip = (page - 1) * pageSize;
|
|
67
|
+
|
|
68
68
|
const transformedParams = {
|
|
69
69
|
pagination: {
|
|
70
|
-
skip
|
|
71
|
-
take:
|
|
70
|
+
skip,
|
|
71
|
+
take: pageSize,
|
|
72
72
|
},
|
|
73
73
|
tab: activeTab,
|
|
74
74
|
};
|
|
@@ -133,7 +133,7 @@ const getDataWithStringPagination = async ({ params }) => {
|
|
|
133
133
|
{
|
|
134
134
|
icon: "Merge",
|
|
135
135
|
onClick: () => setIsModalOpen(true),
|
|
136
|
-
tooltip: t("
|
|
136
|
+
tooltip: t("merge-subjects"),
|
|
137
137
|
disabled: selectedSubjects.length < 2,
|
|
138
138
|
},
|
|
139
139
|
]}
|
|
@@ -192,11 +192,13 @@ const getDataWithStringPagination = async ({ params }) => {
|
|
|
192
192
|
onSuccess={(data) => {
|
|
193
193
|
setIsModalOpen(false);
|
|
194
194
|
setLoading(true);
|
|
195
|
-
message.success(t("Subjects successfully merged."))
|
|
196
195
|
if (typeof mergeSubjectsFunction === 'function') {
|
|
197
|
-
mergeSubjectsFunction(data).
|
|
196
|
+
mergeSubjectsFunction(data).then(() => {
|
|
197
|
+
setTimeout(() => {
|
|
198
|
+
fetchData();
|
|
199
|
+
}, 500);
|
|
200
|
+
}).finally(() => {
|
|
198
201
|
setSelectedSubjects([]);
|
|
199
|
-
fetchData();
|
|
200
202
|
});
|
|
201
203
|
}
|
|
202
204
|
}}
|
|
@@ -207,4 +209,4 @@ const getDataWithStringPagination = async ({ params }) => {
|
|
|
207
209
|
/>
|
|
208
210
|
</>
|
|
209
211
|
);
|
|
210
|
-
}
|
|
212
|
+
}
|
|
@@ -32,6 +32,7 @@ export function useAdminTable({
|
|
|
32
32
|
defaultPageSize: defaultPageSize || 20,
|
|
33
33
|
getRedirectLink,
|
|
34
34
|
});
|
|
35
|
+
console.log(filter, "filter.activeFilters");
|
|
35
36
|
|
|
36
37
|
const activeTab = useMemo(() => filter.activeFilters.activeTab, [filter.activeFilters]);
|
|
37
38
|
|
|
@@ -59,12 +60,14 @@ export function useAdminTable({
|
|
|
59
60
|
fetchPendingAccounts();
|
|
60
61
|
}, []);
|
|
61
62
|
|
|
63
|
+
|
|
62
64
|
const fetchData = useCallback(async () => {
|
|
63
65
|
try {
|
|
64
66
|
setLoading(true);
|
|
65
67
|
const params = filterParams({
|
|
66
68
|
activeFilters: filter.activeFilters,
|
|
67
69
|
});
|
|
70
|
+
console.log(params, "params");
|
|
68
71
|
const { data } = await getData({ params });
|
|
69
72
|
setData(data.data || data);
|
|
70
73
|
filter.setPagination((prev) => ({ ...prev, total: data?.meta?.total || data?.length || 0 }));
|
|
@@ -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
|
+
import AdminService from "../../../../../../../services/AdminService.js";
|
|
7
7
|
export default function Edit({
|
|
8
8
|
t,
|
|
9
9
|
goTo,
|
|
@@ -37,14 +37,17 @@ export default function Edit({
|
|
|
37
37
|
}, [isChanged, addCheck, removeCheck]);
|
|
38
38
|
|
|
39
39
|
const deleteUser = useCallback(
|
|
40
|
-
(id) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
+
}
|
|
44
48
|
},
|
|
45
|
-
[fetchData],
|
|
49
|
+
[fetchData, data.id, t, handleError],
|
|
46
50
|
);
|
|
47
|
-
|
|
48
51
|
const updateUser = useCallback((id, val) => {
|
|
49
52
|
setIsChanged(true);
|
|
50
53
|
setData((prev) => ({
|
|
@@ -71,9 +74,9 @@ export default function Edit({
|
|
|
71
74
|
|
|
72
75
|
const onSuspend = () => {
|
|
73
76
|
Modal.confirm({
|
|
74
|
-
title: t("
|
|
77
|
+
title: t("Are-you-sure-you-want-to-suspend-this-account?"),
|
|
75
78
|
icon: <ExclamationCircleOutlined />,
|
|
76
|
-
content: t("
|
|
79
|
+
content: <span style={{ color: "#888" }}>{t("Associated-users-will-lose-access-to-the-application-and-to-all-data-created-for-this-account.")}</span>,
|
|
77
80
|
okText: t("Yes"),
|
|
78
81
|
cancelText: t("No"),
|
|
79
82
|
onOk: async () => {
|