datastake-daf 0.6.798 → 0.6.799

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.
Files changed (76) hide show
  1. package/dist/components/index.js +3158 -985
  2. package/dist/context/index.js +6 -6
  3. package/dist/pages/index.js +252 -13
  4. package/dist/services/index.js +112 -9
  5. package/dist/utils/index.js +14 -17
  6. package/package.json +1 -1
  7. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/hook.js +0 -1
  8. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/index.jsx +1 -1
  9. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/hook.js +1 -1
  10. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/index.jsx +1 -1
  11. package/src/@daf/core/components/Screens/Admin/AdminModals/AddUser/index.jsx +0 -1
  12. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/columns.js +79 -0
  13. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/helper.js +2 -2
  14. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/index.jsx +18 -8
  15. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineSubjects/index.jsx +6 -6
  16. package/src/@daf/core/components/Screens/Admin/AdminModals/NewAccount/index.jsx +1 -1
  17. package/src/@daf/core/components/Screens/Admin/AdminModals/NewUser/index.jsx +61 -38
  18. package/src/@daf/core/components/Screens/Admin/AdminScreens/Accounts.jsx +1 -4
  19. package/src/@daf/core/components/Screens/Admin/AdminScreens/AccountsView.jsx +2 -0
  20. package/src/@daf/core/components/Screens/Admin/AdminScreens/Dashboard.jsx +2 -2
  21. package/src/@daf/core/components/Screens/Admin/AdminScreens/Location.jsx +6 -7
  22. package/src/@daf/core/components/Screens/Admin/AdminScreens/Subjects.jsx +2 -3
  23. package/src/@daf/core/components/Screens/Admin/AdminScreens/SubjectsView.jsx +395 -0
  24. package/src/@daf/core/components/Screens/Admin/AdminScreens/index.js +1 -0
  25. package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/index.jsx +1 -0
  26. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/column.js +223 -0
  27. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/helper.js +65 -0
  28. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/index.jsx +73 -45
  29. package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/columns.js +37 -37
  30. package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/index.jsx +48 -22
  31. package/src/@daf/core/components/Screens/Admin/AdminTables/UserTable/index.jsx +1 -0
  32. package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/configTransformer.js +137 -0
  33. package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/index.js +9 -0
  34. package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/index.jsx +196 -0
  35. package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/configTransformer.js +216 -0
  36. package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/index.js +7 -0
  37. package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/index.jsx +184 -0
  38. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/config.js +64 -0
  39. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/helpers.js +13 -0
  40. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/index.jsx +77 -0
  41. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/config.js +51 -0
  42. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/helpers.js +0 -0
  43. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/index.jsx +75 -0
  44. package/src/@daf/core/components/Screens/Admin/AdminViews/components/Edit/index.jsx +7 -1
  45. package/src/@daf/core/components/Screens/Admin/AdminViews/components/SidebarMenu/index.jsx +5 -3
  46. package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/helper.js +13 -8
  47. package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/index.jsx +16 -10
  48. package/src/@daf/core/components/Screens/Admin/AdminViews/components/View/index.jsx +2 -1
  49. package/src/@daf/core/components/Screens/Admin/AdminViews/index.jsx +66 -26
  50. package/src/@daf/core/components/Screens/Admin/AppInvitation/index.jsx +193 -0
  51. package/src/@daf/core/components/Screens/Admin/adminRoutes.js +81 -2
  52. package/src/@daf/layouts/AppLayout/index.jsx +0 -1
  53. package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/columns.js +180 -0
  54. package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/config.js +0 -0
  55. package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/index.jsx +27 -0
  56. package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/columns.js +157 -0
  57. package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/config.js +31 -0
  58. package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/index.js +77 -0
  59. package/src/@daf/pages/SelfAssesment/components/ProductionSiteTable/columns.js +117 -0
  60. package/src/@daf/pages/SelfAssesment/components/ProductionSiteTable/index.jsx +54 -0
  61. package/src/@daf/pages/SelfAssesment/index.jsx +0 -0
  62. package/src/@daf/pages/View/hooks/usePrepareForm.js +11 -1
  63. package/src/@daf/pages/View/index.jsx +13 -2
  64. package/src/@daf/services/AdminService.js +111 -7
  65. package/src/@daf/services/AuthenticationService.js +1 -0
  66. package/src/@daf/services/DashboardService.js +2 -1
  67. package/src/@daf/utils/filters.js +15 -13
  68. package/src/constants/locales/en/translation.js +7 -0
  69. package/src/constants/locales/fr/translation.js +1 -1
  70. package/src/constants/locales/sp/translation.js +1 -1
  71. package/src/index.js +1 -0
  72. package/build/favicon.ico +0 -0
  73. package/build/logo192.png +0 -0
  74. package/build/logo512.png +0 -0
  75. package/build/manifest.json +0 -25
  76. package/build/robots.txt +0 -3
@@ -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";
@@ -60,6 +60,7 @@ export default function AccountTable({
60
60
  filtersConfig,
61
61
  getRedirectLink,
62
62
  getData,
63
+ fetchPendingOnMount: true,
63
64
  });
64
65
 
65
66
  const selectOptions = useMemo(() => {
@@ -0,0 +1,223 @@
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
+ }) => {
17
+ const cols = [
18
+ {
19
+ title: "",
20
+ dataIndex: "select",
21
+ key: "select",
22
+ width: 50,
23
+ show: true,
24
+ render: (v, all) => {
25
+ if (all.empty) {
26
+ return <div className="daf-default-cell" />;
27
+ }
28
+ return (
29
+ <Checkbox
30
+ onChange={() =>
31
+ setSelectedLocations((prev) => {
32
+ const isSelected = prev.some((p) => p.id === all.id);
33
+ if (isSelected) {
34
+ return prev.filter((p) => p.id !== all.id);
35
+ }
36
+ return [...prev, all];
37
+ })
38
+ }
39
+ checked={selectedLocations.some((p) => p.id === all.id)}
40
+ disabled={
41
+ selectedLocations?.length >= 3 &&
42
+ !selectedLocations.some((p) => p.id === all.id)
43
+ }
44
+ />
45
+ );
46
+ },
47
+ },
48
+ {
49
+ title: t("ID"),
50
+ dataIndex: "datastakeId",
51
+ key: "datastakeId",
52
+ ellipsis: true,
53
+ show: true,
54
+ render: (value, all) => {
55
+ if (all.empty) {
56
+ return <div className="daf-default-cell" />;
57
+ }
58
+
59
+ return <Tooltip title={value}>{value}</Tooltip>;
60
+ },
61
+ },
62
+ {
63
+ title: t("Name"),
64
+ dataIndex: "name",
65
+ key: "name",
66
+ ellipsis: true,
67
+ show: true,
68
+ render: (value, all) => {
69
+ if (all.empty) {
70
+ return <div className="daf-default-cell" />;
71
+ }
72
+
73
+ return <Tooltip title={value}>{value}</Tooltip>;
74
+ },
75
+ },
76
+ {
77
+ title: t("Category"),
78
+ dataIndex: "category",
79
+ key: "category",
80
+ ellipsis: true,
81
+ show: true,
82
+ render: (value, all) => {
83
+ if (all.empty) {
84
+ return <div className="daf-default-cell" />;
85
+ }
86
+
87
+ const category = findOptions(value, selectOptions?.category || []) || "--";
88
+
89
+ return <Tooltip title={category}>{category}</Tooltip>;
90
+ },
91
+ },
92
+ {
93
+ title: t("Country"),
94
+ dataIndex: "country",
95
+ key: "country",
96
+ ellipsis: true,
97
+ show: true,
98
+ render: (value, all) => {
99
+ if (all.empty) {
100
+ return <div className="daf-default-cell" />;
101
+ }
102
+ const country = findOptions(value, selectOptions?.country || []) || "--";
103
+
104
+ return <Tooltip title={country}>{country}</Tooltip>;
105
+ },
106
+ },
107
+ {
108
+ title: t("Admin Level 1"),
109
+ dataIndex: "administrativeLevel1",
110
+ key: "administrativeLevel1",
111
+ ellipsis: true,
112
+ show: entity.includes("location"),
113
+ render: (value, all) => {
114
+ if (all.empty) {
115
+ return <div className="daf-default-cell" />;
116
+ }
117
+
118
+ let label;
119
+ if(all?.administrativeLevel1 && value === all?.administrativeLevel1) {
120
+ label = all?.linking?.SCL?.[value]?.name
121
+ } else {
122
+ label = getNameByLevel(all?.linking?.SCL, "level_1")?.name
123
+ }
124
+
125
+ return <Tooltip title={label || '-'}>{label || '-'}</Tooltip>;
126
+ },
127
+ },
128
+ {
129
+ title: t("Admin Level 2"),
130
+ dataIndex: "administrativeLevel2",
131
+ key: "administrativeLevel2",
132
+ show: entity.includes("location"),
133
+ ellipsis: true,
134
+ render: (value, all) => {
135
+ if (all.empty) {
136
+ return <div className="daf-default-cell" />;
137
+ }
138
+
139
+ let label;
140
+ if(all?.administrativeLevel2 && value === all?.administrativeLevel2) {
141
+ label = all?.linking?.SCL?.[value]?.name
142
+ } else {
143
+ label = getNameByLevel(all?.linking?.SCL, "level_2")?.name
144
+ }
145
+
146
+ return <Tooltip title={label || '-'}>{label || '-'}</Tooltip>;
147
+ },
148
+ },
149
+ {
150
+ title: t("Sources"),
151
+ dataIndex: "sources",
152
+ key: "sources",
153
+ show: true,
154
+ render: (value, all) => {
155
+ if (all.empty) {
156
+ return <div className="daf-default-cell" />;
157
+ }
158
+
159
+ const MAX_SOURCES = 3;
160
+ const count = value?.length === MAX_SOURCES + 1 ? value?.length : MAX_SOURCES;
161
+ return (
162
+ Array.isArray(value) && value?.length > 0 ? <Avatar.Group
163
+ max={{
164
+ count: count,
165
+ style: {
166
+ color: token.baseGray90,
167
+ backgroundColor: token.baseGray20,
168
+ border: `1px solid ${token.baseGray40}`,
169
+ },
170
+ }}
171
+ size={"small"}
172
+ >
173
+ {value.map((v, i) => (
174
+ <Avatar
175
+ key={i}
176
+ size={"small"}
177
+ style={{
178
+ backgroundColor: token.baseGray20,
179
+ color: token.baseGray90,
180
+ border: `1px solid ${token.baseGray40}`,
181
+ display: "flex",
182
+ alignItems: "center",
183
+ justifyContent: "center",
184
+ }}
185
+ >
186
+ <CustomIcon
187
+ name="Organisation02"
188
+ width={18}
189
+ height={18}
190
+ color={token.baseGray90}
191
+ />
192
+ </Avatar>
193
+ ))}
194
+ </Avatar.Group> : '-'
195
+ );
196
+ },
197
+ },
198
+ {
199
+ title: "",
200
+ dataIndex: "actions",
201
+ key: "actions",
202
+ width: 60,
203
+ show: true,
204
+ render: (value, all) => {
205
+ if (all.empty) {
206
+ return <div className="daf-default-cell" />;
207
+ }
208
+
209
+ return (
210
+ <div
211
+ className="cursor-pointer"
212
+ onClick={() => {
213
+ goTo(getRedirectLink(`/app/view/management-location/${all.id}`)); }}
214
+ >
215
+ <CustomIcon name="Link" width={18} height={18} />
216
+ </div>
217
+ );
218
+ },
219
+ },
220
+ ];
221
+
222
+ return cols.filter((c) => c[show]);
223
+ };
@@ -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
+