datastake-daf 0.6.798 → 0.6.800
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 +1206 -311
- package/dist/context/index.js +6 -6
- package/dist/pages/index.js +250 -14
- package/dist/services/index.js +187 -84
- package/dist/utils/index.js +14 -17
- package/package.json +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/hook.js +0 -1
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/index.jsx +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/hook.js +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/index.jsx +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminModals/AddUser/index.jsx +0 -1
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/columns.js +79 -0
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/helper.js +2 -2
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/index.jsx +18 -8
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineSubjects/index.jsx +6 -6
- package/src/@daf/core/components/Screens/Admin/AdminModals/NewAccount/index.jsx +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminModals/NewUser/index.jsx +61 -38
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Accounts.jsx +1 -4
- package/src/@daf/core/components/Screens/Admin/AdminScreens/AccountsView.jsx +2 -0
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Dashboard.jsx +2 -2
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Location.jsx +10 -8
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Subjects.jsx +5 -3
- package/src/@daf/core/components/Screens/Admin/AdminScreens/SubjectsView.jsx +395 -0
- package/src/@daf/core/components/Screens/Admin/AdminScreens/index.js +1 -0
- package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/index.jsx +1 -0
- package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/column.js +225 -0
- package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/helper.js +65 -0
- package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/index.jsx +78 -46
- package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/columns.js +41 -39
- package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/index.jsx +53 -24
- package/src/@daf/core/components/Screens/Admin/AdminTables/UserTable/index.jsx +1 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/configTransformer.js +137 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/index.js +9 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/index.jsx +196 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/configTransformer.js +216 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/index.js +7 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/index.jsx +184 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/config.js +64 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/helpers.js +13 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/index.jsx +77 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/config.js +51 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/helpers.js +0 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/index.jsx +75 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Edit/index.jsx +7 -1
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/SidebarMenu/index.jsx +5 -3
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/helper.js +13 -8
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/index.jsx +16 -10
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/View/index.jsx +2 -1
- package/src/@daf/core/components/Screens/Admin/AdminViews/index.jsx +66 -26
- package/src/@daf/core/components/Screens/Admin/AppInvitation/index.jsx +193 -0
- package/src/@daf/core/components/Screens/Admin/adminRoutes.js +37 -2
- package/src/@daf/layouts/AppLayout/index.jsx +0 -1
- package/src/@daf/pages/Edit/hooks/usePrepareForm.js +1 -1
- package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/columns.js +180 -0
- package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/config.js +0 -0
- package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/index.jsx +27 -0
- package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/columns.js +157 -0
- package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/config.js +31 -0
- package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/index.js +77 -0
- package/src/@daf/pages/SelfAssesment/components/ProductionSiteTable/columns.js +117 -0
- package/src/@daf/pages/SelfAssesment/components/ProductionSiteTable/index.jsx +54 -0
- package/src/@daf/pages/SelfAssesment/index.jsx +0 -0
- package/src/@daf/pages/View/hooks/usePrepareForm.js +11 -1
- package/src/@daf/pages/View/index.jsx +9 -2
- package/src/@daf/services/AdminService.js +112 -7
- package/src/@daf/services/AuthenticationService.js +1 -0
- package/src/@daf/services/DashboardService.js +2 -1
- package/src/@daf/utils/filters.js +15 -13
- package/src/constants/locales/en/translation.js +7 -0
- package/src/constants/locales/fr/translation.js +1 -1
- package/src/constants/locales/sp/translation.js +1 -1
- package/src/index.js +1 -0
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import React, { useState, useEffect, useCallback, useMemo } from "react";
|
|
2
|
+
import Header from "../../../Header/index.jsx";
|
|
3
|
+
import Loading from "../../../Loading/index.jsx";
|
|
4
|
+
import SideBarMenu from "../AdminViews/components/SidebarMenu/index.jsx";
|
|
5
|
+
import ViewLocation from "../AdminViews/ViewLocation/index.jsx";
|
|
6
|
+
import ViewStakeholder from "../AdminViews/ViewStakeholder/index.jsx";
|
|
7
|
+
import EditLocation from "../AdminViews/EditLocation/index.jsx";
|
|
8
|
+
import EditStakeholder from "../AdminViews/EditStakeholder/index.jsx";
|
|
9
|
+
import { config as locationConfig } from "../AdminViews/ViewLocation/config.js";
|
|
10
|
+
import { config as stakeholderConfig } from "../AdminViews/ViewStakeholder/config.js";
|
|
11
|
+
import NotFound from "../../NotFound/index.jsx";
|
|
12
|
+
import { Form, message, Modal } from "antd";
|
|
13
|
+
import { ExclamationCircleOutlined } from "@ant-design/icons";
|
|
14
|
+
import { NOTIFICATION_MODE, useForms, FormsProvider } from "../../../../context/Forms/index.js";
|
|
15
|
+
import { getMainApiUrl, getAppHeader as getBaseAppHeader } from "../../../../../services/BaseService.js";
|
|
16
|
+
|
|
17
|
+
function withFormsProvider(Component) {
|
|
18
|
+
return function WrappedWithFormsProvider(props) {
|
|
19
|
+
return (
|
|
20
|
+
<FormsProvider>
|
|
21
|
+
<Component {...props} />
|
|
22
|
+
</FormsProvider>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
function normalizeFormData(data) {
|
|
29
|
+
if (!data || typeof data !== 'object') {
|
|
30
|
+
return data;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const normalized = { ...data };
|
|
34
|
+
|
|
35
|
+
Object.keys(normalized).forEach(key => {
|
|
36
|
+
const value = normalized[key];
|
|
37
|
+
|
|
38
|
+
if (value === null || value === undefined) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
if (value.length > 0 && typeof value[0] === 'object' && value[0] !== null) {
|
|
44
|
+
if ('value' in value[0]) {
|
|
45
|
+
normalized[key] = value.map(item => item.value);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (typeof value === 'object' && 'value' in value) {
|
|
52
|
+
normalized[key] = value.value;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return normalized;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Admin Subjects View Screen
|
|
61
|
+
* This component handles viewing and editing individual subjects (locations or stakeholders)
|
|
62
|
+
*
|
|
63
|
+
* @param {Object} config - Application configuration
|
|
64
|
+
* @param {string} config.subject - Subject type: "location" or "stakeholder"
|
|
65
|
+
* @param {string} config.id - Subject ID from route params
|
|
66
|
+
* @param {string} config.mode - Mode: "view" or "edit"
|
|
67
|
+
* @param {string} config.module - Module identifier
|
|
68
|
+
* @param {Function} config.goTo - Navigation function
|
|
69
|
+
* @param {Function} config.t - Translation function
|
|
70
|
+
* @param {Object} config.location - Router location object
|
|
71
|
+
* @param {Function} config.getRedirectLink - Function to get redirect links
|
|
72
|
+
* @param {Function} config.renderBreadCrumbs - Function to render breadcrumbs
|
|
73
|
+
* @param {Object} config.options - Options object with countries, categories, etc.
|
|
74
|
+
* @param {Function} config.AdminService - Admin service for API calls
|
|
75
|
+
* @param {Function} config.handleError - Error handling function
|
|
76
|
+
*/
|
|
77
|
+
function AdminSubjectsViewScreen({ config }) {
|
|
78
|
+
const {
|
|
79
|
+
subject,
|
|
80
|
+
id,
|
|
81
|
+
mode = "view",
|
|
82
|
+
module,
|
|
83
|
+
goTo,
|
|
84
|
+
t,
|
|
85
|
+
location,
|
|
86
|
+
getRedirectLink,
|
|
87
|
+
renderBreadCrumbs,
|
|
88
|
+
options,
|
|
89
|
+
AdminService,
|
|
90
|
+
handleError,
|
|
91
|
+
userRoles = [],
|
|
92
|
+
accountStatuses = [],
|
|
93
|
+
getApiBaseUrl = getMainApiUrl,
|
|
94
|
+
getAppHeader = getBaseAppHeader,
|
|
95
|
+
} = config;
|
|
96
|
+
|
|
97
|
+
const [loading, setLoading] = useState(false);
|
|
98
|
+
const [data, setData] = useState({});
|
|
99
|
+
const [editData, setEditData] = useState({});
|
|
100
|
+
const [isChanged, setIsChanged] = useState(false);
|
|
101
|
+
const [selectedGroup, setSelectedGroup] = useState("");
|
|
102
|
+
const [MainForm] = Form.useForm();
|
|
103
|
+
const { setNotificationMode, changeNotificationState, ajaxForms } = useForms();
|
|
104
|
+
|
|
105
|
+
const configs = useMemo(() => {
|
|
106
|
+
return subject === "location" ? locationConfig : stakeholderConfig;
|
|
107
|
+
}, [subject]);
|
|
108
|
+
|
|
109
|
+
const conf = useMemo(() => {
|
|
110
|
+
if (!Array.isArray(configs) || configs.length === 0) {
|
|
111
|
+
console.warn("configs is not a valid array:", configs);
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (!selectedGroup) {
|
|
116
|
+
setSelectedGroup(configs[0].key);
|
|
117
|
+
return configs[0];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const foundConfig = configs.find((c) => c.key === selectedGroup);
|
|
121
|
+
return foundConfig || configs[0];
|
|
122
|
+
}, [selectedGroup, configs]);
|
|
123
|
+
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
const normalizedData = normalizeFormData(data);
|
|
126
|
+
|
|
127
|
+
console.log(' Form Data Normalization:', {
|
|
128
|
+
rawData: data,
|
|
129
|
+
normalizedData: normalizedData,
|
|
130
|
+
changes: Object.keys(data).filter(key =>
|
|
131
|
+
JSON.stringify(data[key]) !== JSON.stringify(normalizedData[key])
|
|
132
|
+
).map(key => ({
|
|
133
|
+
field: key,
|
|
134
|
+
original: data[key],
|
|
135
|
+
normalized: normalizedData[key]
|
|
136
|
+
}))
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
MainForm.setFieldsValue(normalizedData);
|
|
140
|
+
setEditData(normalizedData);
|
|
141
|
+
}, [data, MainForm]);
|
|
142
|
+
|
|
143
|
+
const goToView = useCallback(() => {
|
|
144
|
+
changeNotificationState({
|
|
145
|
+
onYes: () => {
|
|
146
|
+
setEditData(data);
|
|
147
|
+
setIsChanged(false);
|
|
148
|
+
goTo(`/app/view/management-${subject}/${id}`);
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
}, [goTo, changeNotificationState, data, subject, id]);
|
|
152
|
+
|
|
153
|
+
const fetchData = useCallback(async () => {
|
|
154
|
+
try {
|
|
155
|
+
setLoading(true);
|
|
156
|
+
|
|
157
|
+
let response;
|
|
158
|
+
if (subject === "location") {
|
|
159
|
+
response = await AdminService.viewLocation({ id });
|
|
160
|
+
} else if (subject === "stakeholder") {
|
|
161
|
+
response = await AdminService.viewStakeholder({ id });
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (response?.data) {
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
if (!response.data.id) {
|
|
168
|
+
console.error(' Warning: Backend response missing UUID (id field). Only datastakeId present:', {
|
|
169
|
+
datastakeId: response.data.datastakeId,
|
|
170
|
+
fullData: response.data
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
setData(response.data);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
setLoading(false);
|
|
178
|
+
} catch (err) {
|
|
179
|
+
if (handleError) {
|
|
180
|
+
handleError(err);
|
|
181
|
+
}
|
|
182
|
+
setLoading(false);
|
|
183
|
+
}
|
|
184
|
+
}, [id, subject, AdminService, handleError]);
|
|
185
|
+
|
|
186
|
+
useEffect(() => {
|
|
187
|
+
fetchData();
|
|
188
|
+
}, [fetchData]);
|
|
189
|
+
|
|
190
|
+
const breadCrumbs = useMemo(() => {
|
|
191
|
+
if (renderBreadCrumbs) {
|
|
192
|
+
return renderBreadCrumbs({
|
|
193
|
+
view: subject === "location" ? "location" : "stakeholder",
|
|
194
|
+
t,
|
|
195
|
+
goTo,
|
|
196
|
+
id,
|
|
197
|
+
isView: mode === "view",
|
|
198
|
+
isEdit: mode === "edit",
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
return [];
|
|
202
|
+
}, [renderBreadCrumbs, subject, t, goTo, id, mode]);
|
|
203
|
+
|
|
204
|
+
const formOptions = useMemo(() => {
|
|
205
|
+
const opts = options || {};
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
return {
|
|
209
|
+
...opts,
|
|
210
|
+
|
|
211
|
+
countries: opts.countries || [],
|
|
212
|
+
// category: opts.categoriesOptions || [],
|
|
213
|
+
locationCategories: opts.locationCategories || [],
|
|
214
|
+
|
|
215
|
+
};
|
|
216
|
+
}, [options]);
|
|
217
|
+
|
|
218
|
+
const handleDelete = useCallback(() => {
|
|
219
|
+
const subjectName = subject === "location" ? t("location") : t("stakeholder");
|
|
220
|
+
|
|
221
|
+
Modal.confirm({
|
|
222
|
+
title: t("Delete") + " " + subjectName,
|
|
223
|
+
icon: <ExclamationCircleOutlined />,
|
|
224
|
+
content: t(`Are you sure you want to delete this ${subjectName}? This action cannot be undone.`),
|
|
225
|
+
okText: t("Delete"),
|
|
226
|
+
okType: "danger",
|
|
227
|
+
cancelText: t("Cancel"),
|
|
228
|
+
onOk: async () => {
|
|
229
|
+
setLoading(true);
|
|
230
|
+
try {
|
|
231
|
+
const uuid = data.id;
|
|
232
|
+
|
|
233
|
+
if (!uuid) {
|
|
234
|
+
throw new Error('UUID not found in subject data');
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
await AdminService.deleteSubject({
|
|
238
|
+
subject,
|
|
239
|
+
id: uuid
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
message.success(t(`${subjectName} deleted successfully`));
|
|
243
|
+
goTo(`/app/management/subject/${subject}`);
|
|
244
|
+
} catch (err) {
|
|
245
|
+
handleError(err);
|
|
246
|
+
setLoading(false);
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
});
|
|
250
|
+
}, [subject, data, AdminService, handleError, t, goTo]);
|
|
251
|
+
|
|
252
|
+
const actionButtons = useMemo(() => {
|
|
253
|
+
if (mode === "view") {
|
|
254
|
+
return [
|
|
255
|
+
{
|
|
256
|
+
type: "primary",
|
|
257
|
+
tooltip: t("Edit"),
|
|
258
|
+
icon: "Edit",
|
|
259
|
+
onClick: () => goTo(`/app/edit/management-${subject}/${id}`),
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
type: "danger",
|
|
263
|
+
tooltip: t("Delete"),
|
|
264
|
+
icon: "Delete",
|
|
265
|
+
onClick: handleDelete,
|
|
266
|
+
},
|
|
267
|
+
];
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return [
|
|
271
|
+
{
|
|
272
|
+
type: "primary",
|
|
273
|
+
tooltip: t("Save"),
|
|
274
|
+
icon: "Save",
|
|
275
|
+
disabled: !isChanged,
|
|
276
|
+
onClick: () => {
|
|
277
|
+
MainForm.validateFields()
|
|
278
|
+
.then(async (formData) => {
|
|
279
|
+
setLoading(true);
|
|
280
|
+
|
|
281
|
+
try {
|
|
282
|
+
const allowedKeys = conf?.items?.map(item => item.key) || [];
|
|
283
|
+
const filteredData = {};
|
|
284
|
+
allowedKeys.forEach(key => {
|
|
285
|
+
if (formData[key] !== undefined) {
|
|
286
|
+
filteredData[key] = formData[key];
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
const uuid = editData.id || data.id;
|
|
291
|
+
|
|
292
|
+
console.log('🔍 Debug - Save operation:', {
|
|
293
|
+
editDataId: editData.id,
|
|
294
|
+
dataId: data.id,
|
|
295
|
+
editDataDatastakeId: editData.datastakeId,
|
|
296
|
+
dataDatastakeId: data.datastakeId,
|
|
297
|
+
uuidUsed: uuid,
|
|
298
|
+
routeParamId: id
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
if (!uuid) {
|
|
302
|
+
console.error('UUID not found. Available data:', {
|
|
303
|
+
editData,
|
|
304
|
+
data,
|
|
305
|
+
routeParamId: id
|
|
306
|
+
});
|
|
307
|
+
throw new Error('UUID not found in subject data. Please refresh the page and try again.');
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (typeof uuid !== 'string' || uuid.length < 20) {
|
|
311
|
+
console.error('Invalid UUID format detected:', uuid);
|
|
312
|
+
throw new Error('Invalid UUID format');
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
await AdminService.updateSubject({
|
|
316
|
+
subject,
|
|
317
|
+
id: uuid,
|
|
318
|
+
data: filteredData
|
|
319
|
+
});
|
|
320
|
+
await fetchData();
|
|
321
|
+
message.success(t("Information saved successfully"));
|
|
322
|
+
setNotificationMode(NOTIFICATION_MODE.EMPTY);
|
|
323
|
+
setIsChanged(false);
|
|
324
|
+
goTo(`/app/view/management-${subject}/${id}`);
|
|
325
|
+
} catch (err) {
|
|
326
|
+
handleError(err);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
setLoading(false);
|
|
330
|
+
})
|
|
331
|
+
.catch(() => {});
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
tooltip: t("Cancel"),
|
|
336
|
+
icon: "Close",
|
|
337
|
+
onClick: goToView,
|
|
338
|
+
},
|
|
339
|
+
];
|
|
340
|
+
}, [t, mode, MainForm, goToView, isChanged, editData, fetchData, subject, id, goTo, handleError, AdminService, setNotificationMode, data, conf, handleDelete]);
|
|
341
|
+
|
|
342
|
+
const ViewComponent = subject === "location" ? ViewLocation : ViewStakeholder;
|
|
343
|
+
const EditComponent = subject === "location" ? EditLocation : EditStakeholder;
|
|
344
|
+
|
|
345
|
+
return (
|
|
346
|
+
<div className={mode === "view" ? "daf-view-form" : "daf-edit-form"}>
|
|
347
|
+
{loading && <Loading background="white" />}
|
|
348
|
+
<Header
|
|
349
|
+
title={data.name || t("Loading...")}
|
|
350
|
+
breadcrumbs={breadCrumbs}
|
|
351
|
+
actionButtons={actionButtons}
|
|
352
|
+
/>
|
|
353
|
+
<div className="view-content">
|
|
354
|
+
<SideBarMenu
|
|
355
|
+
selectedGroup={selectedGroup}
|
|
356
|
+
onChange={(v) => setSelectedGroup(v)}
|
|
357
|
+
t={t}
|
|
358
|
+
config={configs}
|
|
359
|
+
/>
|
|
360
|
+
{mode === "edit" ? (
|
|
361
|
+
<EditComponent
|
|
362
|
+
t={t}
|
|
363
|
+
conf={conf}
|
|
364
|
+
data={editData}
|
|
365
|
+
formOptions={formOptions}
|
|
366
|
+
MainForm={MainForm}
|
|
367
|
+
setData={setEditData}
|
|
368
|
+
isChanged={isChanged}
|
|
369
|
+
setIsChanged={setIsChanged}
|
|
370
|
+
goToView={goToView}
|
|
371
|
+
getApiBaseUrl={getApiBaseUrl}
|
|
372
|
+
getAppHeader={getAppHeader}
|
|
373
|
+
ajaxForms={ajaxForms}
|
|
374
|
+
/>
|
|
375
|
+
) : (
|
|
376
|
+
<ViewComponent
|
|
377
|
+
userRoles={userRoles}
|
|
378
|
+
formOptions={formOptions}
|
|
379
|
+
conf={conf}
|
|
380
|
+
data={data}
|
|
381
|
+
t={t}
|
|
382
|
+
goTo={goTo}
|
|
383
|
+
location={location}
|
|
384
|
+
getRedirectLink={getRedirectLink}
|
|
385
|
+
accountStatuses={accountStatuses}
|
|
386
|
+
module={module}
|
|
387
|
+
/>
|
|
388
|
+
)}
|
|
389
|
+
</div>
|
|
390
|
+
</div>
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export default withFormsProvider(AdminSubjectsViewScreen);
|
|
395
|
+
|
|
@@ -10,3 +10,4 @@ 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 AdminSubjectsViewScreen } from "./SubjectsView.jsx";
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { Checkbox, Tooltip, Avatar } from "antd";
|
|
2
|
+
import CustomIcon from "../../../../Icon/CustomIcon.jsx";
|
|
3
|
+
import { findOptions } from "../../../../../../../helpers/StringHelper.js";
|
|
4
|
+
import { getNameByLevel } from "../../AdminViews/ViewLocation/helpers.js";
|
|
5
|
+
|
|
6
|
+
export const getColumns = ({
|
|
7
|
+
t,
|
|
8
|
+
goTo = () => {},
|
|
9
|
+
show = "show",
|
|
10
|
+
getRedirectLink = () => {},
|
|
11
|
+
token,
|
|
12
|
+
selectedLocations,
|
|
13
|
+
setSelectedLocations,
|
|
14
|
+
selectOptions,
|
|
15
|
+
entity,
|
|
16
|
+
user,
|
|
17
|
+
options,
|
|
18
|
+
}) => {
|
|
19
|
+
const cols = [
|
|
20
|
+
{
|
|
21
|
+
title: "",
|
|
22
|
+
dataIndex: "select",
|
|
23
|
+
key: "select",
|
|
24
|
+
width: 50,
|
|
25
|
+
show: true,
|
|
26
|
+
render: (v, all) => {
|
|
27
|
+
if (all.empty) {
|
|
28
|
+
return <div className="daf-default-cell" />;
|
|
29
|
+
}
|
|
30
|
+
return (
|
|
31
|
+
<Checkbox
|
|
32
|
+
onChange={() =>
|
|
33
|
+
setSelectedLocations((prev) => {
|
|
34
|
+
const isSelected = prev.some((p) => p.id === all.id);
|
|
35
|
+
if (isSelected) {
|
|
36
|
+
return prev.filter((p) => p.id !== all.id);
|
|
37
|
+
}
|
|
38
|
+
return [...prev, all];
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
checked={selectedLocations.some((p) => p.id === all.id)}
|
|
42
|
+
disabled={
|
|
43
|
+
selectedLocations?.length >= 3 &&
|
|
44
|
+
!selectedLocations.some((p) => p.id === all.id)
|
|
45
|
+
}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
title: t("ID"),
|
|
52
|
+
dataIndex: "datastakeId",
|
|
53
|
+
key: "datastakeId",
|
|
54
|
+
ellipsis: true,
|
|
55
|
+
show: true,
|
|
56
|
+
render: (value, all) => {
|
|
57
|
+
if (all.empty) {
|
|
58
|
+
return <div className="daf-default-cell" />;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return <Tooltip title={value}>{value}</Tooltip>;
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
title: t("Name"),
|
|
66
|
+
dataIndex: "name",
|
|
67
|
+
key: "name",
|
|
68
|
+
ellipsis: true,
|
|
69
|
+
show: true,
|
|
70
|
+
render: (value, all) => {
|
|
71
|
+
if (all.empty) {
|
|
72
|
+
return <div className="daf-default-cell" />;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return <Tooltip title={value}>{value}</Tooltip>;
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
title: t("Category"),
|
|
80
|
+
dataIndex: "category",
|
|
81
|
+
key: "category",
|
|
82
|
+
ellipsis: true,
|
|
83
|
+
show: true,
|
|
84
|
+
render: (value, all) => {
|
|
85
|
+
if (all.empty) {
|
|
86
|
+
return <div className="daf-default-cell" />;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const category = findOptions(value, selectOptions?.category || []) || "--";
|
|
90
|
+
|
|
91
|
+
return <Tooltip title={category}>{category}</Tooltip>;
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
title: t("Country"),
|
|
96
|
+
dataIndex: "country",
|
|
97
|
+
key: "country",
|
|
98
|
+
ellipsis: true,
|
|
99
|
+
show: true,
|
|
100
|
+
render: (value, all) => {
|
|
101
|
+
if (all.empty) {
|
|
102
|
+
return <div className="daf-default-cell" />;
|
|
103
|
+
}
|
|
104
|
+
const country = findOptions(value, selectOptions?.country || []) || "--";
|
|
105
|
+
|
|
106
|
+
return <Tooltip title={country}>{country}</Tooltip>;
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
title: findOptions(user?.company?.country, options?.administrativeLevel1)?.length > 2 ? findOptions(user?.company?.country, options?.administrativeLevel1) : t("Province"),
|
|
111
|
+
dataIndex: "administrativeLevel1",
|
|
112
|
+
key: "administrativeLevel1",
|
|
113
|
+
ellipsis: true,
|
|
114
|
+
show: entity.includes("location"),
|
|
115
|
+
render: (value, all) => {
|
|
116
|
+
if (all.empty) {
|
|
117
|
+
return <div className="daf-default-cell" />;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
let label;
|
|
121
|
+
if(all?.administrativeLevel1 && value === all?.administrativeLevel1) {
|
|
122
|
+
label = all?.linking?.SCL?.[value]?.name
|
|
123
|
+
} else {
|
|
124
|
+
label = getNameByLevel(all?.linking?.SCL, "level_1")?.name
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return <Tooltip title={label || '-'}>{label || '-'}</Tooltip>;
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
title: findOptions(user?.company?.country, options?.administrativeLevel2)?.length > 2 ? findOptions(user?.company?.country, options?.administrativeLevel2) : t("Territory"),
|
|
132
|
+
dataIndex: "administrativeLevel2",
|
|
133
|
+
key: "administrativeLevel2",
|
|
134
|
+
show: entity.includes("location"),
|
|
135
|
+
ellipsis: true,
|
|
136
|
+
render: (value, all) => {
|
|
137
|
+
if (all.empty) {
|
|
138
|
+
return <div className="daf-default-cell" />;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
let label;
|
|
142
|
+
if(all?.administrativeLevel2 && value === all?.administrativeLevel2) {
|
|
143
|
+
label = all?.linking?.SCL?.[value]?.name
|
|
144
|
+
} else {
|
|
145
|
+
label = getNameByLevel(all?.linking?.SCL, "level_2")?.name
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return <Tooltip title={label || '-'}>{label || '-'}</Tooltip>;
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
title: t("Sources"),
|
|
153
|
+
dataIndex: "sources",
|
|
154
|
+
key: "sources",
|
|
155
|
+
show: true,
|
|
156
|
+
render: (value, all) => {
|
|
157
|
+
if (all.empty) {
|
|
158
|
+
return <div className="daf-default-cell" />;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const MAX_SOURCES = 3;
|
|
162
|
+
const count = value?.length === MAX_SOURCES + 1 ? value?.length : MAX_SOURCES;
|
|
163
|
+
return (
|
|
164
|
+
Array.isArray(value) && value?.length > 0 ? <Avatar.Group
|
|
165
|
+
max={{
|
|
166
|
+
count: count,
|
|
167
|
+
style: {
|
|
168
|
+
color: token.baseGray90,
|
|
169
|
+
backgroundColor: token.baseGray20,
|
|
170
|
+
border: `1px solid ${token.baseGray40}`,
|
|
171
|
+
},
|
|
172
|
+
}}
|
|
173
|
+
size={"small"}
|
|
174
|
+
>
|
|
175
|
+
{value.map((v, i) => (
|
|
176
|
+
<Avatar
|
|
177
|
+
key={i}
|
|
178
|
+
size={"small"}
|
|
179
|
+
style={{
|
|
180
|
+
backgroundColor: token.baseGray20,
|
|
181
|
+
color: token.baseGray90,
|
|
182
|
+
border: `1px solid ${token.baseGray40}`,
|
|
183
|
+
display: "flex",
|
|
184
|
+
alignItems: "center",
|
|
185
|
+
justifyContent: "center",
|
|
186
|
+
}}
|
|
187
|
+
>
|
|
188
|
+
<CustomIcon
|
|
189
|
+
name="Organisation02"
|
|
190
|
+
width={18}
|
|
191
|
+
height={18}
|
|
192
|
+
color={token.baseGray90}
|
|
193
|
+
/>
|
|
194
|
+
</Avatar>
|
|
195
|
+
))}
|
|
196
|
+
</Avatar.Group> : '-'
|
|
197
|
+
);
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
title: "",
|
|
202
|
+
dataIndex: "actions",
|
|
203
|
+
key: "actions",
|
|
204
|
+
width: 60,
|
|
205
|
+
show: true,
|
|
206
|
+
render: (value, all) => {
|
|
207
|
+
if (all.empty) {
|
|
208
|
+
return <div className="daf-default-cell" />;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<div
|
|
213
|
+
className="cursor-pointer"
|
|
214
|
+
onClick={() => {
|
|
215
|
+
goTo(getRedirectLink(`/app/view/management-location/${all.id}`)); }}
|
|
216
|
+
>
|
|
217
|
+
<CustomIcon name="Link" width={18} height={18} />
|
|
218
|
+
</div>
|
|
219
|
+
);
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
];
|
|
223
|
+
|
|
224
|
+
return cols.filter((c) => c[show]);
|
|
225
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export const getTabs = ({ t }) => {
|
|
2
|
+
return [
|
|
3
|
+
{
|
|
4
|
+
key: "active",
|
|
5
|
+
label: t("Active"),
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
key: "pending",
|
|
9
|
+
label: t("Pending"),
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
key: 'suspended',
|
|
13
|
+
label: t("Suspended"),
|
|
14
|
+
}
|
|
15
|
+
];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const selectFiltersConfig = {
|
|
19
|
+
category: {
|
|
20
|
+
type: "select",
|
|
21
|
+
label: "Category",
|
|
22
|
+
placeholder: (t) => t("Category"),
|
|
23
|
+
style: { flex: 1 },
|
|
24
|
+
labelStyle: { flex: 1 },
|
|
25
|
+
getLabel: (option) => option.label,
|
|
26
|
+
getValue: (option) => option.value,
|
|
27
|
+
},
|
|
28
|
+
country: {
|
|
29
|
+
type: "select",
|
|
30
|
+
label: "Country",
|
|
31
|
+
placeholder: (t) => t("Country"),
|
|
32
|
+
style: { flex: 1 },
|
|
33
|
+
labelStyle: { flex: 1 },
|
|
34
|
+
getLabel: (option) => option.label,
|
|
35
|
+
getValue: (option) => option.value,
|
|
36
|
+
},
|
|
37
|
+
sources: {
|
|
38
|
+
type: "select",
|
|
39
|
+
label: "Sources",
|
|
40
|
+
placeholder: (t) => t("Sources"),
|
|
41
|
+
style: { flex: 1 },
|
|
42
|
+
labelStyle: { flex: 1 },
|
|
43
|
+
getLabel: (option) => option.label,
|
|
44
|
+
getValue: (option) => option.value,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const filtersConfig = {
|
|
49
|
+
name: "",
|
|
50
|
+
datastakeId: "",
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const defaultUrlParams = { activeTab: "active" };
|
|
54
|
+
|
|
55
|
+
export const checkboxConfig = {
|
|
56
|
+
name: "Name",
|
|
57
|
+
datastakeId: "ID",
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const getNameByLevel = (data, level) => {
|
|
61
|
+
const entry = Object.values(data || {}).find(item => item.level === level);
|
|
62
|
+
return entry;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|