datastake-daf 0.6.818 → 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 +2978 -1820
- package/dist/hooks/index.js +16 -5
- package/dist/pages/index.js +294 -95
- package/dist/services/index.js +104 -14
- 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/core/components/ViewForm/components/Records/config.js +1 -0
- package/src/@daf/core/components/ViewForm/components/Records/index.jsx +0 -1
- package/src/@daf/hooks/useAdminDashboard.js +7 -4
- package/src/@daf/hooks/useSources.js +2 -1
- package/src/@daf/pages/Dashboards/SupplyChain/components/KeyIndicators/config.js +2 -2
- package/src/@daf/pages/Dashboards/SupplyChain/components/KeyIndicators/index.js +3 -2
- package/src/@daf/pages/Dashboards/SupplyChain/index.jsx +4 -1
- package/src/@daf/pages/Dashboards/UserDashboard/components/KeyIndicators/config.js +3 -3
- package/src/@daf/pages/Dashboards/UserDashboard/components/KeyIndicators/index.jsx +4 -2
- package/src/@daf/pages/Dashboards/UserDashboard/components/MineSites/config.js +2 -2
- package/src/@daf/pages/Dashboards/UserDashboard/config.js +2 -2
- package/src/@daf/pages/Dashboards/UserDashboard/index.jsx +1 -0
- package/src/@daf/pages/Dashboards/helper.js +2 -2
- package/src/@daf/pages/Events/columns.js +15 -3
- package/src/@daf/pages/Events/config.js +1 -1
- package/src/@daf/pages/Locations/MineSite/columns.js +19 -2
- package/src/@daf/pages/TablePage/columns.js +2 -0
- package/src/@daf/pages/TablePage/create.jsx +3 -1
- 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/services/LinkedSubjects.js +1 -1
- 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/dist/style/datastake/mapbox-gl.css +0 -330
- 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 {
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import CustomIcon from '../../../../../core/components/Icon/CustomIcon.jsx';
|
|
3
3
|
import KeyIndicatorNavigateLabel from '../../../../../core/components/UI/KeyIndicatorNavigateLabel/index.jsx';
|
|
4
4
|
|
|
5
|
-
export const getRowConfig = ({ t, data = {}, goTo, getRedirectLink, theme = {} }) => [
|
|
5
|
+
export const getRowConfig = ({ t, data = {}, goTo, getRedirectLink, theme = {}, APP }) => [
|
|
6
6
|
{
|
|
7
7
|
label: (
|
|
8
8
|
<KeyIndicatorNavigateLabel
|
|
@@ -10,7 +10,7 @@ export const getRowConfig = ({ t, data = {}, goTo, getRedirectLink, theme = {} }
|
|
|
10
10
|
getRedirectLink={getRedirectLink}
|
|
11
11
|
theme={theme}
|
|
12
12
|
label="Identified Mine Sites"
|
|
13
|
-
link=
|
|
13
|
+
link={APP === 'nashiriki' ? '/app/scl' : '/app/production-sites'}
|
|
14
14
|
/>
|
|
15
15
|
),
|
|
16
16
|
render: () => {
|
|
@@ -13,7 +13,7 @@ const defaultFetchConfig = {
|
|
|
13
13
|
},
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
function KeyIndicators({selectedSources = {}, theme = {}, getRedirectLink = () => {}, t = () => {}, goTo = () => {} }) {
|
|
16
|
+
function KeyIndicators({selectedSources = {}, theme = {}, getRedirectLink = () => {}, t = () => {}, goTo = () => {}, APP }) {
|
|
17
17
|
const fetchConfig = useMemo(() => ({
|
|
18
18
|
...defaultFetchConfig,
|
|
19
19
|
filters: { ...defaultFetchConfig.filters, sources: selectedSources?.partners || [] },
|
|
@@ -29,8 +29,9 @@ function KeyIndicators({selectedSources = {}, theme = {}, getRedirectLink = () =
|
|
|
29
29
|
goTo,
|
|
30
30
|
getRedirectLink,
|
|
31
31
|
theme,
|
|
32
|
+
APP
|
|
32
33
|
})
|
|
33
|
-
}, [t, data, goTo, getRedirectLink, theme])
|
|
34
|
+
}, [t, data, goTo, getRedirectLink, theme, APP])
|
|
34
35
|
|
|
35
36
|
return (
|
|
36
37
|
<KeyIndicatorsWidget
|
|
@@ -21,6 +21,8 @@ function SupplyChain({
|
|
|
21
21
|
informationSources,
|
|
22
22
|
hardcodedData,
|
|
23
23
|
breadcrumbs = [],
|
|
24
|
+
supportText,
|
|
25
|
+
APP,
|
|
24
26
|
}) {
|
|
25
27
|
|
|
26
28
|
const sourceOptions = useMemo(() => {
|
|
@@ -69,12 +71,13 @@ function SupplyChain({
|
|
|
69
71
|
/>
|
|
70
72
|
</div>
|
|
71
73
|
}
|
|
74
|
+
supportText={supportText}
|
|
72
75
|
breadcrumbs={breadcrumbs}
|
|
73
76
|
/>
|
|
74
77
|
}
|
|
75
78
|
>
|
|
76
79
|
<section>
|
|
77
|
-
<KeyIndicators selectedSources={selectedPartners} theme={theme} t={t} goTo={goTo} getRedirectLink={getRedirectLink} />
|
|
80
|
+
<KeyIndicators selectedSources={selectedPartners} theme={theme} t={t} goTo={goTo} getRedirectLink={getRedirectLink} APP={APP} />
|
|
78
81
|
</section>
|
|
79
82
|
<section>
|
|
80
83
|
<SupplyChainMap selectedSources={selectedPartners} t={t} goTo={goTo} options={options} getRedirectLink={getRedirectLink} />
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import CustomIcon from '../../../../../core/components/Icon/CustomIcon.jsx';
|
|
3
3
|
import KeyIndicatorNavigateLabel from '../../../../../core/components/UI/KeyIndicatorNavigateLabel/index.jsx';
|
|
4
4
|
|
|
5
|
-
export const getRowConfig = ({ t, data = {}, goTo, getRedirectLink, theme = {} }) => [
|
|
5
|
+
export const getRowConfig = ({ t, data = {}, goTo, getRedirectLink, theme = {}, APP }) => [
|
|
6
6
|
{
|
|
7
7
|
label: (
|
|
8
8
|
<KeyIndicatorNavigateLabel
|
|
@@ -35,8 +35,8 @@ export const getRowConfig = ({ t, data = {}, goTo, getRedirectLink, theme = {} }
|
|
|
35
35
|
t={t}
|
|
36
36
|
getRedirectLink={getRedirectLink}
|
|
37
37
|
theme={theme}
|
|
38
|
-
label=
|
|
39
|
-
link=
|
|
38
|
+
label={APP === 'nashiriki' ? 'Corrective Actions' : 'Activities'}
|
|
39
|
+
link={APP === 'nashiriki' ? '/app/corrective-actions' : '/app/activities'}
|
|
40
40
|
/>
|
|
41
41
|
),
|
|
42
42
|
render: () => {
|
|
@@ -17,6 +17,7 @@ function KeyIndicators({
|
|
|
17
17
|
getRedirectLink = () => {},
|
|
18
18
|
theme = {},
|
|
19
19
|
partners = [],
|
|
20
|
+
APP,
|
|
20
21
|
}) {
|
|
21
22
|
const fetchConfig = useMemo(
|
|
22
23
|
() => ({
|
|
@@ -33,9 +34,10 @@ function KeyIndicators({
|
|
|
33
34
|
data: { ...data, partners },
|
|
34
35
|
goTo,
|
|
35
36
|
getRedirectLink,
|
|
36
|
-
theme
|
|
37
|
+
theme,
|
|
38
|
+
APP
|
|
37
39
|
}),
|
|
38
|
-
[t, data, goTo, getRedirectLink, partners, theme],
|
|
40
|
+
[t, data, goTo, getRedirectLink, partners, theme, APP],
|
|
39
41
|
);
|
|
40
42
|
|
|
41
43
|
return (
|
|
@@ -9,7 +9,7 @@ export const getTabs = (t) => {
|
|
|
9
9
|
export const getFiltersConfig = ({t, filters, activeTab, options}) => {
|
|
10
10
|
const value = filters.type ? { value: filters.type } : {};
|
|
11
11
|
|
|
12
|
-
const eventCategoryOptions = (options?.eventCategoryOptions || [])?.map((item) => ({
|
|
12
|
+
const eventCategoryOptions = (options?.eventCategoryOptions || options?.categoryOptions || [])?.map((item) => ({
|
|
13
13
|
value: item.value,
|
|
14
14
|
label: typeof item.label === 'object' ? Object.values(item.label)[1] : item.label,
|
|
15
15
|
}))
|
|
@@ -22,7 +22,7 @@ export const getFiltersConfig = ({t, filters, activeTab, options}) => {
|
|
|
22
22
|
key: "category",
|
|
23
23
|
type: "select",
|
|
24
24
|
...value,
|
|
25
|
-
options: options?.categoriesOptions
|
|
25
|
+
options: options?.categoriesOptions || options?.category || [],
|
|
26
26
|
},
|
|
27
27
|
];
|
|
28
28
|
}
|
|
@@ -2,12 +2,12 @@ export const getActionWidgetsConfig = ({ goTo, getRedirectLink, APP, t }) => [
|
|
|
2
2
|
{
|
|
3
3
|
icon: "MineSite",
|
|
4
4
|
title: t("Create Mine Site"),
|
|
5
|
-
onClick: () => goTo(getRedirectLink(
|
|
5
|
+
onClick: () => goTo(getRedirectLink(`/app/${APP === 'nashiriki' ? 'scl' : 'production-sites'}?create=true`)),
|
|
6
6
|
},
|
|
7
7
|
{
|
|
8
8
|
icon: "FileEdit",
|
|
9
9
|
title: "Report Activity",
|
|
10
|
-
onClick: () => goTo(getRedirectLink(
|
|
10
|
+
onClick: () => goTo(getRedirectLink(`/app/${APP === 'nashiriki' ? 'corrective-actions' : 'activities'}?create=true`)),
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
13
|
icon: "ReportIncidents",
|
|
@@ -53,7 +53,7 @@ export const mapDataForChainOfCustody = (data = {}, options = {}, goTo = () => {
|
|
|
53
53
|
number: 0,
|
|
54
54
|
name: item.name,
|
|
55
55
|
sources: parentId ? [parentId] : [],
|
|
56
|
-
subTitle: findOptions(item?.category, options?.categoriesOptions),
|
|
56
|
+
subTitle: findOptions(item?.category, options?.categoriesOptions || options?.category || []),
|
|
57
57
|
leftIcon: type === "client" ? rightIcon : leftIcon,
|
|
58
58
|
leftBackground: type === "client" ? rightBackground : leftBackground,
|
|
59
59
|
topIcon: mapIcon(item.category),
|
|
@@ -70,7 +70,7 @@ export const mapDataForChainOfCustody = (data = {}, options = {}, goTo = () => {
|
|
|
70
70
|
id: data.id,
|
|
71
71
|
number: 0,
|
|
72
72
|
name: data.name,
|
|
73
|
-
subTitle: findOptions(data?.category, options?.categoriesOptions),
|
|
73
|
+
subTitle: findOptions(data?.category, options?.categoriesOptions || options?.category || []),
|
|
74
74
|
leftIcon: middleIcon,
|
|
75
75
|
leftBackground: theme.colorPrimary10,
|
|
76
76
|
topIcon: mapIcon(data.category),
|
|
@@ -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" />;
|