datastake-daf 0.6.819 → 0.6.820
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 +3936 -2875
- package/dist/hooks/index.js +16 -5
- package/dist/pages/index.js +255 -67
- 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 +33 -5
- 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/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
- 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
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import React, { useState, useEffect } from "react";
|
|
2
|
-
import { Checkbox,
|
|
2
|
+
import { Checkbox, 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";
|
|
5
6
|
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
const theme = window.theme;
|
|
6
10
|
export default function AppInvitation({
|
|
7
|
-
// Redux State
|
|
8
11
|
errors,
|
|
9
12
|
user,
|
|
10
13
|
invitationSuccess,
|
|
11
|
-
// Actions
|
|
12
14
|
confirmInvitation,
|
|
13
15
|
getUserFromInvitation,
|
|
14
|
-
|
|
16
|
+
theme,
|
|
15
17
|
Layout,
|
|
16
18
|
redirectPath = "/",
|
|
17
19
|
loginPath = "/login",
|
|
18
20
|
appRedirectPath = "/app",
|
|
19
21
|
params: propParams = {},
|
|
22
|
+
goTo,
|
|
23
|
+
isMobile = false,
|
|
24
|
+
t,
|
|
20
25
|
}) {
|
|
21
|
-
const {
|
|
22
|
-
const routeParams = useParams();
|
|
23
|
-
const { app, companyCode, userCode } = { ...routeParams, ...propParams };
|
|
24
|
-
const [passwords] = Form.useForm();
|
|
26
|
+
const { app, companyCode, userCode } = propParams;
|
|
25
27
|
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,36 +46,125 @@ export default function AppInvitation({
|
|
|
46
46
|
localStorage.setItem('token', data.token);
|
|
47
47
|
}
|
|
48
48
|
message.success(t('Invitation accepted'));
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
if (goTo && typeof goTo === 'function') {
|
|
50
|
+
goTo(redirectPath);
|
|
51
|
+
} else {
|
|
52
|
+
window.location.href = redirectPath;
|
|
53
|
+
}
|
|
52
54
|
},
|
|
53
55
|
{ companyCode, userCode }
|
|
54
56
|
);
|
|
55
57
|
}
|
|
56
58
|
}, [invitationSuccess, user, confirmInvitation, goTo, redirectPath, companyCode, userCode, t]);
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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]);
|
|
64
83
|
|
|
65
84
|
const subTitle = !passwordReseted ? 'Set up your password and agree with out terms and conditions.' :
|
|
66
85
|
isMobile ? 'Your account has been successfully set up. To log in use a desktop device.'
|
|
67
86
|
: 'Your account has been successfully set up. Please click the button below to log in.';
|
|
68
87
|
const title = passwordReseted ? 'Thank You!' : undefined;
|
|
69
88
|
|
|
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
|
+
|
|
70
162
|
if (checking && !invitationSuccess) {
|
|
71
163
|
return <Loading />;
|
|
72
164
|
}
|
|
73
165
|
|
|
74
|
-
// If auto-confirming (inviteToken present), we might want to show loading or nothing until redirect
|
|
75
166
|
if (invitationSuccess && user && user.inviteToken) {
|
|
76
|
-
|
|
77
|
-
// We can show loading here too or just return null.
|
|
78
|
-
// Original code: checks invitationSuccess && !user.inviteToken for form, else redirect.
|
|
167
|
+
|
|
79
168
|
return <Loading />;
|
|
80
169
|
}
|
|
81
170
|
|
|
@@ -88,6 +177,7 @@ export default function AppInvitation({
|
|
|
88
177
|
<DafButton
|
|
89
178
|
type="primary"
|
|
90
179
|
className="normal-br"
|
|
180
|
+
style={theme || window.theme ? { backgroundColor: (theme || window.theme).colorPrimary, borderColor: (theme || window.theme).colorPrimary } : {}}
|
|
91
181
|
onClick={() => {
|
|
92
182
|
window.location.href = loginPath;
|
|
93
183
|
}}
|
|
@@ -97,86 +187,21 @@ export default function AppInvitation({
|
|
|
97
187
|
)}
|
|
98
188
|
</div>
|
|
99
189
|
) : (
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
</>
|
|
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
|
+
/>
|
|
174
200
|
)}
|
|
175
201
|
</>
|
|
176
202
|
);
|
|
177
203
|
|
|
178
204
|
if (Layout) {
|
|
179
|
-
// Assuming Layout accepts these props as per Nashiriki AuthLayout
|
|
180
205
|
return <Layout app={app} step={1} subTitle={subTitle} title={title}>{Content}</Layout>;
|
|
181
206
|
}
|
|
182
207
|
|
|
@@ -189,5 +214,5 @@ export default function AppInvitation({
|
|
|
189
214
|
);
|
|
190
215
|
}
|
|
191
216
|
|
|
192
|
-
return
|
|
217
|
+
return null;
|
|
193
218
|
}
|
|
@@ -5,8 +5,9 @@ import AdminAccountsScreen from "./AdminScreens/Accounts.jsx";
|
|
|
5
5
|
import AdminAccountsViewScreen from "./AdminScreens/AccountsView.jsx";
|
|
6
6
|
import AdminSubjectsScreen from "./AdminScreens/Subjects.jsx";
|
|
7
7
|
import AdminLocationScreen from "./AdminScreens/Location.jsx";
|
|
8
|
-
import
|
|
9
|
-
|
|
8
|
+
// import AdminSubjectsViewScren from "./AdminScreens/SubjectsView.jsx";
|
|
9
|
+
import AdminEventsScreen from "./AdminScreens/Events.jsx";
|
|
10
|
+
import AdminDocumentsScreen from "./AdminScreens/Documents.jsx";
|
|
10
11
|
export function getAdminRoutes(config) {
|
|
11
12
|
const {
|
|
12
13
|
appName,
|
|
@@ -16,8 +17,9 @@ export function getAdminRoutes(config) {
|
|
|
16
17
|
useAdminAccountsViewConfig,
|
|
17
18
|
useAdminSubjectsConfig,
|
|
18
19
|
useAdminLocationConfig,
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
useAdminDocumentsConfig,
|
|
22
|
+
useAdminEventsConfig,
|
|
21
23
|
userIsAdmin,
|
|
22
24
|
} = config;
|
|
23
25
|
|
|
@@ -59,36 +61,22 @@ export function getAdminRoutes(config) {
|
|
|
59
61
|
return <AdminLocationScreen config={locationConfig} />;
|
|
60
62
|
}
|
|
61
63
|
|
|
62
|
-
function LocationViewWrapper() {
|
|
63
|
-
const locationViewConfig =
|
|
64
|
-
typeof useAdminLocationViewConfig === "function"
|
|
65
|
-
? useAdminLocationViewConfig()
|
|
66
|
-
: undefined;
|
|
67
|
-
return <AdminSubjectsViewScreen config={{ ...locationViewConfig, subject: "location" }} />;
|
|
68
|
-
}
|
|
69
64
|
|
|
70
|
-
function StakeholderViewWrapper() {
|
|
71
|
-
const stakeholderViewConfig =
|
|
72
|
-
typeof useAdminSubjectsViewConfig === "function"
|
|
73
|
-
? useAdminSubjectsViewConfig()
|
|
74
|
-
: undefined;
|
|
75
|
-
return <AdminSubjectsViewScreen config={{ ...stakeholderViewConfig, subject: "stakeholder" }} />;
|
|
76
|
-
}
|
|
77
65
|
|
|
78
|
-
function
|
|
79
|
-
const
|
|
80
|
-
typeof
|
|
81
|
-
?
|
|
66
|
+
function DocumentsWrapper() {
|
|
67
|
+
const documentsConfig =
|
|
68
|
+
typeof useAdminDocumentsConfig === "function"
|
|
69
|
+
? useAdminDocumentsConfig()
|
|
82
70
|
: undefined;
|
|
83
|
-
return <
|
|
71
|
+
return <AdminDocumentsScreen config={documentsConfig} />;
|
|
84
72
|
}
|
|
85
73
|
|
|
86
|
-
function
|
|
87
|
-
const
|
|
88
|
-
typeof
|
|
89
|
-
?
|
|
74
|
+
function EventsWrapper() {
|
|
75
|
+
const eventsConfig =
|
|
76
|
+
typeof useAdminEventsConfig === "function"
|
|
77
|
+
? useAdminEventsConfig()
|
|
90
78
|
: undefined;
|
|
91
|
-
return <
|
|
79
|
+
return <AdminEventsScreen config={eventsConfig} />;
|
|
92
80
|
}
|
|
93
81
|
|
|
94
82
|
const subjectsIndexComponent =
|
|
@@ -96,6 +84,10 @@ export function getAdminRoutes(config) {
|
|
|
96
84
|
? <LocationWrapper />
|
|
97
85
|
: typeof useAdminSubjectsConfig === "function"
|
|
98
86
|
? <SubjectsWrapper />
|
|
87
|
+
: typeof useAdminDocumentsConfig === "function"
|
|
88
|
+
? <DocumentsWrapper />
|
|
89
|
+
: typeof useAdminEventsConfig === "function"
|
|
90
|
+
? <EventsWrapper />
|
|
99
91
|
: <div />;
|
|
100
92
|
|
|
101
93
|
const routes = [
|
|
@@ -156,6 +148,30 @@ export function getAdminRoutes(config) {
|
|
|
156
148
|
visible: (user) => userIsAdmin(user),
|
|
157
149
|
component: <SubjectsWrapper />,
|
|
158
150
|
},
|
|
151
|
+
|
|
152
|
+
]
|
|
153
|
+
|
|
154
|
+
: []),
|
|
155
|
+
...(typeof useAdminDocumentsConfig === "function"
|
|
156
|
+
? [
|
|
157
|
+
{
|
|
158
|
+
path: "management/subjects/document",
|
|
159
|
+
key: `${APP_PREFIX}_ADMIN_SUBJECTS_DOCUMENTS`,
|
|
160
|
+
exact: true,
|
|
161
|
+
visible: (user) => userIsAdmin(user),
|
|
162
|
+
component: <DocumentsWrapper />,
|
|
163
|
+
},
|
|
164
|
+
]
|
|
165
|
+
: []),
|
|
166
|
+
...(typeof useAdminEventsConfig === "function"
|
|
167
|
+
? [
|
|
168
|
+
{
|
|
169
|
+
path: "management/subjects/event",
|
|
170
|
+
key: `${APP_PREFIX}_ADMIN_SUBJECTS_EVENTS`,
|
|
171
|
+
exact: true,
|
|
172
|
+
visible: (user) => userIsAdmin(user),
|
|
173
|
+
component: <EventsWrapper />,
|
|
174
|
+
},
|
|
159
175
|
]
|
|
160
176
|
: []),
|
|
161
177
|
];
|
|
@@ -46,15 +46,20 @@ export function useAdminDashboard({ dashboardService, onError }) {
|
|
|
46
46
|
}, [dashboardService, onError]);
|
|
47
47
|
|
|
48
48
|
const fetchUserGrowth = useCallback(
|
|
49
|
-
async (
|
|
49
|
+
async (activeFilter) => {
|
|
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
|
+
|
|
55
60
|
setUserGrowthDataLoading(true);
|
|
56
61
|
try {
|
|
57
|
-
const response = await dashboardService.getUserGrowth(
|
|
62
|
+
const response = await dashboardService.getUserGrowth(activeFilter);
|
|
58
63
|
setUserGrowthData(response || []);
|
|
59
64
|
} catch (err) {
|
|
60
65
|
if (onError) {
|
|
@@ -68,11 +73,9 @@ export function useAdminDashboard({ dashboardService, onError }) {
|
|
|
68
73
|
},
|
|
69
74
|
[dashboardService, onError]
|
|
70
75
|
);
|
|
71
|
-
|
|
72
76
|
useEffect(() => {
|
|
73
77
|
fetchDashboardData();
|
|
74
78
|
}, [fetchDashboardData]);
|
|
75
|
-
|
|
76
79
|
return {
|
|
77
80
|
data,
|
|
78
81
|
loading,
|
|
@@ -80,8 +80,9 @@ export default function useSource({ user = {}, t = () => {}, getData = () => {},
|
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
export const useSources = ({type, id, user, t = () => {}}) => {
|
|
83
|
+
export const useSources = ({type, id, user, t = () => {}, stop}) => {
|
|
84
84
|
function getData(params) {
|
|
85
|
+
if(stop) return Promise.resolve({ data: [] });
|
|
85
86
|
if(id !== undefined && id !== null) {
|
|
86
87
|
return SourceService.getSources({type, id});
|
|
87
88
|
} else {
|
|
@@ -160,14 +160,26 @@ export const getColumns = ({ t, goTo, user, options, activeTab, getRedirectLink,
|
|
|
160
160
|
return <AvatarGroup items={sources} />;
|
|
161
161
|
},
|
|
162
162
|
},
|
|
163
|
+
{
|
|
164
|
+
title: t("Author"),
|
|
165
|
+
dataIndex: "author",
|
|
166
|
+
key: "author",
|
|
167
|
+
show: activeTab === "own",
|
|
168
|
+
render: (value, all) => {
|
|
169
|
+
if (all.empty) {
|
|
170
|
+
return <div className="daf-default-cell" />;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const author = value?.name;
|
|
174
|
+
return author ? <Tooltip title={author}>{author}</Tooltip> : '-';
|
|
175
|
+
},
|
|
176
|
+
ellipsis: true,
|
|
177
|
+
},
|
|
163
178
|
{
|
|
164
179
|
title: t("Status"),
|
|
165
180
|
dataIndex: "status",
|
|
166
181
|
key: "status",
|
|
167
182
|
show: activeTab === "own",
|
|
168
|
-
correctiveActions: activeTab === "own",
|
|
169
|
-
testimonials: activeTab === "own",
|
|
170
|
-
incident: activeTab === "own",
|
|
171
183
|
render: (value, all) => {
|
|
172
184
|
if (all.empty) {
|
|
173
185
|
return <div className="daf-default-cell" />;
|
|
@@ -8,6 +8,7 @@ import sourceAvatarConfig from '../../../../helpers/sourceAvatarConfig.js';
|
|
|
8
8
|
import MoreMenu from '../../../core/components/Table/MoreMenu/index.jsx';
|
|
9
9
|
import MoreOptions from '../../../core/components/Table/MoreOptions/index.jsx';
|
|
10
10
|
import { renderStatusTag } from '../../../utils/tags.js';
|
|
11
|
+
import MoreTags from '../../../core/components/Table/MoreTags/index.jsx';
|
|
11
12
|
|
|
12
13
|
export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink, theme, subject, data, applications, APP}) => [
|
|
13
14
|
{
|
|
@@ -105,7 +106,23 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
|
|
|
105
106
|
|
|
106
107
|
return <Tooltip title={category}>{category}</Tooltip>;
|
|
107
108
|
},
|
|
108
|
-
},
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
dataIndex: 'products',
|
|
112
|
+
title: t('Products'),
|
|
113
|
+
ellipsis: true,
|
|
114
|
+
show: APP === 'nashiriki',
|
|
115
|
+
render: (v, all) => {
|
|
116
|
+
if (all.empty) {
|
|
117
|
+
return <div className="daf-default-cell" />
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const products = v?.map((product) => product?.typeOfProduct);
|
|
121
|
+
const productOptions = findOptions(products, options?.minerals || options?.mineralOptions);
|
|
122
|
+
|
|
123
|
+
return productOptions?.length > 0 ? <MoreTags values={productOptions} limit={1} tagColor="processing" style={{ fontWeight: "normal", fontSize: 14 }} /> : '-';
|
|
124
|
+
},
|
|
125
|
+
},
|
|
109
126
|
{
|
|
110
127
|
dataIndex: 'operator',
|
|
111
128
|
title: t('Operator'),
|
|
@@ -11,6 +11,7 @@ export const getColumns = ({
|
|
|
11
11
|
subject,
|
|
12
12
|
data,
|
|
13
13
|
applications,
|
|
14
|
+
APP,
|
|
14
15
|
}) => {
|
|
15
16
|
const registry = FILTER_REGISTRY[subject] || FILTER_REGISTRY[DEFAULT_SUBJECT];
|
|
16
17
|
|
|
@@ -25,5 +26,6 @@ export const getColumns = ({
|
|
|
25
26
|
subject,
|
|
26
27
|
data,
|
|
27
28
|
applications,
|
|
29
|
+
APP,
|
|
28
30
|
});
|
|
29
31
|
}
|
|
@@ -17,6 +17,8 @@ export const useViewActions = ({
|
|
|
17
17
|
t,
|
|
18
18
|
viewConfig,
|
|
19
19
|
buttonActions,
|
|
20
|
+
canDelete,
|
|
21
|
+
deleteSubject,
|
|
20
22
|
}) => {
|
|
21
23
|
const [pageActions, setPageActions] = useState([]);
|
|
22
24
|
const [extraPageActions, setExtraPageActions] = useState([]);
|
|
@@ -50,6 +52,12 @@ export const useViewActions = ({
|
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
}
|
|
55
|
+
|
|
56
|
+
if(canDelete) {
|
|
57
|
+
if(viewConfig.deleteNamespaces.includes(namespace)){
|
|
58
|
+
actions.push(buttonActions.createDeleteButton(t, deleteSubject))
|
|
59
|
+
}
|
|
60
|
+
}
|
|
53
61
|
|
|
54
62
|
if (viewConfig.summaryNamespaces.includes(namespace)) {
|
|
55
63
|
extraActions.push(
|
|
@@ -58,6 +66,11 @@ export const useViewActions = ({
|
|
|
58
66
|
extraActions.push(
|
|
59
67
|
buttonActions.createRecordsButton(t, setOpenRecordsModal)
|
|
60
68
|
);
|
|
69
|
+
if(canDelete) {
|
|
70
|
+
if(viewConfig.deleteNamespaces.includes(namespace)){
|
|
71
|
+
extraActions.push(buttonActions.createDeleteButton(t, deleteSubject))
|
|
72
|
+
}
|
|
73
|
+
}
|
|
61
74
|
}
|
|
62
75
|
|
|
63
76
|
setPageActions(actions);
|
|
@@ -6,6 +6,7 @@ export const useViewPermissions = ({
|
|
|
6
6
|
namespaceOverrides = {
|
|
7
7
|
supportedNamespaces: {},
|
|
8
8
|
canEdit: {},
|
|
9
|
+
canDelete: {},
|
|
9
10
|
},
|
|
10
11
|
namespace,
|
|
11
12
|
user,
|
|
@@ -16,6 +17,7 @@ export const useViewPermissions = ({
|
|
|
16
17
|
viewConfig,
|
|
17
18
|
}) => {
|
|
18
19
|
const baseNamespaceKeys = Object.keys(namespaceConfig || {});
|
|
20
|
+
console.log({namespaceConfig})
|
|
19
21
|
|
|
20
22
|
const baseSupportedNamespaces = baseNamespaceKeys?.reduce((acc, key) => {
|
|
21
23
|
acc[key] = () => true;
|
|
@@ -55,6 +57,19 @@ export const useViewPermissions = ({
|
|
|
55
57
|
return canEditAction[namespace] ? canEditAction[namespace]() : false;
|
|
56
58
|
}, [namespace, data, user]);
|
|
57
59
|
|
|
60
|
+
const canDelete = useMemo(() => {
|
|
61
|
+
const basecanDeleteAction = baseNamespaceKeys.reduce((acc, key) => {
|
|
62
|
+
acc[key] = () => isUserData();
|
|
63
|
+
return acc;
|
|
64
|
+
}, {});
|
|
65
|
+
|
|
66
|
+
const canDeleteAction = {
|
|
67
|
+
...namespaceOverrides.canDelete,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return canDeleteAction[namespace] ? canDeleteAction[namespace]() : false;
|
|
71
|
+
}, [namespace, data, user, namespaceOverrides])
|
|
72
|
+
|
|
58
73
|
useEffect(() => {
|
|
59
74
|
if (data) {
|
|
60
75
|
if (typeof isSupportedNamespaces[namespace] === "function") {
|
|
@@ -69,6 +84,7 @@ export const useViewPermissions = ({
|
|
|
69
84
|
isSupportedNamespaces,
|
|
70
85
|
canEdit,
|
|
71
86
|
isSupported,
|
|
87
|
+
canDelete
|
|
72
88
|
}
|
|
73
89
|
|
|
74
90
|
}
|