datastake-daf 0.6.787 → 0.6.788

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 (62) hide show
  1. package/build/favicon.ico +0 -0
  2. package/build/logo192.png +0 -0
  3. package/build/logo512.png +0 -0
  4. package/build/manifest.json +25 -0
  5. package/build/robots.txt +3 -0
  6. package/dist/components/index.js +579 -722
  7. package/dist/pages/index.js +774 -33
  8. package/dist/services/index.js +1 -10
  9. package/dist/style/datastake/mapbox-gl.css +330 -0
  10. package/dist/utils/index.js +12 -28
  11. package/package.json +1 -1
  12. package/src/@daf/core/components/Dashboard/Widget/ActivityIndicators/ActivityIndicators.stories.js +24 -0
  13. package/src/@daf/core/components/Dashboard/Widget/ActivityIndicators/index.jsx +1 -0
  14. package/src/@daf/core/components/Dashboard/Widget/ActivityIndicators/style.js +34 -0
  15. package/src/@daf/core/components/Dashboard/Widget/KeyIndicators/KeyIndicators.stories.js +39 -0
  16. package/src/@daf/core/components/Dashboard/Widget/KeyIndicators/LabelWithIcon.jsx +38 -0
  17. package/src/@daf/core/components/Dashboard/Widget/KeyIndicators/index.jsx +16 -3
  18. package/src/@daf/core/components/Dashboard/Widget/KeyIndicators/style.js +33 -0
  19. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/hook.js +1 -0
  20. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/index.jsx +1 -1
  21. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/hook.js +1 -1
  22. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/index.jsx +1 -1
  23. package/src/@daf/core/components/Screens/Admin/AdminModals/AddUser/index.jsx +1 -0
  24. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/index.jsx +1 -1
  25. package/src/@daf/core/components/Screens/Admin/AdminModals/NewAccount/index.jsx +1 -1
  26. package/src/@daf/core/components/Screens/Admin/AdminScreens/Dashboard.jsx +2 -2
  27. package/src/@daf/core/components/Screens/Admin/AdminScreens/Location.jsx +5 -5
  28. package/src/@daf/core/components/Screens/Admin/AdminScreens/Subjects.jsx +2 -2
  29. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/index.jsx +5 -23
  30. package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/columns.js +36 -36
  31. package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/index.jsx +21 -12
  32. package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/helper.js +8 -13
  33. package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/index.jsx +2 -2
  34. package/src/@daf/core/components/Screens/Admin/adminRoutes.js +2 -2
  35. package/src/@daf/pages/Summary/Activities/Monitoring/components/ActivityImagery/index.jsx +29 -0
  36. package/src/@daf/pages/Summary/Activities/Monitoring/components/ActivityLocation/index.jsx +94 -0
  37. package/src/@daf/pages/Summary/Activities/Monitoring/components/MangroveGrowthAndSurvival/components/PlantedSpecies/index.jsx +56 -0
  38. package/src/@daf/pages/Summary/Activities/Monitoring/components/MangroveGrowthAndSurvival/components/SeedlingsHeight/index.jsx +121 -0
  39. package/src/@daf/pages/Summary/Activities/Monitoring/components/MangroveGrowthAndSurvival/components/SurvivalRate/index.jsx +94 -0
  40. package/src/@daf/pages/Summary/Activities/Monitoring/components/MangroveGrowthAndSurvival/index.jsx +54 -0
  41. package/src/@daf/pages/Summary/Activities/Monitoring/components/WorkersDistribution/index.jsx +49 -0
  42. package/src/@daf/pages/Summary/Activities/Monitoring/config.js +51 -0
  43. package/src/@daf/pages/Summary/Activities/Monitoring/helper.js +236 -0
  44. package/src/@daf/pages/Summary/Activities/Monitoring/index.jsx +66 -0
  45. package/src/@daf/services/AdminService.js +3 -12
  46. package/src/@daf/services/DashboardService.js +1 -2
  47. package/src/@daf/utils/filters.js +89 -89
  48. package/src/constants/locales/en/translation.js +0 -3
  49. package/src/constants/locales/fr/translation.js +1 -1
  50. package/src/constants/locales/sp/translation.js +1 -1
  51. package/src/pages.js +1 -0
  52. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/column.js +0 -224
  53. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/helper.js +0 -65
  54. package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/columns.js +0 -180
  55. package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/config.js +0 -0
  56. package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/index.jsx +0 -27
  57. package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/columns.js +0 -157
  58. package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/config.js +0 -31
  59. package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/index.js +0 -77
  60. package/src/@daf/pages/SelfAssesment/components/ProductionSiteTable/columns.js +0 -117
  61. package/src/@daf/pages/SelfAssesment/components/ProductionSiteTable/index.jsx +0 -54
  62. package/src/@daf/pages/SelfAssesment/index.jsx +0 -0
@@ -69,10 +69,10 @@ class AdminService extends BaseService {
69
69
  }
70
70
 
71
71
  getSubjects({ subject, params }) {
72
- return this.apiGet({
73
- url: `/management/subjects/${subject}`,
72
+ return this.apiGet({
73
+ url: `${subject}`,
74
74
  params,
75
- });
75
+ })
76
76
  }
77
77
 
78
78
  mergeSubjects({ subject, ...data }) {
@@ -81,15 +81,6 @@ class AdminService extends BaseService {
81
81
  data,
82
82
  })
83
83
  }
84
- getUserGrowth(activeFilter) {
85
- return this.apiGet({
86
- url: `/accounts/dashboard/user-growth`,
87
- isUserManager: true,
88
- params: { activeFilter },
89
- });
90
- }
91
-
92
-
93
84
  }
94
85
 
95
86
  export default createLazyService(AdminService);
@@ -26,5 +26,4 @@ class DashboardService extends BaseService {
26
26
  }
27
27
  }
28
28
 
29
- export default createLazyService(DashboardService);
30
-
29
+ export default createLazyService(DashboardService);
@@ -1,102 +1,102 @@
1
1
  export const defaultFilterKeys = ["search", "sortDir", "sortBy", "timeframe", "activeTab"];
2
+
2
3
  function hasJsonStructure(str) {
3
- if (typeof str !== "string") return false;
4
- try {
5
- const result = JSON.parse(str);
6
- const type = Object.prototype.toString.call(result);
7
- return type === "[object Object]" || type === "[object Array]";
8
- } catch (err) {
9
- return false;
10
- }
4
+ if (typeof str !== "string") return false;
5
+ try {
6
+ const result = JSON.parse(str);
7
+ const type = Object.prototype.toString.call(result);
8
+ return type === "[object Object]" || type === "[object Array]";
9
+ } catch (err) {
10
+ return false;
11
+ }
11
12
  }
13
+
12
14
  export const getDefaultActiveFilters = (
13
- params,
14
- selectFiltersConfig,
15
- defaultPageSize,
16
- defaultFilters = {},
17
- doPagination,
15
+ params,
16
+ selectFiltersConfig,
17
+ defaultPageSize,
18
+ defaultFilters = {},
19
+ doPagination,
18
20
  ) => {
19
- const o = {};
20
- defaultFilterKeys.forEach((k) => {
21
- if (params.has(k)) {
22
- if (hasJsonStructure(params.get(k))) {
23
- o[k] = JSON.parse(params.get(k));
24
- } else {
25
- o[k] = params.get(k);
26
- }
27
- } else if (defaultFilters[k]) {
28
- if (hasJsonStructure(defaultFilters[k])) {
29
- o[k] = JSON.parse(defaultFilters[k]);
30
- } else {
31
- o[k] = defaultFilters[k];
32
- }
33
- }
34
- });
35
- if (params.has("searchParams")) {
36
- try {
37
- o.searchParams = JSON.parse(params.get("searchParams"));
38
- } catch (e) {
39
- o.searchParams = params.get("searchParams").split(",");
40
- }
41
- }
42
- if (doPagination) {
43
- o.page = Number(params.get("page")) || 1;
44
- o.pageSize = Number(params.get("pageSize")) || defaultPageSize;
45
- }
46
- Object.keys(selectFiltersConfig).forEach((k) => {
47
- if (params.has(k)) {
48
- if (hasJsonStructure(params.get(k))) {
49
- o[k] = JSON.parse(params.get(k));
50
- } else {
51
- o[k] = params.get(k);
52
- }
53
- }
54
- });
55
- return o;
21
+ const o = {};
22
+
23
+ defaultFilterKeys.forEach((k) => {
24
+ if (params.has(k)) {
25
+ if (hasJsonStructure(params.get(k))) {
26
+ o[k] = JSON.parse(params.get(k));
27
+ } else {
28
+ o[k] = params.get(k);
29
+ }
30
+ } else if (defaultFilters[k]) {
31
+ if (hasJsonStructure(defaultFilters[k])) {
32
+ o[k] = JSON.parse(defaultFilters[k]);
33
+ } else {
34
+ o[k] = defaultFilters[k];
35
+ }
36
+ }
37
+ });
38
+
39
+ if (params.has("searchParams")) {
40
+ try {
41
+ o.searchParams = JSON.parse(params.get("searchParams"));
42
+ } catch (e) {
43
+ o.searchParams = params.get("searchParams").split(",");
44
+ }
45
+ }
46
+
47
+ if (doPagination) {
48
+ o.page = Number(params.get("page")) || 1;
49
+ o.pageSize = Number(params.get("pageSize")) || defaultPageSize;
50
+ }
51
+
52
+ Object.keys(selectFiltersConfig).forEach((k) => {
53
+ if (params.has(k)) {
54
+ if (hasJsonStructure(params.get(k))) {
55
+ o[k] = JSON.parse(params.get(k));
56
+ } else {
57
+ o[k] = params.get(k);
58
+ }
59
+ }
60
+ });
61
+
62
+ return o;
56
63
  };
64
+
57
65
  const NEW_PAGINATION_APPS = ["nashiriki"];
58
66
  export const filterParams = (value, module) => {
59
- const { activeFilters, ...rest } = value;
60
- const { page, pageSize, sortDir, sortBy, search, searchParams, ...filters } =
61
- activeFilters || {};
62
- const params = {};
63
- // Use skip and take inside pagination object
64
- // Calculate skip from page number (page 1 = skip 1, page 2 = skip 21, etc.)
65
- params.pagination = {
66
- skip: page ? ((page - 1) * (pageSize || 20) + 1) : 1,
67
- take: pageSize || 20,
68
- };
69
- if (search && searchParams) {
70
- params.search = JSON.stringify({
71
- qs: search,
72
- fields: searchParams,
73
- });
74
- }
75
- if (sortDir && sortBy) {
76
- params.sort = JSON.stringify({
77
- dir: sortDir,
78
- by: sortBy,
79
- });
80
- }
81
- if (Object.keys(filters).length) {
82
- if (value.sourceId && value.sourceId === "overview") {
83
- const { activeTab, ...restFilters } = filters;
84
- Object.assign(params, restFilters);
85
- if (activeTab !== undefined) {
86
- params.tab = activeTab;
87
- }
88
- } else {
89
- const { authorId, activeTab, ...restFilters } = filters;
90
- Object.assign(params, restFilters);
91
- if (activeTab !== undefined) {
92
- params.tab = activeTab;
93
- }
94
- }
95
- }
96
- return { ...rest, ...params };
97
- };
67
+ const { activeFilters, ...rest } = value;
98
68
 
69
+ const { page, pageSize, sortDir, sortBy, search, searchParams, ...filters } =
70
+ activeFilters || {};
99
71
 
72
+ const params = {};
73
+
74
+ params.pagination = JSON.stringify({
75
+ [NEW_PAGINATION_APPS.includes(module) ? "skip" : "page"]: page,
76
+ [NEW_PAGINATION_APPS.includes(module) ? "take" : "pageSize"]: pageSize,
77
+ });
100
78
 
79
+ if (search && searchParams) {
80
+ params.search = JSON.stringify({
81
+ qs: search,
82
+ fields: searchParams,
83
+ });
84
+ }
101
85
 
86
+ if (sortDir && sortBy) {
87
+ params.sort = JSON.stringify({
88
+ dir: sortDir,
89
+ by: sortBy,
90
+ });
91
+ }
102
92
 
93
+ if (Object.keys(filters).length) {
94
+ if (value.sourceId && value.sourceId === "overview") {
95
+ params.filters = JSON.stringify(filters);
96
+ } else {
97
+ params.filters = JSON.stringify({ ...filters, authorId: undefined });
98
+ }
99
+ }
100
+
101
+ return { ...rest, ...params };
102
+ };
@@ -1,7 +1,4 @@
1
1
  const en = {
2
- "sbg-admin::remove-user-title":"Remove User Title",
3
- "sbg-admin::remove-user-body":"Remove User Body",
4
- "add-account":"Add Account",
5
2
  "Site": "Site",
6
3
  "Production Sites": "Production Sites",
7
4
  "Type of account": "Type of account",
@@ -420,7 +420,7 @@ const fr = {
420
420
  Documentation: "Documents",
421
421
  "Edit project": "Modifier le projet",
422
422
  Name: "Nom",
423
- Type: "Type",
423
+ Type: "Tapez",
424
424
  type: "Type",
425
425
  Province: "Province",
426
426
  Territory: "Territoire",
@@ -233,7 +233,7 @@ const sp = {
233
233
  "Documentation": "Documentos",
234
234
  "Edit project": "Modificar proyecto",
235
235
  "Name": "Nombre",
236
- "Type": "Tipo",
236
+ "Type": "Escribe",
237
237
  "type": "Tipo",
238
238
  "Province": "Provincia",
239
239
  "Territory": "Territorio",
package/src/pages.js CHANGED
@@ -21,6 +21,7 @@ export { default as RestorationActivitySummary } from './@daf/pages/Summary/Acti
21
21
  export { default as PlantingCycleSummary } from './@daf/pages/Summary/Activities/PlantingCycle/index.jsx';
22
22
  export { default as MonitoringCampaignSummary } from './@daf/pages/Summary/Activities/MonitoringCampaign/index.jsx';
23
23
  export { default as MineSummary } from './@daf/pages/Summary/Minesite/index.jsx';
24
+ export { default as MonitoringActivitySummary } from './@daf/pages/Summary/Activities/Monitoring/index.jsx';
24
25
 
25
26
  // View
26
27
  export { default as View } from './@daf/pages/View/index.jsx';
@@ -1,224 +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 "./helper.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/accounts/view/${all.id}/details`));
214
- }}
215
- >
216
- <CustomIcon name="Link" width={18} height={18} />
217
- </div>
218
- );
219
- },
220
- },
221
- ];
222
-
223
- return cols.filter((c) => c[show]);
224
- };
@@ -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
-