datastake-daf 0.6.792 → 0.6.794
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 +4377 -3187
- package/dist/pages/index.js +1401 -589
- package/dist/services/index.js +69 -3
- package/dist/utils/index.js +14 -17
- package/package.json +1 -1
- package/src/@daf/core/components/ProgressBar/ProgressBarWithIcon/index.jsx +23 -0
- 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/AdminScreens/Dashboard.jsx +2 -2
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Location.jsx +6 -7
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Subjects.jsx +2 -2
- package/src/@daf/core/components/Screens/Admin/AdminScreens/SubjectsView.jsx +272 -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 +223 -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 +73 -45
- package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/columns.js +37 -37
- package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/index.jsx +48 -22
- package/src/@daf/core/components/Screens/Admin/AdminTables/UserTable/index.jsx +1 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/index.jsx +81 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/index.jsx +76 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/config.js +38 -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 +38 -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 +3 -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 +2 -2
- package/src/@daf/core/components/Screens/Admin/AdminViews/index.jsx +3 -4
- package/src/@daf/core/components/Screens/Admin/adminRoutes.js +81 -2
- package/src/@daf/core/components/Table/NavigationAction/index.jsx +5 -3
- package/src/@daf/pages/Dashboards/SelfAssesment/components/AssociatedInformation/columns.js +248 -0
- package/src/@daf/pages/Dashboards/SelfAssesment/components/AssociatedInformation/index.jsx +68 -0
- package/src/@daf/pages/Dashboards/SelfAssesment/components/AssociatedInformation/style.js +29 -0
- package/src/@daf/pages/Dashboards/SelfAssesment/components/OrganisationInformation/columns.js +93 -0
- package/src/@daf/pages/Dashboards/SelfAssesment/components/OrganisationInformation/index.jsx +43 -0
- package/src/@daf/pages/Dashboards/SelfAssesment/components/ProductionSites/columns.js +127 -0
- package/src/@daf/pages/Dashboards/SelfAssesment/components/ProductionSites/index.jsx +52 -0
- package/src/@daf/pages/Dashboards/SelfAssesment/components/ProductionSites/style.js +26 -0
- package/src/@daf/pages/Dashboards/SelfAssesment/index.jsx +39 -0
- 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/services/AdminService.js +79 -7
- 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
- package/src/pages.js +1 -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
|
@@ -0,0 +1,272 @@
|
|
|
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 } from "antd";
|
|
13
|
+
import { NOTIFICATION_MODE, useForms, FormsProvider } from "../../../../context/Forms/index.js";
|
|
14
|
+
|
|
15
|
+
function withFormsProvider(Component) {
|
|
16
|
+
return function WrappedWithFormsProvider(props) {
|
|
17
|
+
return (
|
|
18
|
+
<FormsProvider>
|
|
19
|
+
<Component {...props} />
|
|
20
|
+
</FormsProvider>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Admin Subjects View Screen
|
|
27
|
+
* This component handles viewing and editing individual subjects (locations or stakeholders)
|
|
28
|
+
*
|
|
29
|
+
* @param {Object} config - Application configuration
|
|
30
|
+
* @param {string} config.subject - Subject type: "location" or "stakeholder"
|
|
31
|
+
* @param {string} config.id - Subject ID from route params
|
|
32
|
+
* @param {string} config.mode - Mode: "view" or "edit"
|
|
33
|
+
* @param {string} config.module - Module identifier
|
|
34
|
+
* @param {Function} config.goTo - Navigation function
|
|
35
|
+
* @param {Function} config.t - Translation function
|
|
36
|
+
* @param {Object} config.location - Router location object
|
|
37
|
+
* @param {Function} config.getRedirectLink - Function to get redirect links
|
|
38
|
+
* @param {Function} config.renderBreadCrumbs - Function to render breadcrumbs
|
|
39
|
+
* @param {Object} config.options - Options object with countries, categories, etc.
|
|
40
|
+
* @param {Function} config.AdminService - Admin service for API calls
|
|
41
|
+
* @param {Function} config.handleError - Error handling function
|
|
42
|
+
*/
|
|
43
|
+
function AdminSubjectsViewScreen({ config }) {
|
|
44
|
+
const {
|
|
45
|
+
subject,
|
|
46
|
+
id,
|
|
47
|
+
mode = "view",
|
|
48
|
+
module,
|
|
49
|
+
goTo,
|
|
50
|
+
t,
|
|
51
|
+
location,
|
|
52
|
+
getRedirectLink,
|
|
53
|
+
renderBreadCrumbs,
|
|
54
|
+
options,
|
|
55
|
+
AdminService,
|
|
56
|
+
handleError,
|
|
57
|
+
userRoles = [],
|
|
58
|
+
accountStatuses = [],
|
|
59
|
+
} = config;
|
|
60
|
+
|
|
61
|
+
const [loading, setLoading] = useState(false);
|
|
62
|
+
const [data, setData] = useState({});
|
|
63
|
+
const [editData, setEditData] = useState({});
|
|
64
|
+
const [isChanged, setIsChanged] = useState(false);
|
|
65
|
+
const [selectedGroup, setSelectedGroup] = useState("");
|
|
66
|
+
const [MainForm] = Form.useForm();
|
|
67
|
+
const { setNotificationMode, changeNotificationState } = useForms();
|
|
68
|
+
|
|
69
|
+
const configs = useMemo(() => {
|
|
70
|
+
return subject === "location" ? locationConfig : stakeholderConfig;
|
|
71
|
+
}, [subject]);
|
|
72
|
+
|
|
73
|
+
const conf = useMemo(() => {
|
|
74
|
+
if (!Array.isArray(configs) || configs.length === 0) {
|
|
75
|
+
console.warn("configs is not a valid array:", configs);
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!selectedGroup) {
|
|
80
|
+
setSelectedGroup(configs[0].key);
|
|
81
|
+
return configs[0];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const foundConfig = configs.find((c) => c.key === selectedGroup);
|
|
85
|
+
return foundConfig || configs[0];
|
|
86
|
+
}, [selectedGroup, configs]);
|
|
87
|
+
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
MainForm.setFieldsValue(data);
|
|
90
|
+
setEditData(data);
|
|
91
|
+
}, [data, MainForm]);
|
|
92
|
+
|
|
93
|
+
const goToView = useCallback(() => {
|
|
94
|
+
changeNotificationState({
|
|
95
|
+
onYes: () => {
|
|
96
|
+
setEditData(data);
|
|
97
|
+
setIsChanged(false);
|
|
98
|
+
goTo(`/app/management/subject/${subject}/${id}`);
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
}, [goTo, changeNotificationState, data, subject, id]);
|
|
102
|
+
|
|
103
|
+
const fetchData = useCallback(async () => {
|
|
104
|
+
try {
|
|
105
|
+
setLoading(true);
|
|
106
|
+
|
|
107
|
+
let response;
|
|
108
|
+
if (subject === "location") {
|
|
109
|
+
response = await AdminService.viewLocation({ id });
|
|
110
|
+
} else if (subject === "stakeholder") {
|
|
111
|
+
response = await AdminService.viewStakeholder({ id });
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (response?.data) {
|
|
115
|
+
console.log('📦 Backend response data:', {
|
|
116
|
+
id: response.data.id,
|
|
117
|
+
datastakeId: response.data.datastakeId,
|
|
118
|
+
name: response.data.name,
|
|
119
|
+
fullData: response.data
|
|
120
|
+
});
|
|
121
|
+
setData(response.data);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
setLoading(false);
|
|
125
|
+
} catch (err) {
|
|
126
|
+
if (handleError) {
|
|
127
|
+
handleError(err);
|
|
128
|
+
}
|
|
129
|
+
setLoading(false);
|
|
130
|
+
}
|
|
131
|
+
}, [id, subject, AdminService, handleError]);
|
|
132
|
+
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
fetchData();
|
|
135
|
+
}, [fetchData]);
|
|
136
|
+
|
|
137
|
+
const breadCrumbs = useMemo(() => {
|
|
138
|
+
if (renderBreadCrumbs) {
|
|
139
|
+
return renderBreadCrumbs({
|
|
140
|
+
view: subject === "location" ? "location" : "stakeholder",
|
|
141
|
+
t,
|
|
142
|
+
goTo,
|
|
143
|
+
id,
|
|
144
|
+
isView: mode === "view",
|
|
145
|
+
isEdit: mode === "edit",
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return [];
|
|
149
|
+
}, [renderBreadCrumbs, subject, t, goTo, id, mode]);
|
|
150
|
+
|
|
151
|
+
const formOptions = useMemo(() => {
|
|
152
|
+
return {
|
|
153
|
+
countries: options?.countries || [],
|
|
154
|
+
category: options?.category || [],
|
|
155
|
+
};
|
|
156
|
+
}, [options]);
|
|
157
|
+
|
|
158
|
+
const actionButtons = useMemo(() => {
|
|
159
|
+
if (mode === "view") {
|
|
160
|
+
return [
|
|
161
|
+
{
|
|
162
|
+
type: "primary",
|
|
163
|
+
tooltip: t("Edit"),
|
|
164
|
+
icon: "Edit",
|
|
165
|
+
onClick: () => goTo(`/app/management/subject/${subject}/edit/${id}`),
|
|
166
|
+
},
|
|
167
|
+
];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return [
|
|
171
|
+
{
|
|
172
|
+
type: "primary",
|
|
173
|
+
tooltip: t("Save"),
|
|
174
|
+
icon: "Save",
|
|
175
|
+
disabled: !isChanged,
|
|
176
|
+
onClick: () => {
|
|
177
|
+
MainForm.validateFields()
|
|
178
|
+
.then(async (formData) => {
|
|
179
|
+
setLoading(true);
|
|
180
|
+
|
|
181
|
+
try {
|
|
182
|
+
const allowedKeys = conf?.items?.map(item => item.key) || [];
|
|
183
|
+
const filteredData = {};
|
|
184
|
+
allowedKeys.forEach(key => {
|
|
185
|
+
if (formData[key] !== undefined) {
|
|
186
|
+
filteredData[key] = formData[key];
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
const internalId = data.id;
|
|
191
|
+
if (!internalId) {
|
|
192
|
+
throw new Error('Internal ID not found');
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
await AdminService.updateSubject({
|
|
196
|
+
subject,
|
|
197
|
+
id: internalId,
|
|
198
|
+
data: filteredData
|
|
199
|
+
});
|
|
200
|
+
await fetchData();
|
|
201
|
+
message.success(t("Information saved successfully"));
|
|
202
|
+
setNotificationMode(NOTIFICATION_MODE.EMPTY);
|
|
203
|
+
setIsChanged(false);
|
|
204
|
+
goTo(`/app/management/subject/${subject}/${id}`);
|
|
205
|
+
} catch (err) {
|
|
206
|
+
handleError(err);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
setLoading(false);
|
|
210
|
+
})
|
|
211
|
+
.catch(() => {});
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
tooltip: t("Cancel"),
|
|
216
|
+
icon: "Close",
|
|
217
|
+
onClick: goToView,
|
|
218
|
+
},
|
|
219
|
+
];
|
|
220
|
+
}, [t, mode, MainForm, goToView, isChanged, editData, fetchData, subject, id, goTo, handleError, AdminService, setNotificationMode]);
|
|
221
|
+
|
|
222
|
+
const ViewComponent = subject === "location" ? ViewLocation : ViewStakeholder;
|
|
223
|
+
const EditComponent = subject === "location" ? EditLocation : EditStakeholder;
|
|
224
|
+
|
|
225
|
+
return (
|
|
226
|
+
<div className={mode === "view" ? "daf-view-form" : "daf-edit-form"}>
|
|
227
|
+
{loading && <Loading background="white" />}
|
|
228
|
+
<Header
|
|
229
|
+
title={data.name || t("Loading...")}
|
|
230
|
+
breadcrumbs={breadCrumbs}
|
|
231
|
+
actionButtons={actionButtons}
|
|
232
|
+
/>
|
|
233
|
+
<div className="view-content">
|
|
234
|
+
<SideBarMenu
|
|
235
|
+
selectedGroup={selectedGroup}
|
|
236
|
+
onChange={(v) => setSelectedGroup(v)}
|
|
237
|
+
t={t}
|
|
238
|
+
config={configs}
|
|
239
|
+
/>
|
|
240
|
+
{mode === "edit" ? (
|
|
241
|
+
<EditComponent
|
|
242
|
+
t={t}
|
|
243
|
+
conf={conf}
|
|
244
|
+
data={editData}
|
|
245
|
+
formOptions={formOptions}
|
|
246
|
+
MainForm={MainForm}
|
|
247
|
+
setData={setEditData}
|
|
248
|
+
isChanged={isChanged}
|
|
249
|
+
setIsChanged={setIsChanged}
|
|
250
|
+
goToView={goToView}
|
|
251
|
+
/>
|
|
252
|
+
) : (
|
|
253
|
+
<ViewComponent
|
|
254
|
+
userRoles={userRoles}
|
|
255
|
+
formOptions={formOptions}
|
|
256
|
+
conf={conf}
|
|
257
|
+
data={data}
|
|
258
|
+
t={t}
|
|
259
|
+
goTo={goTo}
|
|
260
|
+
location={location}
|
|
261
|
+
getRedirectLink={getRedirectLink}
|
|
262
|
+
accountStatuses={accountStatuses}
|
|
263
|
+
module={module}
|
|
264
|
+
/>
|
|
265
|
+
)}
|
|
266
|
+
</div>
|
|
267
|
+
</div>
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export default withFormsProvider(AdminSubjectsViewScreen);
|
|
272
|
+
|
|
@@ -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,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/management/subject/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
|
+
|