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.
Files changed (74) hide show
  1. package/dist/components/index.js +4377 -3187
  2. package/dist/pages/index.js +1401 -589
  3. package/dist/services/index.js +69 -3
  4. package/dist/utils/index.js +14 -17
  5. package/package.json +1 -1
  6. package/src/@daf/core/components/ProgressBar/ProgressBarWithIcon/index.jsx +23 -0
  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/AdminScreens/Dashboard.jsx +2 -2
  18. package/src/@daf/core/components/Screens/Admin/AdminScreens/Location.jsx +6 -7
  19. package/src/@daf/core/components/Screens/Admin/AdminScreens/Subjects.jsx +2 -2
  20. package/src/@daf/core/components/Screens/Admin/AdminScreens/SubjectsView.jsx +272 -0
  21. package/src/@daf/core/components/Screens/Admin/AdminScreens/index.js +1 -0
  22. package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/index.jsx +1 -0
  23. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/column.js +223 -0
  24. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/helper.js +65 -0
  25. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/index.jsx +73 -45
  26. package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/columns.js +37 -37
  27. package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/index.jsx +48 -22
  28. package/src/@daf/core/components/Screens/Admin/AdminTables/UserTable/index.jsx +1 -0
  29. package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/index.jsx +81 -0
  30. package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/index.jsx +76 -0
  31. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/config.js +38 -0
  32. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/helpers.js +13 -0
  33. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/index.jsx +77 -0
  34. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/config.js +38 -0
  35. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/helpers.js +0 -0
  36. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/index.jsx +75 -0
  37. package/src/@daf/core/components/Screens/Admin/AdminViews/components/Edit/index.jsx +3 -1
  38. package/src/@daf/core/components/Screens/Admin/AdminViews/components/SidebarMenu/index.jsx +5 -3
  39. package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/helper.js +13 -8
  40. package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/index.jsx +2 -2
  41. package/src/@daf/core/components/Screens/Admin/AdminViews/index.jsx +3 -4
  42. package/src/@daf/core/components/Screens/Admin/adminRoutes.js +81 -2
  43. package/src/@daf/core/components/Table/NavigationAction/index.jsx +5 -3
  44. package/src/@daf/pages/Dashboards/SelfAssesment/components/AssociatedInformation/columns.js +248 -0
  45. package/src/@daf/pages/Dashboards/SelfAssesment/components/AssociatedInformation/index.jsx +68 -0
  46. package/src/@daf/pages/Dashboards/SelfAssesment/components/AssociatedInformation/style.js +29 -0
  47. package/src/@daf/pages/Dashboards/SelfAssesment/components/OrganisationInformation/columns.js +93 -0
  48. package/src/@daf/pages/Dashboards/SelfAssesment/components/OrganisationInformation/index.jsx +43 -0
  49. package/src/@daf/pages/Dashboards/SelfAssesment/components/ProductionSites/columns.js +127 -0
  50. package/src/@daf/pages/Dashboards/SelfAssesment/components/ProductionSites/index.jsx +52 -0
  51. package/src/@daf/pages/Dashboards/SelfAssesment/components/ProductionSites/style.js +26 -0
  52. package/src/@daf/pages/Dashboards/SelfAssesment/index.jsx +39 -0
  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/services/AdminService.js +79 -7
  63. package/src/@daf/services/DashboardService.js +2 -1
  64. package/src/@daf/utils/filters.js +15 -13
  65. package/src/constants/locales/en/translation.js +7 -0
  66. package/src/constants/locales/fr/translation.js +1 -1
  67. package/src/constants/locales/sp/translation.js +1 -1
  68. package/src/index.js +1 -0
  69. package/src/pages.js +1 -0
  70. package/build/favicon.ico +0 -0
  71. package/build/logo192.png +0 -0
  72. package/build/logo512.png +0 -0
  73. package/build/manifest.json +0 -25
  74. package/build/robots.txt +0 -3
@@ -2,7 +2,7 @@ import { useState, useMemo } from "react";
2
2
  import { useAdminTable } from "../hook";
3
3
  import AdminTable from "../components/index.jsx";
4
4
  import DAFTable from "../../../../Table/index.jsx";
5
- import { theme, Tag } from "antd";
5
+ import { theme, Tag, message } from "antd";
6
6
  import CustomIcon from "../../../../Icon/CustomIcon.jsx";
7
7
  import {
8
8
  getTabs,
@@ -10,9 +10,10 @@ import {
10
10
  filtersConfig,
11
11
  defaultUrlParams,
12
12
  checkboxConfig,
13
- } from "../SubjectsTable/helper.js";
14
- import { getColumns } from "../SubjectsTable/columns.js";
13
+ } from "./helper.js";
14
+ import { getColumns } from "./column.js";
15
15
  import CombineLocationModal from "../../AdminModals/CombineLocation/index.jsx";
16
+
16
17
  const { useToken } = theme;
17
18
 
18
19
  export default function LocationTable({
@@ -28,14 +29,49 @@ export default function LocationTable({
28
29
  view,
29
30
  headerTitle,
30
31
  breadcrumbs,
31
- mergeSubjectsFunction,
32
+ mergeLocationsFunction,
32
33
  refetchTrigger,
33
34
  }) {
34
35
  const [showFilters, setShowFilters] = useState(false);
35
36
  const [hasError, setHasError] = useState(false);
36
- const [selectedLocations, setSelectedLocations] = useState([]);
37
- const { token } = useToken();
38
- const [combineLocationVisible, setCombineLocationVisible] = useState(false);
37
+
38
+ const [selectedLocations, setSelectedLocations] = useState([]);
39
+
40
+ const { token } = useToken();
41
+ const [isCombineModalOpen, setIsModalOpen] = useState(false);
42
+
43
+ const getDataWithStringPagination = async ({ params }) => {
44
+ const { pagination, tab, filters, search, sort, ...otherParams } = params;
45
+
46
+ let paginationObj = { page: 1, pageSize: 20 };
47
+ if (pagination) {
48
+ try {
49
+ paginationObj = typeof pagination === 'string' ? JSON.parse(pagination) : pagination;
50
+ } catch (e) {
51
+ console.error('Failed to parse pagination', e);
52
+ }
53
+ }
54
+
55
+ let activeTab = tab || "active";
56
+ if (!tab && filters) {
57
+ try {
58
+ const parsedFilters = typeof filters === 'string' ? JSON.parse(filters) : filters;
59
+ activeTab = parsedFilters.activeTab || "active";
60
+ } catch (e) {
61
+ activeTab = "active";
62
+ }
63
+ }
64
+
65
+ const transformedParams = {
66
+ pagination: {
67
+ skip: String(paginationObj.page || 1),
68
+ take: String(paginationObj.pageSize || 20),
69
+ },
70
+ tab: activeTab,
71
+ };
72
+
73
+ return getData({ params: transformedParams });
74
+ };
39
75
 
40
76
  const {
41
77
  filter,
@@ -58,7 +94,7 @@ export default function LocationTable({
58
94
  defaultPageSize,
59
95
  filtersConfig,
60
96
  getRedirectLink,
61
- getData,
97
+ getData: getDataWithStringPagination,
62
98
  refetchTrigger,
63
99
  });
64
100
 
@@ -66,7 +102,7 @@ export default function LocationTable({
66
102
  return {
67
103
  category: config.options?.category,
68
104
  country: config.options?.countries,
69
- sources: [], //TODO: add sources logic and make sure you only show unique sources only once
105
+ sources: [],
70
106
  };
71
107
  }, [config.options]);
72
108
 
@@ -76,7 +112,7 @@ export default function LocationTable({
76
112
  goTo,
77
113
  token,
78
114
  module,
79
- selectedLocations,
115
+ selectedLocations,
80
116
  setSelectedLocations,
81
117
  getRedirectLink,
82
118
  selectOptions,
@@ -93,8 +129,8 @@ export default function LocationTable({
93
129
  actionButton={[
94
130
  {
95
131
  icon: "Merge",
96
- onClick: () => setCombineLocationVisible(true),
97
- tooltip: "Combine",
132
+ onClick: () => setIsModalOpen(true),
133
+ tooltip: t("admin::merge-locations"),
98
134
  disabled: selectedLocations.length < 2,
99
135
  },
100
136
  ]}
@@ -112,25 +148,15 @@ export default function LocationTable({
112
148
  breadcrumbs={breadcrumbs}
113
149
  >
114
150
  {selectedLocations.length > 0 && (
115
- <div
116
- className="flex flex-row ml-6 mt-5"
117
- style={{
118
- flexWrap: "wrap",
119
- gap: "8px",
120
- }}
121
- >
151
+ <div className="flex flex-row ml-6 mt-5" style={{ flexWrap: "wrap", gap: "8px" }}>
122
152
  {selectedLocations.map((account) => (
123
153
  <Tag
124
154
  key={account.userId}
125
155
  className="flex flex-row gap-2 items-center"
126
156
  onClick={() =>
127
- setSelectedLocations((prev) =>
128
- prev.filter((a) => a.datastakeId !== account.datastakeId),
129
- )
157
+ setSelectedLocations((prev) => prev.filter((a) => a.datastakeId !== account.datastakeId))
130
158
  }
131
- style={{
132
- cursor: "pointer",
133
- }}
159
+ style={{ cursor: "pointer" }}
134
160
  >
135
161
  <span>{account.datastakeId}</span>
136
162
  <CustomIcon name="Close" size={10} />
@@ -156,25 +182,27 @@ export default function LocationTable({
156
182
  />
157
183
  </AdminTable>
158
184
 
159
- <CombineLocationModal
160
- isOpen={combineLocationVisible}
161
- t={t}
162
- onClose={() => {
163
- setCombineLocationVisible(false);
164
- }}
165
- onSuccess={(data) => {
166
- setCombineLocationVisible(false);
167
- setLoading(true);
168
- if (typeof mergeSubjectsFunction === 'function') {
169
- mergeSubjectsFunction(data);
170
- setSelectedLocations([])
171
- }
172
- }}
173
- selectedLocations={selectedLocations}
174
- selectOptions={selectOptions || {}}
175
- module={module}
176
- entity={headerTitle}
177
- />
185
+ <CombineLocationModal
186
+ isOpen={isCombineModalOpen}
187
+ t={t}
188
+ onClose={() => setIsModalOpen(false)}
189
+ onSuccess={(data) => {
190
+ console.log("Modal Success triggered", data); // 1. Check if this logs
191
+ console.log("Is function?", typeof mergeLocationsFunction);
192
+ setIsModalOpen(false);
193
+ setLoading(true);
194
+ if (typeof mergeLocationsFunction === 'function') {
195
+ mergeLocationsFunction(data).finally(() => {
196
+ setSelectedLocations([]);
197
+ fetchData();
198
+ });
199
+ }
200
+ }}
201
+ selectedLocations={selectedLocations}
202
+ selectOptions={selectOptions}
203
+ module={module}
204
+ entity={headerTitle}
205
+ />
178
206
  </>
179
207
  );
180
- }
208
+ }
@@ -104,48 +104,48 @@ export const getColumns = ({
104
104
  return <Tooltip title={country}>{country}</Tooltip>;
105
105
  },
106
106
  },
107
- {
108
- title: t("Province"),
109
- dataIndex: "administrativeLevel1",
110
- key: "administrativeLevel1",
111
- ellipsis: true,
112
- show: entity.includes("locations"),
113
- render: (value, all) => {
114
- if (all.empty) {
115
- return <div className="daf-default-cell" />;
116
- }
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
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
- }
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
124
 
125
- return <Tooltip title={label || '-'}>{label || '-'}</Tooltip>;
126
- },
125
+ return <Tooltip title={label || '-'}>{label || '-'}</Tooltip>;
127
126
  },
128
- {
129
- title: t("Territory"),
130
- dataIndex: "administrativeLevel2",
131
- key: "administrativeLevel2",
132
- show: entity.includes("locations"),
133
- ellipsis: true,
134
- render: (value, all) => {
135
- if (all.empty) {
136
- return <div className="daf-default-cell" />;
137
- }
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
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
- }
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
145
 
146
- return <Tooltip title={label || '-'}>{label || '-'}</Tooltip>;
147
- },
146
+ return <Tooltip title={label || '-'}>{label || '-'}</Tooltip>;
148
147
  },
148
+ },
149
149
  {
150
150
  title: t("Sources"),
151
151
  dataIndex: "sources",
@@ -210,7 +210,7 @@ export const getColumns = ({
210
210
  <div
211
211
  className="cursor-pointer"
212
212
  onClick={() => {
213
- goTo(getRedirectLink(`/app/accounts/view/${all.id}/details`));
213
+ goTo(getRedirectLink(`/app/management/subject/stakeholder/${all.id}`));
214
214
  }}
215
215
  >
216
216
  <CustomIcon name="Link" width={18} height={18} />
@@ -2,7 +2,7 @@ import { useState, useMemo } from "react";
2
2
  import { useAdminTable } from "../hook";
3
3
  import AdminTable from "../components/index.jsx";
4
4
  import DAFTable from "../../../../Table/index.jsx";
5
- import { theme, Tag } from "antd";
5
+ import { theme, Tag, message } from "antd";
6
6
  import CustomIcon from "../../../../Icon/CustomIcon.jsx";
7
7
  import {
8
8
  getTabs,
@@ -38,6 +38,41 @@ export default function SubjectsTable({
38
38
  const { token } = useToken();
39
39
  const [isCombineModalOpen, setIsModalOpen] = useState(false);
40
40
 
41
+
42
+
43
+
44
+ const getDataWithStringPagination = async ({ params }) => {
45
+ const { pagination, tab, filters, search, sort, ...otherParams } = params;
46
+
47
+ let paginationObj = { page: 1, pageSize: 20 };
48
+ if (pagination) {
49
+ try {
50
+ paginationObj = typeof pagination === 'string' ? JSON.parse(pagination) : pagination;
51
+ } catch (e) {
52
+ console.error('Failed to parse pagination', e);
53
+ }
54
+ }
55
+
56
+ let activeTab = tab || "active";
57
+ if (!tab && filters) {
58
+ try {
59
+ const parsedFilters = typeof filters === 'string' ? JSON.parse(filters) : filters;
60
+ activeTab = parsedFilters.activeTab || "active";
61
+ } catch (e) {
62
+ activeTab = "active";
63
+ }
64
+ }
65
+
66
+ const transformedParams = {
67
+ pagination: {
68
+ skip: String(paginationObj.page || 1),
69
+ take: String(paginationObj.pageSize || 20),
70
+ },
71
+ tab: activeTab,
72
+ };
73
+
74
+ return getData({ params: transformedParams });
75
+ };
41
76
  const {
42
77
  filter,
43
78
  activeTab,
@@ -59,7 +94,7 @@ export default function SubjectsTable({
59
94
  defaultPageSize,
60
95
  filtersConfig,
61
96
  getRedirectLink,
62
- getData,
97
+ getData: getDataWithStringPagination,
63
98
  refetchTrigger,
64
99
  });
65
100
 
@@ -67,7 +102,7 @@ export default function SubjectsTable({
67
102
  return {
68
103
  category: config.options?.category,
69
104
  country: config.options?.countries,
70
- sources: [], //TODO: add sources logic and make sure you only show unique sources only once
105
+ sources: [],
71
106
  };
72
107
  }, [config.options]);
73
108
 
@@ -113,25 +148,15 @@ export default function SubjectsTable({
113
148
  breadcrumbs={breadcrumbs}
114
149
  >
115
150
  {selectedSubjects.length > 0 && (
116
- <div
117
- className="flex flex-row ml-6 mt-5"
118
- style={{
119
- flexWrap: "wrap",
120
- gap: "8px",
121
- }}
122
- >
151
+ <div className="flex flex-row ml-6 mt-5" style={{ flexWrap: "wrap", gap: "8px" }}>
123
152
  {selectedSubjects.map((account) => (
124
153
  <Tag
125
154
  key={account.userId}
126
155
  className="flex flex-row gap-2 items-center"
127
156
  onClick={() =>
128
- setSelectedSubjects((prev) =>
129
- prev.filter((a) => a.datastakeId !== account.datastakeId),
130
- )
157
+ setSelectedSubjects((prev) => prev.filter((a) => a.datastakeId !== account.datastakeId))
131
158
  }
132
- style={{
133
- cursor: "pointer",
134
- }}
159
+ style={{ cursor: "pointer" }}
135
160
  >
136
161
  <span>{account.datastakeId}</span>
137
162
  <CustomIcon name="Close" size={10} />
@@ -160,19 +185,20 @@ export default function SubjectsTable({
160
185
  <CombineSubjectsModal
161
186
  isOpen={isCombineModalOpen}
162
187
  t={t}
163
- onClose={() => {
164
- setIsModalOpen(false);
165
- }}
188
+ onClose={() => setIsModalOpen(false)}
166
189
  onSuccess={(data) => {
167
190
  setIsModalOpen(false);
168
191
  setLoading(true);
192
+ message.success(t("Subjects successfully merged."))
169
193
  if (typeof mergeSubjectsFunction === 'function') {
170
- mergeSubjectsFunction(data);
171
- setSelectedSubjects([])
194
+ mergeSubjectsFunction(data).finally(() => {
195
+ setSelectedSubjects([]);
196
+ fetchData();
197
+ });
172
198
  }
173
199
  }}
174
200
  selectedSubjects={selectedSubjects}
175
- selectOptions={selectOptions || {}}
201
+ selectOptions={selectOptions}
176
202
  module={module}
177
203
  entity={headerTitle}
178
204
  />
@@ -54,6 +54,7 @@ export default function UserTable({
54
54
  getRedirectLink,
55
55
  getData,
56
56
  defaultPageSize,
57
+ fetchPendingOnMount: true, // Users table needs pending count
57
58
  });
58
59
 
59
60
  const selectOptions = useMemo(() => {
@@ -0,0 +1,81 @@
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
+
@@ -0,0 +1,76 @@
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
+
@@ -0,0 +1,38 @@
1
+ export const config = [
2
+ {
3
+ label: "Core Data",
4
+ key: "core-data",
5
+ title: "Core Data",
6
+ items: [
7
+ {
8
+ label: "Name",
9
+ key: "name",
10
+ type: "input"
11
+ },
12
+ {
13
+ label: "Category",
14
+ key: "category",
15
+ type: "select",
16
+ optionsName: "category"
17
+ },
18
+ {
19
+ label: "Country",
20
+ key: "country",
21
+ type: "select",
22
+ optionsName: "countries"
23
+ },
24
+ {
25
+ label: "Province",
26
+ key: "administrativeLevel1",
27
+ type: "administrative",
28
+ level: "level_1"
29
+ },
30
+ {
31
+ label: "Territory",
32
+ key: "administrativeLevel2",
33
+ type: "administrative",
34
+ level: "level_2"
35
+ },
36
+ ],
37
+ },
38
+ ];
@@ -0,0 +1,13 @@
1
+ export const getNameByLevel = (data, level) => {
2
+ const entry = Object.values(data || {}).find(item => item.level === level);
3
+ return entry?.name || "-";
4
+ };
5
+
6
+ export const getAdministrativeLevel1 = (location) => {
7
+ return getNameByLevel(location?.linking?.SCL, "level_1");
8
+ };
9
+
10
+ export const getAdministrativeLevel2 = (location) => {
11
+ return getNameByLevel(location?.linking?.SCL, "level_2");
12
+ };
13
+