datastake-daf 0.6.785 → 0.6.787

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 (54) hide show
  1. package/dist/components/index.js +674 -399
  2. package/dist/hooks/index.js +9 -1
  3. package/dist/pages/index.js +24 -16
  4. package/dist/services/index.js +10 -1
  5. package/dist/utils/index.js +28 -12
  6. package/package.json +1 -1
  7. package/src/@daf/core/components/Dashboard/Map/hook.js +1 -1
  8. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/hook.js +0 -1
  9. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/index.jsx +1 -1
  10. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/hook.js +1 -1
  11. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/index.jsx +1 -1
  12. package/src/@daf/core/components/Screens/Admin/AdminModals/AddUser/index.jsx +0 -1
  13. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/index.jsx +1 -1
  14. package/src/@daf/core/components/Screens/Admin/AdminModals/NewAccount/index.jsx +1 -1
  15. package/src/@daf/core/components/Screens/Admin/AdminScreens/Dashboard.jsx +2 -2
  16. package/src/@daf/core/components/Screens/Admin/AdminScreens/Location.jsx +5 -5
  17. package/src/@daf/core/components/Screens/Admin/AdminScreens/Subjects.jsx +2 -2
  18. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/column.js +224 -0
  19. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/helper.js +65 -0
  20. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/index.jsx +23 -5
  21. package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/columns.js +36 -36
  22. package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/index.jsx +12 -21
  23. package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/helper.js +13 -8
  24. package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/index.jsx +2 -2
  25. package/src/@daf/core/components/Screens/Admin/adminRoutes.js +2 -2
  26. package/src/@daf/hooks/useGetQueryParams.js +3 -1
  27. package/src/@daf/pages/Events/Activities/columns.js +2 -2
  28. package/src/@daf/pages/Events/Activities/config.js +2 -2
  29. package/src/@daf/pages/Events/Incidents/columns.js +2 -2
  30. package/src/@daf/pages/Events/Incidents/config.js +2 -2
  31. package/src/@daf/pages/Locations/MineSite/columns.js +2 -2
  32. package/src/@daf/pages/Locations/columns.js +2 -2
  33. package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/columns.js +180 -0
  34. package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/config.js +0 -0
  35. package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/index.jsx +27 -0
  36. package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/columns.js +157 -0
  37. package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/config.js +31 -0
  38. package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/index.js +77 -0
  39. package/src/@daf/pages/SelfAssesment/components/ProductionSiteTable/columns.js +117 -0
  40. package/src/@daf/pages/SelfAssesment/components/ProductionSiteTable/index.jsx +54 -0
  41. package/src/@daf/pages/SelfAssesment/index.jsx +0 -0
  42. package/src/@daf/pages/Stakeholders/Operators/columns.js +2 -2
  43. package/src/@daf/services/AdminService.js +12 -3
  44. package/src/@daf/services/DashboardService.js +2 -1
  45. package/src/@daf/utils/filters.js +89 -89
  46. package/src/constants/locales/en/translation.js +3 -0
  47. package/src/constants/locales/fr/translation.js +1 -1
  48. package/src/constants/locales/sp/translation.js +1 -1
  49. package/build/favicon.ico +0 -0
  50. package/build/logo192.png +0 -0
  51. package/build/logo512.png +0 -0
  52. package/build/manifest.json +0 -25
  53. package/build/robots.txt +0 -3
  54. package/dist/style/datastake/mapbox-gl.css +0 -330
@@ -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
+
@@ -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,
@@ -11,8 +11,8 @@ import {
11
11
  defaultUrlParams,
12
12
  checkboxConfig,
13
13
  } from "../SubjectsTable/helper.js";
14
- import { getColumns } from "../SubjectsTable/columns.js";
15
14
  import CombineLocationModal from "../../AdminModals/CombineLocation/index.jsx";
15
+ import { getColumns } from "./column.js";
16
16
  const { useToken } = theme;
17
17
 
18
18
  export default function LocationTable({
@@ -37,6 +37,22 @@ export default function LocationTable({
37
37
  const { token } = useToken();
38
38
  const [combineLocationVisible, setCombineLocationVisible] = useState(false);
39
39
 
40
+ // Wrapper to transform pagination params to strings and ensure tab is at root level
41
+ const getDataWithStringPagination = async ({ params }) => {
42
+ // Extract tab from the params (it should already be there from filterParams)
43
+ const { pagination, tab, ...otherParams } = params;
44
+
45
+ const transformedParams = {
46
+ ...otherParams,
47
+ pagination: {
48
+ skip: String(pagination?.skip || 1),
49
+ take: String(pagination?.take || 20),
50
+ },
51
+ tab: tab || "active", // Ensure tab is at root level with default value
52
+ };
53
+ return getData({ params: transformedParams });
54
+ };
55
+
40
56
  const {
41
57
  filter,
42
58
  activeTab,
@@ -58,7 +74,7 @@ export default function LocationTable({
58
74
  defaultPageSize,
59
75
  filtersConfig,
60
76
  getRedirectLink,
61
- getData,
77
+ getData: getDataWithStringPagination,
62
78
  refetchTrigger,
63
79
  });
64
80
 
@@ -80,7 +96,7 @@ export default function LocationTable({
80
96
  setSelectedLocations,
81
97
  getRedirectLink,
82
98
  selectOptions,
83
- entity: headerTitle
99
+ entity: headerTitle,
84
100
  });
85
101
  }, [t, goTo, module, token, selectedLocations, getRedirectLink, selectOptions, headerTitle]);
86
102
 
@@ -89,7 +105,7 @@ export default function LocationTable({
89
105
  <AdminTable
90
106
  filters={filter}
91
107
  t={t}
92
- headerTitle={headerTitle}
108
+ headerTitle={"test"}
93
109
  actionButton={[
94
110
  {
95
111
  icon: "Merge",
@@ -110,6 +126,7 @@ export default function LocationTable({
110
126
  checkboxConfig={checkboxConfig}
111
127
  defaultTableFilters={{}}
112
128
  breadcrumbs={breadcrumbs}
129
+
113
130
  >
114
131
  {selectedLocations.length > 0 && (
115
132
  <div
@@ -168,6 +185,7 @@ export default function LocationTable({
168
185
  if (typeof mergeSubjectsFunction === 'function') {
169
186
  mergeSubjectsFunction(data);
170
187
  setSelectedLocations([])
188
+ message.success(t("Locations successfully merged."))
171
189
  }
172
190
  }}
173
191
  selectedLocations={selectedLocations}
@@ -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",
@@ -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,
@@ -67,7 +67,7 @@ export default function SubjectsTable({
67
67
  return {
68
68
  category: config.options?.category,
69
69
  country: config.options?.countries,
70
- sources: [], //TODO: add sources logic and make sure you only show unique sources only once
70
+ sources: [],
71
71
  };
72
72
  }, [config.options]);
73
73
 
@@ -113,25 +113,15 @@ export default function SubjectsTable({
113
113
  breadcrumbs={breadcrumbs}
114
114
  >
115
115
  {selectedSubjects.length > 0 && (
116
- <div
117
- className="flex flex-row ml-6 mt-5"
118
- style={{
119
- flexWrap: "wrap",
120
- gap: "8px",
121
- }}
122
- >
116
+ <div className="flex flex-row ml-6 mt-5" style={{ flexWrap: "wrap", gap: "8px" }}>
123
117
  {selectedSubjects.map((account) => (
124
118
  <Tag
125
119
  key={account.userId}
126
120
  className="flex flex-row gap-2 items-center"
127
121
  onClick={() =>
128
- setSelectedSubjects((prev) =>
129
- prev.filter((a) => a.datastakeId !== account.datastakeId),
130
- )
122
+ setSelectedSubjects((prev) => prev.filter((a) => a.datastakeId !== account.datastakeId))
131
123
  }
132
- style={{
133
- cursor: "pointer",
134
- }}
124
+ style={{ cursor: "pointer" }}
135
125
  >
136
126
  <span>{account.datastakeId}</span>
137
127
  <CustomIcon name="Close" size={10} />
@@ -160,19 +150,20 @@ export default function SubjectsTable({
160
150
  <CombineSubjectsModal
161
151
  isOpen={isCombineModalOpen}
162
152
  t={t}
163
- onClose={() => {
164
- setIsModalOpen(false);
165
- }}
153
+ onClose={() => setIsModalOpen(false)}
166
154
  onSuccess={(data) => {
167
155
  setIsModalOpen(false);
168
156
  setLoading(true);
157
+ message.success(t("Subjects successfully merged."))
169
158
  if (typeof mergeSubjectsFunction === 'function') {
170
- mergeSubjectsFunction(data);
171
- setSelectedSubjects([])
159
+ mergeSubjectsFunction(data).finally(() => {
160
+ setSelectedSubjects([]);
161
+ fetchData();
162
+ });
172
163
  }
173
164
  }}
174
165
  selectedSubjects={selectedSubjects}
175
- selectOptions={selectOptions || {}}
166
+ selectOptions={selectOptions}
176
167
  module={module}
177
168
  entity={headerTitle}
178
169
  />
@@ -167,10 +167,7 @@ export const getColumns = ({
167
167
  return cols.filter((v) => v.show);
168
168
  };
169
169
 
170
- export const checkboxConfig = {
171
- name: "Name",
172
- datastakeId: "ID",
173
- };
170
+ export const checkboxConfig = {};
174
171
 
175
172
  export const selectFiltersConfig = {
176
173
  userRole: {
@@ -194,9 +191,17 @@ export const selectFiltersConfig = {
194
191
  };
195
192
 
196
193
  export const filtersConfig = {
197
- name: "",
198
- datastakeId: "",
194
+ search: "",
195
+ };
196
+
197
+ export const defaultUrlParams = {
198
+ search: "",
199
+ userRole: null,
200
+ status: null,
199
201
  };
200
202
 
201
- export const defaultUrlParams = {};
202
- export const defaultTableFilters = {};
203
+ export const defaultTableFilters = {
204
+ search: "",
205
+ userRole: null,
206
+ status: null,
207
+ };
@@ -60,10 +60,10 @@ export default function Users({
60
60
  userRole: userRoles.filter((u) => !u.isForAppAdmin),
61
61
  status: accountStatuses,
62
62
  };
63
- }, [userRoles]);
63
+ }, [userRoles, accountStatuses]);
64
64
 
65
65
  const canClearSearch = useMemo(() => {
66
- return !!activeFilters.search;
66
+ return !!activeFilters.search || !!activeFilters.userRole || !!activeFilters.status;
67
67
  }, [activeFilters]);
68
68
 
69
69
  const onDeleteUserClick = useCallback(
@@ -104,7 +104,7 @@ export function getAdminRoutes(config) {
104
104
  ...(typeof useAdminLocationConfig === "function"
105
105
  ? [
106
106
  {
107
- path: "subjects/location",
107
+ path: "management/subjects/location",
108
108
  key: `${APP_PREFIX}_ADMIN_SUBJECTS_LOCATIONS`,
109
109
  exact: true,
110
110
  visible: (user) => userIsAdmin(user),
@@ -115,7 +115,7 @@ export function getAdminRoutes(config) {
115
115
  ...(typeof useAdminSubjectsConfig === "function"
116
116
  ? [
117
117
  {
118
- path: "subjects/stakeholder",
118
+ path: "management/subjects/stakeholder",
119
119
  key: `${APP_PREFIX}_ADMIN_SUBJECTS_STAKEHOLDERS`,
120
120
  exact: true,
121
121
  visible: (user) => userIsAdmin(user),
@@ -8,7 +8,7 @@ export const useGetQueryParams = ({location}) => {
8
8
  }, [location.search]);
9
9
 
10
10
  const params = useMemo(() => {
11
- const { page, pageSize, search, searchParams: rawSearchParams, sortBy, sortDir, ...rest } = queryParams;
11
+ const { page, pageSize, search, searchParams: rawSearchParams, sortBy, sortDir, status, product, ...rest } = queryParams;
12
12
 
13
13
  return {
14
14
  paginationQuery: { skip: page, take: pageSize },
@@ -18,6 +18,8 @@ export const useGetQueryParams = ({location}) => {
18
18
  },
19
19
  otherParams: {
20
20
  ...rest,
21
+ ...(product && { "products.typeOfProduct": product }),
22
+ ...(status && { published: status === "submitted" ? true : false }),
21
23
  },
22
24
  sortBy,
23
25
  sortDir,
@@ -72,7 +72,7 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
72
72
  },
73
73
  {
74
74
  dataIndex: 'province',
75
- title: t('Province'),
75
+ title: findOptions(user?.company?.country, options?.administrativeLevel1) || t("Province"),
76
76
  ellipsis: true,
77
77
  show: true,
78
78
  render: (v, all) => {
@@ -87,7 +87,7 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
87
87
  },
88
88
  {
89
89
  dataIndex: 'territory',
90
- title: t('Territory'),
90
+ title: findOptions(user?.company?.country, options?.administrativeLevel2) || t("Territory"),
91
91
  ellipsis: true,
92
92
  show: true,
93
93
  render: (v, all) => {
@@ -78,7 +78,7 @@ export const getFiltersConfig = ({t}) => {
78
78
  style: { flex: 1 },
79
79
  labelStyle: { flex: 1 },
80
80
  },
81
- category: {
81
+ eventCategory: {
82
82
  type: 'select',
83
83
  label: 'Category',
84
84
  placeholder: () => `${t('Filter by')} ${t('Category').toLowerCase()}`,
@@ -157,7 +157,7 @@ export const getFilterOptions = (options, t) => {
157
157
  label: t("Private"),
158
158
  },
159
159
  ],
160
- category: _categoryOptions,
160
+ eventCategory: _categoryOptions,
161
161
  country: countries,
162
162
  subCategory: subCategoriesOptions,
163
163
  // category: category,
@@ -72,7 +72,7 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
72
72
  },
73
73
  {
74
74
  dataIndex: 'province',
75
- title: t('Province'),
75
+ title: findOptions(user?.company?.country, options?.administrativeLevel1) || t("Province"),
76
76
  ellipsis: true,
77
77
  show: true,
78
78
  render: (v, all) => {
@@ -87,7 +87,7 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
87
87
  },
88
88
  {
89
89
  dataIndex: 'territory',
90
- title: t('Territory'),
90
+ title: findOptions(user?.company?.country, options?.administrativeLevel2) || t("Territory"),
91
91
  ellipsis: true,
92
92
  show: true,
93
93
  render: (v, all) => {
@@ -77,7 +77,7 @@ export const getFiltersConfig = ({t}) => {
77
77
  style: { flex: 1 },
78
78
  labelStyle: { flex: 1 },
79
79
  },
80
- category: {
80
+ eventCategory: {
81
81
  type: 'select',
82
82
  label: 'Category',
83
83
  placeholder: (t) => `${t('Filter by')} ${t('Category').toLowerCase()}`,
@@ -156,7 +156,7 @@ export const getFilterOptions = (options, t) => {
156
156
  label: t("Private"),
157
157
  },
158
158
  ],
159
- category: _categoryOptions,
159
+ eventCategory: _categoryOptions,
160
160
  country: countries,
161
161
  subCategory: subCategoriesOptions,
162
162
  // category: category,
@@ -42,7 +42,7 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
42
42
  },
43
43
  {
44
44
  dataIndex: 'region',
45
- title: t('Region'),
45
+ title: findOptions(user?.company?.country, options?.administrativeLevel1) || t("Province"),
46
46
  ellipsis: true,
47
47
  show: true,
48
48
  render: (v, all) => {
@@ -57,7 +57,7 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
57
57
  },
58
58
  {
59
59
  dataIndex: 'territory',
60
- title: t('Territory'),
60
+ title: findOptions(user?.company?.country, options?.administrativeLevel2) || t("Territory"),
61
61
  ellipsis: true,
62
62
  show: true,
63
63
  render: (v, all) => {
@@ -65,7 +65,7 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
65
65
  },
66
66
  {
67
67
  dataIndex: 'province',
68
- title: t('Province'),
68
+ title: findOptions(user?.company?.country, options?.administrativeLevel1) || t("Province"),
69
69
  ellipsis: true,
70
70
  show: true,
71
71
  render: (v, all) => {
@@ -80,7 +80,7 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
80
80
  },
81
81
  {
82
82
  dataIndex: 'territory',
83
- title: t('Territory'),
83
+ title: findOptions(user?.company?.country, options?.administrativeLevel2) || t("Territory"),
84
84
  ellipsis: true,
85
85
  show: true,
86
86
  render: (v, all) => {