datastake-daf 0.6.819 → 0.6.821
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 +2264 -1099
- package/dist/hooks/index.js +16 -5
- package/dist/pages/index.js +251 -65
- package/dist/services/index.js +104 -9
- package/dist/utils/index.js +75 -8
- package/package.json +1 -1
- package/src/@daf/core/components/AuthForm/index.jsx +12 -3
- package/src/@daf/core/components/DynamicForm/_index.scss +1 -3
- package/src/@daf/core/components/EditForm/_index.scss +0 -4
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/hook.js +27 -1
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/index.jsx +2 -3
- 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/AdminDashboard/components/UserStatistics/index.jsx +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminModals/AddAccount/index.jsx +82 -10
- 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 +53 -31
- package/src/@daf/core/components/Screens/Admin/AdminModals/NewUser/index.jsx +36 -10
- package/src/@daf/core/components/Screens/Admin/AdminModals/TransferRights/index.jsx +2 -2
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Accounts.jsx +37 -10
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Dashboard.jsx +2 -2
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Documents.jsx +81 -0
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Events.jsx +77 -0
- package/src/@daf/core/components/Screens/Admin/AdminScreens/index.js +2 -1
- package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/helper.js +22 -30
- package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/index.jsx +28 -16
- package/src/@daf/core/components/Screens/Admin/AdminTables/DocumentsTable/column.js +93 -0
- package/src/@daf/core/components/Screens/Admin/AdminTables/DocumentsTable/helper.js +43 -0
- package/src/@daf/core/components/Screens/Admin/AdminTables/DocumentsTable/index.jsx +201 -0
- package/src/@daf/core/components/Screens/Admin/AdminTables/EventsTable/column.js +113 -0
- package/src/@daf/core/components/Screens/Admin/AdminTables/EventsTable/helper.js +58 -0
- package/src/@daf/core/components/Screens/Admin/AdminTables/EventsTable/index.jsx +176 -0
- package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/helper.js +3 -6
- package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/index.jsx +17 -2
- package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/helper.js +3 -6
- package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/index.jsx +27 -13
- package/src/@daf/core/components/Screens/Admin/AdminTables/UserTable/index.jsx +0 -1
- package/src/@daf/core/components/Screens/Admin/AdminTables/components/index.jsx +4 -2
- package/src/@daf/core/components/Screens/Admin/AdminTables/hook.js +3 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Edit/index.jsx +21 -9
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/helper.js +16 -11
- 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 +12 -16
- package/src/@daf/core/components/Screens/Admin/AppInvitation/index.jsx +124 -99
- package/src/@daf/core/components/Screens/Admin/adminRoutes.js +44 -28
- package/src/@daf/hooks/useAdminDashboard.js +7 -4
- package/src/@daf/hooks/useSources.js +2 -1
- package/src/@daf/pages/Events/columns.js +15 -3
- package/src/@daf/pages/Locations/MineSite/columns.js +18 -1
- package/src/@daf/pages/TablePage/columns.js +2 -0
- package/src/@daf/pages/TablePage/hook.js +0 -2
- package/src/@daf/pages/View/hooks/useViewActions.js +13 -0
- package/src/@daf/pages/View/hooks/useViewPermissions.js +16 -0
- package/src/@daf/pages/View/index.jsx +32 -4
- package/src/@daf/services/AdminService.js +80 -8
- package/src/@daf/services/DashboardService.js +3 -3
- package/src/@daf/utils/filters.js +13 -15
- package/src/constants/locales/en/translation.js +24 -4
- package/src/constants/locales/fr/translation.js +17 -0
- package/src/constants/locales/sp/translation.js +28 -7
- package/src/helpers/copyToClipboard.js +60 -0
- package/src/@daf/core/components/Screens/Admin/AdminScreens/SubjectsView.jsx +0 -395
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/configTransformer.js +0 -137
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/index.js +0 -9
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/index.jsx +0 -196
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/configTransformer.js +0 -216
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/index.js +0 -7
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/index.jsx +0 -184
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/config.js +0 -64
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/helpers.js +0 -10
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/index.jsx +0 -77
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/config.js +0 -51
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/helpers.js +0 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/index.jsx +0 -76
|
@@ -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>
|
|
@@ -6,42 +6,64 @@ export default function NewAccount({
|
|
|
6
6
|
t,
|
|
7
7
|
isOpen,
|
|
8
8
|
onClose,
|
|
9
|
-
accountTypes
|
|
9
|
+
accountTypes ,
|
|
10
10
|
fetchData,
|
|
11
|
+
updateAccount,
|
|
11
12
|
inviteAccount,
|
|
13
|
+
isPending=false,
|
|
14
|
+
accountToEdit,
|
|
12
15
|
}) {
|
|
13
16
|
const [MainForm] = Form.useForm();
|
|
14
17
|
const [loading, setLoading] = useState(false);
|
|
15
18
|
const [accountUsed, setAccountUsed] = useState(false);
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
const isEdit = useMemo(() => accountToEdit && typeof accountToEdit === "object", [accountToEdit]);
|
|
18
23
|
|
|
19
24
|
useEffect(() => {
|
|
20
|
-
if (
|
|
25
|
+
if (accountToEdit && typeof accountToEdit === "object") {
|
|
21
26
|
MainForm.setFieldsValue({
|
|
22
|
-
name:
|
|
23
|
-
email:
|
|
27
|
+
name: accountToEdit.name,
|
|
28
|
+
email: accountToEdit.email,
|
|
29
|
+
type: accountToEdit?.otherData?.interface,
|
|
24
30
|
});
|
|
25
31
|
} else {
|
|
26
32
|
MainForm.resetFields();
|
|
27
33
|
}
|
|
28
|
-
|
|
34
|
+
}, [accountToEdit, MainForm]);
|
|
29
35
|
|
|
30
|
-
const onSubmit = () => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
const onSubmit = async () => {
|
|
37
|
+
try {
|
|
38
|
+
const val = await MainForm.validateFields();
|
|
39
|
+
console.log(val, "val");
|
|
40
|
+
setLoading(true);
|
|
41
|
+
|
|
42
|
+
if (isEdit && accountToEdit?.id) {
|
|
43
|
+
await updateAccount({
|
|
44
|
+
id: accountToEdit.id,
|
|
45
|
+
data: val,
|
|
46
|
+
isPending: accountToEdit.status === 'pending' || isPending
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
if (!inviteAccount) {
|
|
50
|
+
throw new Error("inviteAccount function is required for creating new accounts");
|
|
42
51
|
}
|
|
43
|
-
|
|
44
|
-
|
|
52
|
+
await inviteAccount(val);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
setLoading(false);
|
|
56
|
+
fetchData();
|
|
57
|
+
onClose();
|
|
58
|
+
MainForm.resetFields();
|
|
59
|
+
} catch (err) {
|
|
60
|
+
console.log(err);
|
|
61
|
+
setLoading(false);
|
|
62
|
+
if (err.errorFields) {
|
|
63
|
+
// Validation errors, don't show error message
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
45
67
|
};
|
|
46
68
|
|
|
47
69
|
return (
|
|
@@ -57,18 +79,18 @@ export default function NewAccount({
|
|
|
57
79
|
<Form.Item name="name" label={t("Name")} rules={[{ required: true }]}>
|
|
58
80
|
<Input placeholder={t("Type")} />
|
|
59
81
|
</Form.Item>
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
<Form.Item
|
|
85
|
+
name="email"
|
|
86
|
+
label={t("Email")}
|
|
87
|
+
rules={[{ required: true, type: "email" }]}
|
|
88
|
+
>
|
|
89
|
+
<Input placeholder={t("Type")} />
|
|
90
|
+
</Form.Item>
|
|
91
|
+
|
|
60
92
|
<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
|
-
/>
|
|
93
|
+
<Select placeholder={t("Select")} options={accountTypes || []} />
|
|
72
94
|
</Form.Item>
|
|
73
95
|
{accountUsed && (
|
|
74
96
|
<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
|
|
@@ -39,7 +39,7 @@ export default function TransferRights({
|
|
|
39
39
|
setLoading(true);
|
|
40
40
|
|
|
41
41
|
try {
|
|
42
|
-
await transferAdmin({
|
|
42
|
+
await transferAdmin({ companyId: accountData.id, userId: val.newAdmin });
|
|
43
43
|
MainForm.resetFields();
|
|
44
44
|
fetchData();
|
|
45
45
|
onClose();
|
|
@@ -56,7 +56,7 @@ export default function TransferRights({
|
|
|
56
56
|
return (
|
|
57
57
|
<Modal
|
|
58
58
|
t={t}
|
|
59
|
-
title={t("admin::transfer-admin-rights")}
|
|
59
|
+
title={t("admin::transfer-account-admin-rights")}
|
|
60
60
|
open={isOpen}
|
|
61
61
|
onClose={onClose}
|
|
62
62
|
loading={loading}
|
|
@@ -2,6 +2,7 @@ import React, { useCallback, useMemo, useState } from "react";
|
|
|
2
2
|
import { message } from "antd";
|
|
3
3
|
import AccountTable from "../AdminTables/AccountTable/index.jsx";
|
|
4
4
|
import DefaultNewAccountModal from "../AdminModals/NewAccount/index.jsx";
|
|
5
|
+
import { copyStringToClipboard } from "../../../../../../helpers/copyToClipboard.js";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Admin Accounts Screen Wrapper
|
|
@@ -35,20 +36,21 @@ export default function AdminAccountsScreen({ config }) {
|
|
|
35
36
|
options,
|
|
36
37
|
useQuery,
|
|
37
38
|
NewAccountModal,
|
|
39
|
+
appUrl
|
|
38
40
|
} = config;
|
|
41
|
+
// console.log(accountTypes, "accountTypes");
|
|
42
|
+
// const userTypes = useMemo(() => accountTypes.map((c) => ({
|
|
43
|
+
// label: c.label,
|
|
44
|
+
// value: c.value,
|
|
45
|
+
// })), [accountTypes]);
|
|
39
46
|
|
|
40
47
|
const AccountModal = NewAccountModal || DefaultNewAccountModal;
|
|
41
48
|
|
|
42
49
|
const query = useQuery ? useQuery() : { get: () => null };
|
|
43
50
|
const [addAccountVisible, setAddAccountVisible] = useState(!!query.get("create"));
|
|
51
|
+
const [accountToEdit, setAccountToEdit] = useState(null);
|
|
44
52
|
|
|
45
|
-
const onResendInvitation = useCallback(() => {
|
|
46
|
-
message.success(t("Invitation email resent"));
|
|
47
|
-
}, [t]);
|
|
48
53
|
|
|
49
|
-
const onCopyInvitation = useCallback(() => {
|
|
50
|
-
message.success(t("Invitation link copied"));
|
|
51
|
-
}, [t]);
|
|
52
54
|
|
|
53
55
|
const actionButtons = useMemo(
|
|
54
56
|
() => [
|
|
@@ -62,6 +64,13 @@ export default function AdminAccountsScreen({ config }) {
|
|
|
62
64
|
[t]
|
|
63
65
|
);
|
|
64
66
|
|
|
67
|
+
|
|
68
|
+
function handleAccountModal(data) {
|
|
69
|
+
console.log(data, "data");
|
|
70
|
+
setAddAccountVisible(true);
|
|
71
|
+
setAccountToEdit(data);
|
|
72
|
+
}
|
|
73
|
+
|
|
65
74
|
function handleGetData(params) {
|
|
66
75
|
return AdminService.getAccounts(params);
|
|
67
76
|
}
|
|
@@ -69,7 +78,18 @@ export default function AdminAccountsScreen({ config }) {
|
|
|
69
78
|
function handleCancelVerification(token) {
|
|
70
79
|
return AdminService.cancelInvitation(token);
|
|
71
80
|
}
|
|
81
|
+
function handleResendInvitation(account) {
|
|
82
|
+
console.log("account", account);
|
|
83
|
+
const token = account.invitationToken || account.users?.[0]?.invitationToken || account.admin?.invitationToken;
|
|
84
|
+
return AdminService.resendInvitation({ invitationToken: token });
|
|
85
|
+
}
|
|
72
86
|
|
|
87
|
+
|
|
88
|
+
function handleCopyInvitation(account) {
|
|
89
|
+
const link = `${appUrl}/register?code=${account.invitationToken}`;
|
|
90
|
+
copyStringToClipboard(link);
|
|
91
|
+
message.success(t("Invitation link copied"));
|
|
92
|
+
}
|
|
73
93
|
return (
|
|
74
94
|
<>
|
|
75
95
|
<AccountTable
|
|
@@ -84,14 +104,15 @@ export default function AdminAccountsScreen({ config }) {
|
|
|
84
104
|
getData={handleGetData}
|
|
85
105
|
config={{
|
|
86
106
|
accountTypes,
|
|
107
|
+
addAccountVisible,
|
|
87
108
|
options: {
|
|
88
109
|
countries: options?.countries,
|
|
89
110
|
},
|
|
90
111
|
onTableClick: {
|
|
91
112
|
onCanelVerification: handleCancelVerification,
|
|
92
|
-
onCopyInvitation,
|
|
93
|
-
onResendInvitation,
|
|
94
|
-
setAddAccountVisible,
|
|
113
|
+
onCopyInvitation: handleCopyInvitation,
|
|
114
|
+
onResendInvitation: handleResendInvitation,
|
|
115
|
+
setAddAccountVisible: handleAccountModal,
|
|
95
116
|
},
|
|
96
117
|
}}
|
|
97
118
|
/>
|
|
@@ -99,11 +120,17 @@ export default function AdminAccountsScreen({ config }) {
|
|
|
99
120
|
<AccountModal
|
|
100
121
|
t={t}
|
|
101
122
|
isOpen={addAccountVisible}
|
|
102
|
-
onClose={() =>
|
|
123
|
+
onClose={() => {
|
|
124
|
+
setAddAccountVisible(false);
|
|
125
|
+
setAccountToEdit(null);
|
|
126
|
+
}}
|
|
103
127
|
accountTypes={accountTypes}
|
|
128
|
+
countriesOptions={options?.countries}
|
|
104
129
|
fetchData={() => {
|
|
105
130
|
}}
|
|
106
131
|
inviteAccount={(data) => AdminService.inviteAccount(data)}
|
|
132
|
+
updateAccount={({ data, id, isPending }) => AdminService.updateAccount({ data, id, isPending })}
|
|
133
|
+
accountToEdit={accountToEdit}
|
|
107
134
|
/>
|
|
108
135
|
</>
|
|
109
136
|
);
|
|
@@ -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,
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
|
+
import { message } from "antd";
|
|
3
|
+
import EventsTable from "../AdminTables/EventsTable/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 AdminEventsScreen({ 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 = "events",
|
|
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: 'event', params });
|
|
54
|
+
}, [getData, AdminService]);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<EventsTable
|
|
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:options}}
|
|
72
|
+
user={user}
|
|
73
|
+
options={options}
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
@@ -10,4 +10,5 @@ export { default as AdminAccountsScreen } from "./Accounts.jsx";
|
|
|
10
10
|
export { default as AdminAccountsViewScreen } from "./AccountsView.jsx";
|
|
11
11
|
export { default as AdminSubjectsScreen } from "./Subjects.jsx";
|
|
12
12
|
export { default as AdminLocationScreen } from "./Location.jsx";
|
|
13
|
-
export { default as
|
|
13
|
+
export { default as AdminDocumentsScreen } from "./Documents.jsx";
|
|
14
|
+
export { default as AdminEventsScreen } from "./Events.jsx";
|