datastake-daf 0.6.794 → 0.6.796
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/build/favicon.ico +0 -0
- package/build/logo192.png +0 -0
- package/build/logo512.png +0 -0
- package/build/manifest.json +25 -0
- package/build/robots.txt +3 -0
- package/dist/components/index.js +3354 -4327
- package/dist/pages/index.js +2853 -3439
- package/dist/services/index.js +3 -69
- package/dist/style/datastake/mapbox-gl.css +330 -0
- package/dist/utils/index.js +20 -14
- package/package.json +1 -1
- package/public/Vegetation/black-default.svg +23 -0
- package/public/Vegetation/black.svg +12 -0
- package/public/Vegetation/damage-from-insects-default.svg +14 -0
- package/public/Vegetation/damage-from-insects.svg +8 -0
- package/public/Vegetation/dry-or-dead-default.svg +16 -0
- package/public/Vegetation/dry-or-dead.svg +7 -0
- package/public/Vegetation/healthy-default.svg +14 -0
- package/public/Vegetation/healthy.svg +34 -0
- package/public/Vegetation/mosaic-default.svg +17 -0
- package/public/Vegetation/mosaic.svg +9 -0
- package/public/Vegetation/no-leaves-default.svg +6 -0
- package/public/Vegetation/no-leaves.svg +5 -0
- package/public/Vegetation/reddish-default.svg +23 -0
- package/public/Vegetation/reddish.svg +79 -0
- package/public/Vegetation/spider-webs-default.svg +10 -0
- package/public/Vegetation/spider-webs.svg +10 -0
- package/public/Vegetation/white-default.svg +25 -0
- package/public/Vegetation/white.svg +12 -0
- package/public/Vegetation/yellowing-default.svg +7 -0
- package/public/Vegetation/yellowing.svg +8 -0
- package/src/@daf/core/components/Dashboard/Map/hook.js +25 -1
- package/src/@daf/core/components/Dashboard/Widget/ActivityIndicators/index.jsx +24 -6
- package/src/@daf/core/components/Dashboard/Widget/ActivityIndicators/style.js +2 -6
- package/src/@daf/core/components/Dashboard/Widget/VegetationWidget/VegetationWidget.stories.jsx +76 -0
- package/src/@daf/core/components/Dashboard/Widget/VegetationWidget/config.js +31 -0
- package/src/@daf/core/components/Dashboard/Widget/VegetationWidget/index.jsx +137 -0
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/hook.js +1 -0
- 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 +1 -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 +8 -18
- 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 +7 -6
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Subjects.jsx +2 -2
- package/src/@daf/core/components/Screens/Admin/AdminScreens/index.js +0 -1
- package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/index.jsx +0 -1
- package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/index.jsx +45 -73
- package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/columns.js +37 -37
- package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/index.jsx +22 -48
- package/src/@daf/core/components/Screens/Admin/AdminTables/UserTable/index.jsx +0 -1
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Edit/index.jsx +1 -3
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/SidebarMenu/index.jsx +3 -5
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/helper.js +8 -13
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/index.jsx +2 -2
- package/src/@daf/core/components/Screens/Admin/AdminViews/index.jsx +4 -3
- package/src/@daf/core/components/Screens/Admin/adminRoutes.js +2 -81
- package/src/@daf/core/components/ViewForm/components/Records/config.js +3 -0
- package/src/@daf/pages/Dashboards/SelfAssesment/components/AssociatedInformation/index.jsx +1 -1
- package/src/@daf/pages/Dashboards/SelfAssesment/components/OrganisationInformation/columns.js +0 -1
- package/src/@daf/pages/Dashboards/SelfAssesment/components/ProductionSites/columns.js +3 -2
- package/src/@daf/pages/Dashboards/SelfAssesment/components/ProductionSites/index.jsx +13 -4
- package/src/@daf/pages/Dashboards/SelfAssesment/index.jsx +22 -20
- package/src/@daf/pages/Events/Activities/columns.js +1 -1
- package/src/@daf/pages/Events/Activities/config.js +23 -30
- package/src/@daf/pages/Events/Incidents/columns.js +1 -1
- package/src/@daf/pages/Events/Incidents/config.js +23 -30
- package/src/@daf/pages/Events/config.js +7 -7
- package/src/@daf/pages/Locations/MineSite/columns.js +3 -3
- package/src/@daf/pages/Locations/MineSite/config.js +20 -14
- package/src/@daf/pages/Locations/config.js +3 -3
- package/src/@daf/pages/Stakeholders/Operators/columns.js +2 -2
- package/src/@daf/pages/Stakeholders/Operators/config.js +9 -16
- package/src/@daf/pages/Stakeholders/Workers/columns.js +1 -1
- package/src/@daf/pages/Stakeholders/Workers/config.js +23 -29
- package/src/@daf/pages/Stakeholders/config.js +3 -3
- package/src/@daf/pages/Summary/Activities/Monitoring/components/ActivityImagery/index.jsx +12 -10
- package/src/@daf/pages/Summary/Activities/Monitoring/components/BiodiversityAndHabitat/helper.js +86 -0
- package/src/@daf/pages/Summary/Activities/Monitoring/components/BiodiversityAndHabitat/index.jsx +65 -0
- package/src/@daf/pages/Summary/Activities/Monitoring/components/EnvironmentalMetrics/index.jsx +30 -0
- package/src/@daf/pages/Summary/Activities/Monitoring/components/MangroveGrowthAndSurvival/components/PlantedSpecies/index.jsx +15 -28
- package/src/@daf/pages/Summary/Activities/Monitoring/components/MangroveGrowthAndSurvival/components/SeedlingsHeight/index.jsx +17 -30
- package/src/@daf/pages/Summary/Activities/Monitoring/components/MangroveGrowthAndSurvival/components/SurvivalRate/index.jsx +38 -45
- package/src/@daf/pages/Summary/Activities/Monitoring/components/MangroveGrowthAndSurvival/index.jsx +87 -8
- package/src/@daf/pages/Summary/Activities/Monitoring/config.js +21 -4
- package/src/@daf/pages/Summary/Activities/Monitoring/helper.js +7 -1
- package/src/@daf/pages/Summary/Activities/Monitoring/index.jsx +31 -8
- package/src/@daf/pages/Summary/Operator/components/TradeRelationships/helper.js +1 -1
- package/src/@daf/pages/TablePage/helper.js +17 -1
- package/src/@daf/pages/TablePage/hook.js +3 -1
- package/src/@daf/pages/TablePage/index.jsx +8 -6
- package/src/@daf/pages/View/index.jsx +4 -2
- package/src/@daf/services/AdminService.js +7 -79
- package/src/@daf/services/DashboardService.js +1 -2
- package/src/@daf/utils/filters.js +26 -15
- package/src/constants/Vegetation.js +15 -0
- package/src/constants/locales/en/translation.js +1 -7
- package/src/constants/locales/fr/translation.js +2 -1
- package/src/constants/locales/sp/translation.js +2 -1
- package/src/index.js +1 -0
- package/src/pages.js +1 -10
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/columns.js +0 -79
- package/src/@daf/core/components/Screens/Admin/AdminScreens/SubjectsView.jsx +0 -272
- package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/column.js +0 -223
- package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/helper.js +0 -65
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/index.jsx +0 -81
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/index.jsx +0 -76
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/config.js +0 -38
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/helpers.js +0 -13
- 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 -38
- 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 -75
- package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/columns.js +0 -180
- package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/config.js +0 -0
- package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/index.jsx +0 -27
- package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/columns.js +0 -157
- package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/config.js +0 -31
- package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/index.js +0 -77
- package/src/@daf/pages/SelfAssesment/components/ProductionSiteTable/columns.js +0 -117
- package/src/@daf/pages/SelfAssesment/components/ProductionSiteTable/index.jsx +0 -54
- package/src/@daf/pages/SelfAssesment/index.jsx +0 -0
|
@@ -1,272 +0,0 @@
|
|
|
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
|
-
|
|
@@ -1,223 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,65 +0,0 @@
|
|
|
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
|
-
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { Form, Input, Select } from "antd";
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
import { useForms } from "../../../../../context/Forms";
|
|
4
|
-
export default function EditLocation({
|
|
5
|
-
t,
|
|
6
|
-
conf,
|
|
7
|
-
data = {},
|
|
8
|
-
formOptions = {},
|
|
9
|
-
MainForm,
|
|
10
|
-
setData = () => {},
|
|
11
|
-
isChanged,
|
|
12
|
-
setIsChanged,
|
|
13
|
-
goToView,
|
|
14
|
-
}) {
|
|
15
|
-
const { addCheck, removeCheck } = useForms();
|
|
16
|
-
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
if (isChanged) {
|
|
19
|
-
addCheck(() => goToView());
|
|
20
|
-
} else {
|
|
21
|
-
removeCheck();
|
|
22
|
-
}
|
|
23
|
-
}, [isChanged, addCheck, removeCheck, goToView]);
|
|
24
|
-
|
|
25
|
-
const renderItem = (item) => {
|
|
26
|
-
const getValue = () => {
|
|
27
|
-
switch (item.type) {
|
|
28
|
-
case "select":
|
|
29
|
-
return (
|
|
30
|
-
<Select
|
|
31
|
-
options={(formOptions[item.optionsName] || []).map((o) => ({
|
|
32
|
-
value: o.value,
|
|
33
|
-
label: t(o.label),
|
|
34
|
-
}))}
|
|
35
|
-
/>
|
|
36
|
-
);
|
|
37
|
-
case "administrative":
|
|
38
|
-
|
|
39
|
-
return <Input disabled />;
|
|
40
|
-
default:
|
|
41
|
-
return <Input />;
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<div className="group" key={item.key}>
|
|
47
|
-
<Form.Item label={t(item.label)} name={item.key}>
|
|
48
|
-
{getValue()}
|
|
49
|
-
</Form.Item>
|
|
50
|
-
</div>
|
|
51
|
-
);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
// Safety check for conf and conf.items
|
|
55
|
-
if (!conf || !conf.items || !Array.isArray(conf.items)) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<div className="form-edit flex-row">
|
|
61
|
-
<Form
|
|
62
|
-
onValuesChange={(changedData) => {
|
|
63
|
-
setIsChanged(true);
|
|
64
|
-
setData((prev) => ({ ...prev, ...changedData }));
|
|
65
|
-
}}
|
|
66
|
-
style={{ width: 700 }}
|
|
67
|
-
layout="vertical"
|
|
68
|
-
form={MainForm}
|
|
69
|
-
>
|
|
70
|
-
<div className="group">
|
|
71
|
-
<div className="daf-title with-subtitle">
|
|
72
|
-
<h1>{t(conf.title)}</h1>
|
|
73
|
-
</div>
|
|
74
|
-
</div>
|
|
75
|
-
|
|
76
|
-
{conf.items.map((item) => renderItem(item))}
|
|
77
|
-
</Form>
|
|
78
|
-
</div>
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { Form, Input, Select } from "antd";
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
import { useForms } from "../../../../../context/Forms";
|
|
4
|
-
|
|
5
|
-
export default function EditStakeholder({
|
|
6
|
-
t,
|
|
7
|
-
conf,
|
|
8
|
-
data = {},
|
|
9
|
-
formOptions = {},
|
|
10
|
-
MainForm,
|
|
11
|
-
setData = () => {},
|
|
12
|
-
isChanged,
|
|
13
|
-
setIsChanged,
|
|
14
|
-
goToView,
|
|
15
|
-
}) {
|
|
16
|
-
const { addCheck, removeCheck } = useForms();
|
|
17
|
-
console.log(conf,"data");
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
if (isChanged) {
|
|
20
|
-
addCheck(() => goToView());
|
|
21
|
-
} else {
|
|
22
|
-
removeCheck();
|
|
23
|
-
}
|
|
24
|
-
}, [isChanged, addCheck, removeCheck, goToView]);
|
|
25
|
-
|
|
26
|
-
const renderItem = (item) => {
|
|
27
|
-
const getValue = () => {
|
|
28
|
-
switch (item.type) {
|
|
29
|
-
case "select":
|
|
30
|
-
return (
|
|
31
|
-
<Select
|
|
32
|
-
options={(formOptions[item.optionsName] || []).map((o) => ({
|
|
33
|
-
value: o.value,
|
|
34
|
-
label: t(o.label),
|
|
35
|
-
}))}
|
|
36
|
-
/>
|
|
37
|
-
);
|
|
38
|
-
default:
|
|
39
|
-
return <Input />;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<div className="group" key={item.key}>
|
|
45
|
-
<Form.Item label={t(item.label)} name={item.key}>
|
|
46
|
-
{getValue()}
|
|
47
|
-
</Form.Item>
|
|
48
|
-
</div>
|
|
49
|
-
);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<div className="form-edit flex-row">
|
|
56
|
-
<Form
|
|
57
|
-
onValuesChange={(changedData) => {
|
|
58
|
-
setIsChanged(true);
|
|
59
|
-
setData((prev) => ({ ...prev, ...changedData }));
|
|
60
|
-
}}
|
|
61
|
-
style={{ width: 700 }}
|
|
62
|
-
layout="vertical"
|
|
63
|
-
form={MainForm}
|
|
64
|
-
>
|
|
65
|
-
<div className="group">
|
|
66
|
-
<div className="daf-title with-subtitle">
|
|
67
|
-
<h1>{t(conf.title)}</h1>
|
|
68
|
-
</div>
|
|
69
|
-
</div>
|
|
70
|
-
|
|
71
|
-
{conf.items.map((item) => renderItem(item))}
|
|
72
|
-
</Form>
|
|
73
|
-
</div>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|