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
package/src/@daf/pages/Summary/Activities/Monitoring/components/BiodiversityAndHabitat/helper.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export const FAUNA_KEYS = [
|
|
2
|
+
'birds',
|
|
3
|
+
'juveniles',
|
|
4
|
+
'crabs',
|
|
5
|
+
'cymbium',
|
|
6
|
+
'fish',
|
|
7
|
+
'mongooses',
|
|
8
|
+
'mollusks',
|
|
9
|
+
'monkeys',
|
|
10
|
+
'oysters',
|
|
11
|
+
'snails',
|
|
12
|
+
'caterpillars',
|
|
13
|
+
'animal_tracks',
|
|
14
|
+
'other'
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
export const INVASIVE_SPECIES_KEYS = [
|
|
18
|
+
'spiders',
|
|
19
|
+
'scaleInsects',
|
|
20
|
+
'caterpillars',
|
|
21
|
+
'unidentifiedPests',
|
|
22
|
+
'other',
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
export const formatFaunaLabel = (key) => {
|
|
26
|
+
return key
|
|
27
|
+
.split('_')
|
|
28
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
29
|
+
.join(' ');
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const formatInvasiveSpeciesLabel = (key) => {
|
|
33
|
+
return key
|
|
34
|
+
.replace(/([A-Z])/g, ' $1')
|
|
35
|
+
.split(' ')
|
|
36
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
37
|
+
.join(' ');
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const createFaunaIndicatorConfig = (key, faunaPresent, t) => {
|
|
41
|
+
const isPresent = Array.isArray(faunaPresent) && faunaPresent.includes(key);
|
|
42
|
+
const label = formatFaunaLabel(key);
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
label: t(label),
|
|
46
|
+
type: isPresent ? 'compliant' : 'notCompliant',
|
|
47
|
+
statusIcon: isPresent ? 'Check' : 'Close',
|
|
48
|
+
statusIconColor: isPresent ? '#12B76A' : '#6C737F',
|
|
49
|
+
statusBadgeBackgroundColor: isPresent ? undefined : '#F9FAFB',
|
|
50
|
+
statusBadgeBorderColor: isPresent ? undefined : '#E5E7EB'
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const createInvasiveSpeciesIndicatorConfig = (key, invasiveSpecies, hasInvasiveSpecies, t) => {
|
|
55
|
+
const shouldShowAllAsNotPresent = hasInvasiveSpecies === 'no';
|
|
56
|
+
const shouldShowRedForPresent = hasInvasiveSpecies === 'yes';
|
|
57
|
+
|
|
58
|
+
const isPresent = !shouldShowAllAsNotPresent &&
|
|
59
|
+
Array.isArray(invasiveSpecies) &&
|
|
60
|
+
invasiveSpecies.includes(key);
|
|
61
|
+
|
|
62
|
+
const isRedBadge = isPresent && shouldShowRedForPresent;
|
|
63
|
+
const label = formatInvasiveSpeciesLabel(key);
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
label: t(label),
|
|
67
|
+
type: isPresent ? 'compliant' : 'notCompliant',
|
|
68
|
+
statusIcon: isPresent ? 'Check' : 'Close',
|
|
69
|
+
statusIconColor: isRedBadge ? '#D92D20' : (isPresent ? '#12B76A' : '#6C737F'),
|
|
70
|
+
statusBadgeBackgroundColor: isRedBadge ? '#FEE4E2' : (isPresent ? undefined : '#F9FAFB'),
|
|
71
|
+
statusBadgeBorderColor: isRedBadge ? '#FDA29B' : (isPresent ? undefined : '#E5E7EB')
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const generateFaunaConfig = (faunaPresent, t) => {
|
|
76
|
+
return FAUNA_KEYS.map(key =>
|
|
77
|
+
createFaunaIndicatorConfig(key, faunaPresent, t)
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const generateInvasiveSpeciesConfig = (invasiveSpecies, hasInvasiveSpecies, t) => {
|
|
82
|
+
return INVASIVE_SPECIES_KEYS.map(key =>
|
|
83
|
+
createInvasiveSpeciesIndicatorConfig(key, invasiveSpecies, hasInvasiveSpecies, t)
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
package/src/@daf/pages/Summary/Activities/Monitoring/components/BiodiversityAndHabitat/index.jsx
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { ActivityIndicators, Widget } from '../../../../../../../../src/index.js';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import {
|
|
5
|
+
generateFaunaConfig,
|
|
6
|
+
generateInvasiveSpeciesConfig
|
|
7
|
+
} from './helper';
|
|
8
|
+
|
|
9
|
+
const Container = styled.div`
|
|
10
|
+
display: grid;
|
|
11
|
+
grid-template-columns: 70% 28.5%;
|
|
12
|
+
gap: 24px;
|
|
13
|
+
width: 100%;
|
|
14
|
+
@media (max-width: 768px) {
|
|
15
|
+
grid-template-columns: 1fr;
|
|
16
|
+
}
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
const BiodiversityAndHabitat = ({
|
|
20
|
+
faunaPresent = [],
|
|
21
|
+
invasiveSpecies = [],
|
|
22
|
+
hasInvasiveSpecies,
|
|
23
|
+
loading = false,
|
|
24
|
+
t = (s) => s
|
|
25
|
+
}) => {
|
|
26
|
+
const observedFaunaConfig = useMemo(() =>
|
|
27
|
+
generateFaunaConfig(faunaPresent, t),
|
|
28
|
+
[faunaPresent, t]
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const invasiveSpeciesConfig = useMemo(() =>
|
|
32
|
+
generateInvasiveSpeciesConfig(invasiveSpecies, hasInvasiveSpecies, t),
|
|
33
|
+
[invasiveSpecies, hasInvasiveSpecies, t]
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<Widget
|
|
38
|
+
title={t("Biodiversity & Habitat")}
|
|
39
|
+
className="with-border-header h-w-btn-header"
|
|
40
|
+
>
|
|
41
|
+
<section>
|
|
42
|
+
<Container>
|
|
43
|
+
<ActivityIndicators
|
|
44
|
+
title={t("Observed Fauna")}
|
|
45
|
+
config={observedFaunaConfig}
|
|
46
|
+
loading={loading}
|
|
47
|
+
widgetClassName="h-w-btn-header"
|
|
48
|
+
t={t}
|
|
49
|
+
/>
|
|
50
|
+
<ActivityIndicators
|
|
51
|
+
title={t("Invasive Species")}
|
|
52
|
+
config={invasiveSpeciesConfig}
|
|
53
|
+
loading={loading}
|
|
54
|
+
className="single-column"
|
|
55
|
+
widgetClassName="h-w-btn-header"
|
|
56
|
+
t={t}
|
|
57
|
+
/>
|
|
58
|
+
</Container>
|
|
59
|
+
</section>
|
|
60
|
+
</Widget>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export default BiodiversityAndHabitat;
|
|
65
|
+
|
package/src/@daf/pages/Summary/Activities/Monitoring/components/EnvironmentalMetrics/index.jsx
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { KeyIndicators } from '../../../../../../../../src/index.js';
|
|
3
|
+
import { getEnvironmentalMetricsConfig } from '../../config';
|
|
4
|
+
|
|
5
|
+
const EnvironmentalMetrics = ({
|
|
6
|
+
activityData,
|
|
7
|
+
loading = false,
|
|
8
|
+
t = (s) => s,
|
|
9
|
+
options
|
|
10
|
+
}) => {
|
|
11
|
+
const environmentalMetricsConfig = useMemo(() =>
|
|
12
|
+
getEnvironmentalMetricsConfig({ t, data: activityData, options }),
|
|
13
|
+
[t, activityData]
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<div style={{ flex: 1, }}>
|
|
18
|
+
<KeyIndicators
|
|
19
|
+
loading={loading}
|
|
20
|
+
config={environmentalMetricsConfig}
|
|
21
|
+
title={t("straatos::environmental-metrics")}
|
|
22
|
+
className="small-content row-content"
|
|
23
|
+
widgetClassName="h-w-btn-header"
|
|
24
|
+
/>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default EnvironmentalMetrics;
|
|
30
|
+
|
|
@@ -2,43 +2,30 @@ import React, { useMemo } from 'react';
|
|
|
2
2
|
import { ActivityIndicators } from '../../../../../../../../../../src/index.js';
|
|
3
3
|
|
|
4
4
|
const PlantedSpecies = ({
|
|
5
|
-
|
|
5
|
+
plantedSpecies,
|
|
6
|
+
mangroveSpecies,
|
|
6
7
|
loading = false,
|
|
7
8
|
t = (s) => s
|
|
8
9
|
}) => {
|
|
10
|
+
|
|
9
11
|
const speciesConfig = useMemo(() => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// If species is an array, map it to config format
|
|
15
|
-
if (Array.isArray(species)) {
|
|
16
|
-
return species.map((speciesItem, index) => {
|
|
17
|
-
const speciesName = typeof speciesItem === 'string'
|
|
18
|
-
? speciesItem
|
|
19
|
-
: speciesItem?.name || speciesItem?.species || `Species ${index + 1}`;
|
|
20
|
-
|
|
21
|
-
// Determine if species is selected/planted (you may need to adjust this logic)
|
|
22
|
-
const isSelected = typeof speciesItem === 'object'
|
|
23
|
-
? speciesItem?.selected !== false
|
|
24
|
-
: true;
|
|
25
|
-
|
|
12
|
+
if (Array.isArray(mangroveSpecies) && mangroveSpecies.length > 0) {
|
|
13
|
+
return mangroveSpecies.map((species) => {
|
|
14
|
+
const isPlanted = species.value === plantedSpecies;
|
|
26
15
|
return {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
16
|
+
label: species.label,
|
|
17
|
+
type: isPlanted ? 'compliant' : 'notCompliant',
|
|
18
|
+
statusIcon: isPlanted ? 'Check' : 'Close',
|
|
19
|
+
statusIconColor: isPlanted ? '#12B76A' : '#6C737F',
|
|
20
|
+
statusBadgeBackgroundColor: isPlanted ? undefined : '#F9FAFB',
|
|
21
|
+
statusBadgeBorderColor: isPlanted ? undefined : '#E5E7EB'
|
|
31
22
|
};
|
|
32
23
|
});
|
|
33
24
|
}
|
|
34
25
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
{ icon: 'Tree', label: 'Rhyzophora', type: 'notCompliant', statusIcon: 'Close' },
|
|
39
|
-
{ icon: 'Tree', label: 'Rhyzophora mangle', type: 'notCompliant', statusIcon: 'Close' }
|
|
40
|
-
];
|
|
41
|
-
}, [activityData]);
|
|
26
|
+
return []
|
|
27
|
+
|
|
28
|
+
}, [plantedSpecies, mangroveSpecies]);
|
|
42
29
|
|
|
43
30
|
return (
|
|
44
31
|
<ActivityIndicators
|
|
@@ -2,29 +2,26 @@ import React, { useMemo } from 'react';
|
|
|
2
2
|
import { Widget, ColumnChart } from '../../../../../../../../../../src/index.js';
|
|
3
3
|
|
|
4
4
|
const SeedlingsHeight = ({
|
|
5
|
-
|
|
5
|
+
averageHeight,
|
|
6
|
+
averageHeightUnit,
|
|
6
7
|
loading = false,
|
|
7
8
|
t = (s) => s
|
|
8
9
|
}) => {
|
|
9
10
|
const heightData = useMemo(() => {
|
|
10
11
|
// Extract seedlings height from activityData
|
|
11
12
|
// Assuming the data might have averageHeight, seedlingsHeight, or similar
|
|
12
|
-
const averageHeight = activityData?.averageHeight ||
|
|
13
|
-
activityData?.seedlingsHeight ||
|
|
14
|
-
activityData?.mangroveAverageHeight ||
|
|
15
|
-
28; // Default from image
|
|
16
|
-
|
|
17
13
|
const heightValue = typeof averageHeight === 'number'
|
|
18
14
|
? averageHeight
|
|
19
|
-
: parseFloat(averageHeight) ||
|
|
15
|
+
: parseFloat(averageHeight) || 0;
|
|
20
16
|
|
|
21
17
|
return [
|
|
22
18
|
{
|
|
23
19
|
label: t("Average Height"),
|
|
24
|
-
value: heightValue
|
|
20
|
+
value: heightValue,
|
|
21
|
+
unit: averageHeightUnit
|
|
25
22
|
}
|
|
26
23
|
];
|
|
27
|
-
}, [
|
|
24
|
+
}, [averageHeight, averageHeightUnit,t]);
|
|
28
25
|
|
|
29
26
|
const renderTooltipContent = useMemo(() => {
|
|
30
27
|
return (title, data) => {
|
|
@@ -41,26 +38,26 @@ const SeedlingsHeight = ({
|
|
|
41
38
|
}
|
|
42
39
|
|
|
43
40
|
const item = data[0];
|
|
44
|
-
const
|
|
41
|
+
const rawValue = item?.value || item?.data?.value || 0;
|
|
42
|
+
const value = Number(rawValue) || 0;
|
|
43
|
+
const formattedValue = Number(value).toLocaleString('en-us');
|
|
45
44
|
|
|
46
45
|
return {
|
|
47
46
|
title: t("Average Height"),
|
|
48
47
|
items: [
|
|
49
48
|
{
|
|
50
49
|
label: t("Average Height"),
|
|
51
|
-
value: `${
|
|
52
|
-
color: '#00AEB1'
|
|
50
|
+
value: `${formattedValue} ${averageHeightUnit || 'cm'}`,
|
|
51
|
+
color: '#00AEB1',
|
|
53
52
|
}
|
|
54
53
|
]
|
|
55
54
|
};
|
|
56
55
|
};
|
|
57
|
-
}, [t]);
|
|
56
|
+
}, [t, averageHeightUnit]);
|
|
58
57
|
|
|
59
58
|
const isEmpty = useMemo(() => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
!activityData?.mangroveAverageHeight;
|
|
63
|
-
}, [activityData]);
|
|
59
|
+
return !averageHeight && averageHeight !== 0;
|
|
60
|
+
}, [averageHeight]);
|
|
64
61
|
|
|
65
62
|
return (
|
|
66
63
|
<Widget
|
|
@@ -68,20 +65,11 @@ const SeedlingsHeight = ({
|
|
|
68
65
|
title={t("Seedlings Height")}
|
|
69
66
|
className="with-border-header h-w-btn-header"
|
|
70
67
|
>
|
|
71
|
-
<div
|
|
72
|
-
style={{
|
|
73
|
-
display: 'flex',
|
|
74
|
-
flexDirection: 'column',
|
|
75
|
-
minHeight: '250px',
|
|
76
|
-
padding: '20px 0'
|
|
77
|
-
}}
|
|
78
|
-
>
|
|
79
68
|
<ColumnChart
|
|
80
69
|
data={isEmpty ? [] : heightData}
|
|
81
70
|
xFieldKey="label"
|
|
82
71
|
yFieldKey="value"
|
|
83
72
|
color="#00AEB1"
|
|
84
|
-
height={250}
|
|
85
73
|
animated={true}
|
|
86
74
|
renderTooltipContent={renderTooltipContent}
|
|
87
75
|
yAxis={{
|
|
@@ -89,7 +77,7 @@ const SeedlingsHeight = ({
|
|
|
89
77
|
max: 35,
|
|
90
78
|
tickMethod: () => [0, 5, 10, 15, 20, 25, 30, 35],
|
|
91
79
|
label: {
|
|
92
|
-
formatter: (v) => `${v}cm`
|
|
80
|
+
formatter: (v) => `${v} ${averageHeightUnit || 'cm'}`
|
|
93
81
|
}
|
|
94
82
|
}}
|
|
95
83
|
xAxis={{
|
|
@@ -103,16 +91,15 @@ const SeedlingsHeight = ({
|
|
|
103
91
|
/>
|
|
104
92
|
{!isEmpty && (
|
|
105
93
|
<div style={{
|
|
106
|
-
|
|
94
|
+
marginTop: '16px',
|
|
107
95
|
textAlign: 'center',
|
|
108
96
|
fontSize: '14px',
|
|
109
97
|
color: '#475467',
|
|
110
98
|
fontWeight: 500
|
|
111
99
|
}}>
|
|
112
|
-
{t("Average Height")}: {heightData[0]?.value.toFixed(0)}cm
|
|
113
100
|
</div>
|
|
114
101
|
)}
|
|
115
|
-
|
|
102
|
+
|
|
116
103
|
</Widget>
|
|
117
104
|
);
|
|
118
105
|
};
|
|
@@ -2,65 +2,62 @@ import React, { useMemo } from 'react';
|
|
|
2
2
|
import { Widget, DonutPie } from '../../../../../../../../../../src/index.js';
|
|
3
3
|
|
|
4
4
|
const SurvivalRate = ({
|
|
5
|
-
|
|
5
|
+
survivalRate,
|
|
6
6
|
loading = false,
|
|
7
7
|
t = (s) => s
|
|
8
8
|
}) => {
|
|
9
9
|
const survivalData = useMemo(() => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const survivalPercent = typeof survivalRate === 'number' ? survivalRate : parseFloat(survivalRate) || 78;
|
|
10
|
+
if (!survivalRate && survivalRate !== 0) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
14
13
|
|
|
15
14
|
return [
|
|
16
15
|
{
|
|
17
16
|
type: t("Survival Rate"),
|
|
18
|
-
value:
|
|
17
|
+
value: Math.round(survivalRate || 0)
|
|
19
18
|
},
|
|
20
19
|
{
|
|
21
20
|
type: t("Non-survival"),
|
|
22
|
-
value: 100 -
|
|
21
|
+
value: 100 - Math.round(survivalRate || 0)
|
|
23
22
|
}
|
|
24
23
|
];
|
|
25
|
-
}, [
|
|
24
|
+
}, [survivalRate, t]);
|
|
26
25
|
|
|
27
26
|
const renderTooltipContent = useMemo(() => {
|
|
28
27
|
return (title, data) => {
|
|
29
|
-
if (!data || data.length === 0) {
|
|
28
|
+
if (!survivalData || survivalData.length === 0 || !data || data.length === 0) {
|
|
30
29
|
return {
|
|
31
30
|
title: t("Survival Rate"),
|
|
32
31
|
items: [
|
|
33
32
|
{
|
|
34
|
-
label: t("
|
|
33
|
+
label: t("Not answered"),
|
|
35
34
|
value: '-'
|
|
36
35
|
}
|
|
37
36
|
]
|
|
38
37
|
};
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
const item = data[0];
|
|
42
|
-
const value = item?.value || item?.data?.value || 0;
|
|
43
|
-
const itemType = item?.type || item?.data?.type || t("Survival Rate");
|
|
44
|
-
|
|
45
|
-
// Determine color based on item type
|
|
46
|
-
const itemColor = itemType === t("Survival Rate") ? '#00AEB1' : '#E8EDF3';
|
|
47
|
-
|
|
48
40
|
return {
|
|
49
41
|
title: t("Survival Rate"),
|
|
50
|
-
items:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
]
|
|
42
|
+
items: survivalData.map((item) => ({
|
|
43
|
+
label: item.type,
|
|
44
|
+
value: item.value + '%',
|
|
45
|
+
color: item.type === t("Survival Rate") ? '#00AEB1' : '#E8EDF3'
|
|
46
|
+
})),
|
|
57
47
|
};
|
|
58
48
|
};
|
|
59
|
-
}, [t]);
|
|
49
|
+
}, [survivalData, t]);
|
|
60
50
|
|
|
61
51
|
const isEmpty = useMemo(() => {
|
|
62
|
-
return !
|
|
63
|
-
}, [
|
|
52
|
+
return !survivalRate && survivalRate !== 0;
|
|
53
|
+
}, [survivalRate]);
|
|
54
|
+
|
|
55
|
+
const chartColors = useMemo(() => {
|
|
56
|
+
if (isEmpty) {
|
|
57
|
+
return ['#E5E7EB', '#F9FAFB'];
|
|
58
|
+
}
|
|
59
|
+
return ['#00AEB1', '#E8EDF3'];
|
|
60
|
+
}, [isEmpty]);
|
|
64
61
|
|
|
65
62
|
return (
|
|
66
63
|
<Widget
|
|
@@ -68,24 +65,20 @@ const SurvivalRate = ({
|
|
|
68
65
|
title={t("Survival Rate")}
|
|
69
66
|
className="with-border-header h-w-btn-header"
|
|
70
67
|
>
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
showTitle: false
|
|
86
|
-
}}
|
|
87
|
-
/> */}
|
|
88
|
-
|
|
68
|
+
<DonutPie
|
|
69
|
+
angleField="value"
|
|
70
|
+
color={chartColors}
|
|
71
|
+
colorField="type"
|
|
72
|
+
data={isEmpty ? [] : survivalData}
|
|
73
|
+
height={250}
|
|
74
|
+
innerRadius={0.78}
|
|
75
|
+
radius={1}
|
|
76
|
+
renderTooltipContent={renderTooltipContent}
|
|
77
|
+
tooltip
|
|
78
|
+
tooltipConfig={{
|
|
79
|
+
showTitle: false
|
|
80
|
+
}}
|
|
81
|
+
/>
|
|
89
82
|
</Widget>
|
|
90
83
|
);
|
|
91
84
|
};
|
package/src/@daf/pages/Summary/Activities/Monitoring/components/MangroveGrowthAndSurvival/index.jsx
CHANGED
|
@@ -3,48 +3,127 @@ import PlantedSpecies from './components/PlantedSpecies/index.jsx';
|
|
|
3
3
|
import SurvivalRate from './components/SurvivalRate/index.jsx';
|
|
4
4
|
import SeedlingsHeight from './components/SeedlingsHeight/index.jsx';
|
|
5
5
|
import styled from 'styled-components';
|
|
6
|
-
import { Widget } from '../../../../../../../../src/index.js';
|
|
6
|
+
import { Widget, VegetationHealth } from '../../../../../../../../src/index.js';
|
|
7
|
+
import { VEGETATION_KEYS } from '../../../../../../../../src/constants/Vegetation.js';
|
|
7
8
|
|
|
8
9
|
const Container = styled.div`
|
|
9
10
|
display: grid;
|
|
10
|
-
grid-template-columns: repeat(
|
|
11
|
+
grid-template-columns: repeat(3, 1fr);
|
|
12
|
+
gap: 24px;
|
|
13
|
+
width: 100%;
|
|
14
|
+
overflow-x: auto;
|
|
15
|
+
|
|
16
|
+
> * {
|
|
17
|
+
min-width: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@media (max-width: 768px) {
|
|
21
|
+
grid-template-columns: repeat(3, minmax(200px, 1fr));
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
const VegetationHealthContainer = styled.div`
|
|
26
|
+
display: flex;
|
|
11
27
|
gap: 24px;
|
|
12
28
|
width: 100%;
|
|
13
29
|
|
|
14
30
|
@media (max-width: 768px) {
|
|
15
|
-
|
|
31
|
+
flex-direction: column;
|
|
16
32
|
}
|
|
17
33
|
`;
|
|
18
34
|
|
|
35
|
+
const VegetationHealthSection = styled.section`
|
|
36
|
+
width: 66%;
|
|
37
|
+
`;
|
|
38
|
+
|
|
19
39
|
const MangroveGrowthAndSurvival = ({
|
|
20
40
|
activityData,
|
|
21
41
|
loading = false,
|
|
22
|
-
t = (s) => s
|
|
42
|
+
t = (s) => s,
|
|
43
|
+
options
|
|
23
44
|
}) => {
|
|
45
|
+
|
|
24
46
|
return (
|
|
25
47
|
|
|
26
48
|
<Widget
|
|
27
|
-
title={t("Mangrove Growth
|
|
49
|
+
title={t("Mangrove Growth and Survival")}
|
|
28
50
|
className="with-border-header h-w-btn-header"
|
|
29
51
|
>
|
|
30
52
|
<section>
|
|
53
|
+
|
|
54
|
+
|
|
31
55
|
<Container>
|
|
32
56
|
<PlantedSpecies
|
|
33
|
-
|
|
57
|
+
plantedSpecies={activityData?.plantedSpecies}
|
|
58
|
+
mangroveSpecies={options?.mangroveSpecies}
|
|
34
59
|
loading={loading}
|
|
35
60
|
t={t}
|
|
36
61
|
/>
|
|
37
62
|
<SurvivalRate
|
|
38
|
-
|
|
63
|
+
survivalRate={activityData?.survivalRate}
|
|
39
64
|
loading={loading}
|
|
40
65
|
t={t}
|
|
41
66
|
/>
|
|
42
67
|
<SeedlingsHeight
|
|
43
|
-
|
|
68
|
+
averageHeight={activityData?.averageHeightValue}
|
|
69
|
+
averageHeightUnit={activityData?.averageHeightUnit}
|
|
44
70
|
loading={loading}
|
|
45
71
|
t={t}
|
|
46
72
|
/>
|
|
47
73
|
</Container>
|
|
74
|
+
|
|
75
|
+
<VegetationHealthContainer>
|
|
76
|
+
<VegetationHealthSection>
|
|
77
|
+
<VegetationHealth
|
|
78
|
+
title={t("Vegetation Health")}
|
|
79
|
+
vegetationHealthChart={activityData?.growthObservations}
|
|
80
|
+
growthObservations={activityData?.growthObservations}
|
|
81
|
+
filterKeys={[
|
|
82
|
+
VEGETATION_KEYS.HEALTHY,
|
|
83
|
+
VEGETATION_KEYS.WHITE_SPOTS,
|
|
84
|
+
VEGETATION_KEYS.BLACK_SPOTS,
|
|
85
|
+
VEGETATION_KEYS.REDDISH_SPOTS,
|
|
86
|
+
VEGETATION_KEYS.YELLOWING,
|
|
87
|
+
VEGETATION_KEYS.MOSAIC,
|
|
88
|
+
VEGETATION_KEYS.DRY_OR_DEAD,
|
|
89
|
+
VEGETATION_KEYS.NO_LEAVES
|
|
90
|
+
]}
|
|
91
|
+
columnsPerRow={4}
|
|
92
|
+
itemWidth={80}
|
|
93
|
+
itemHeight={80}
|
|
94
|
+
activeVegetationConditions={
|
|
95
|
+
activityData?.vegetationHealthChart
|
|
96
|
+
?.filter(item =>
|
|
97
|
+
item?.type !== VEGETATION_KEYS.SPIDER_WEBS &&
|
|
98
|
+
item?.type !== VEGETATION_KEYS.DAMAGE_FROM_INSECTS
|
|
99
|
+
)
|
|
100
|
+
?.map(item => item?.type) || []
|
|
101
|
+
}
|
|
102
|
+
loading={loading}
|
|
103
|
+
t={t}
|
|
104
|
+
/>
|
|
105
|
+
</VegetationHealthSection>
|
|
106
|
+
|
|
107
|
+
<VegetationHealth
|
|
108
|
+
title={t("Vegetation Health")}
|
|
109
|
+
growthObservations={activityData?.growthObservations}
|
|
110
|
+
activeVegetationConditions={
|
|
111
|
+
activityData?.vegetationHealthChart
|
|
112
|
+
?.filter(item =>
|
|
113
|
+
item?.type === VEGETATION_KEYS.SPIDER_WEBS ||
|
|
114
|
+
item?.type === VEGETATION_KEYS.DAMAGE_FROM_INSECTS
|
|
115
|
+
)
|
|
116
|
+
?.map(item => item?.type) || []
|
|
117
|
+
}
|
|
118
|
+
filterKeys={[VEGETATION_KEYS.SPIDER_WEBS, VEGETATION_KEYS.DAMAGE_FROM_INSECTS]}
|
|
119
|
+
columnsPerRow={1}
|
|
120
|
+
itemWidth={210}
|
|
121
|
+
itemHeight={105}
|
|
122
|
+
loading={loading}
|
|
123
|
+
t={t}
|
|
124
|
+
/>
|
|
125
|
+
|
|
126
|
+
</VegetationHealthContainer>
|
|
48
127
|
</section>
|
|
49
128
|
</Widget>
|
|
50
129
|
);
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { camelCaseToTitle } from "../../../../../utils";
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { camelCaseToTitle, findOptions, renderNumber } from "../../../../../utils";
|
|
5
3
|
|
|
6
4
|
export const getKeyIndicatorsRowConfig = ({ t, data = {} }) => [
|
|
7
5
|
|
|
@@ -22,7 +20,7 @@ export const getKeyIndicatorsRowConfig = ({ t, data = {} }) => [
|
|
|
22
20
|
},
|
|
23
21
|
{
|
|
24
22
|
label: t('Monitored Area'),
|
|
25
|
-
render: () => <div>{data?.totalAreaParcelMonitored ? `${data?.totalAreaParcelMonitored} ha` : '0 ha'}</div>
|
|
23
|
+
render: () => <div>{data?.totalAreaParcelMonitored ? `${renderNumber(data?.totalAreaParcelMonitored)} ha` : '0 ha'}</div>
|
|
26
24
|
},
|
|
27
25
|
|
|
28
26
|
];
|
|
@@ -49,3 +47,22 @@ export const getSiteConditionsConfig = ({ t, data = {} }) => [
|
|
|
49
47
|
render: () => <div>{data?.hasDisturbances ? t('Yes') : t('No')}</div>
|
|
50
48
|
},
|
|
51
49
|
];
|
|
50
|
+
|
|
51
|
+
export const getEnvironmentalMetricsConfig = ({ t, data = {}, options }) => [
|
|
52
|
+
{
|
|
53
|
+
label: t('Soil Type'),
|
|
54
|
+
render: () => <div>{camelCaseToTitle(data?.soilType) || '-'}</div>
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
label: t('Soil Salinity'),
|
|
58
|
+
render: () => <div>{data?.soilSalinity ? `${ renderNumber(data.soilSalinity)} ${data?.soilSalinityUnit || 'dS/m'}` : '-'}</div>
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
label: t('pH Level'),
|
|
62
|
+
render: () => <div>{renderNumber(data?.phLevel) || '-'}</div>
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
label: t('Water Quality'),
|
|
66
|
+
render: () => <div>{ findOptions(data?.waterQuality, options?.waterQuality) || '-'}</div>
|
|
67
|
+
},
|
|
68
|
+
];
|