datastake-daf 0.6.784 → 0.6.785
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/dist/components/index.js +99 -99
- package/dist/pages/index.js +846 -65
- package/dist/style/datastake/mapbox-gl.css +330 -0
- package/dist/utils/index.js +58 -0
- package/package.json +1 -1
- package/src/@daf/pages/Summary/Activities/MonitoringCampaign/components/KeyInformation/index.jsx +48 -0
- package/src/@daf/pages/Summary/Activities/MonitoringCampaign/components/MangroveGrowth/PlantedSpecies.jsx +73 -0
- package/src/@daf/pages/Summary/Activities/MonitoringCampaign/components/MangroveGrowth/SeedlingsHeight.jsx +44 -0
- package/src/@daf/pages/Summary/Activities/MonitoringCampaign/components/MangroveGrowth/Stats.jsx +86 -0
- package/src/@daf/pages/Summary/Activities/MonitoringCampaign/components/MangroveGrowth/VegetationHealth.jsx +73 -0
- package/src/@daf/pages/Summary/Activities/MonitoringCampaign/components/MangroveGrowth/index.jsx +92 -0
- package/src/@daf/pages/Summary/Activities/MonitoringCampaign/components/MonitoringScopeAndFindings/index.jsx +348 -0
- package/src/@daf/pages/Summary/Activities/MonitoringCampaign/config.js +35 -0
- package/src/@daf/pages/Summary/Activities/MonitoringCampaign/index.jsx +30 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CommunityParticipation/CommunityStats/helper.js +1 -1
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleIndicators/index.jsx +1 -1
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleOutcomes/index.jsx +1 -1
- package/src/@daf/pages/Summary/Activities/PlantingCycle/helper.js +0 -56
- package/src/@daf/utils/numbers.js +57 -0
- package/src/pages.js +1 -0
- package/src/utils.js +1 -1
|
@@ -32,3 +32,60 @@ export const renderPercentage = (val) => {
|
|
|
32
32
|
|
|
33
33
|
return val + "%";
|
|
34
34
|
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Calculates stat change object for StatCard component based on current and previous values
|
|
38
|
+
* @param {Object} data - Object with current and previous values
|
|
39
|
+
* @param {number} data.current - Current value
|
|
40
|
+
* @param {number} data.previous - Previous value
|
|
41
|
+
* @param {Object} options - Optional configuration
|
|
42
|
+
* @param {string} options.tooltipText - Custom tooltip text
|
|
43
|
+
* @param {string} options.format - Format type: 'percentage' (default) or 'absolute'
|
|
44
|
+
* @param {number} options.decimalPlaces - Number of decimal places for percentage (default: 1)
|
|
45
|
+
* @returns {Object|null} Change object for StatCard or null if data is invalid
|
|
46
|
+
*/
|
|
47
|
+
export const calculateStatChange = (data, options = {}) => {
|
|
48
|
+
if (!data || typeof data !== 'object') {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const { current, previous } = data;
|
|
53
|
+
|
|
54
|
+
// Validate that both values are numbers
|
|
55
|
+
if (typeof current !== 'number' || typeof previous !== 'number') {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// If previous is 0, we can't calculate percentage change
|
|
60
|
+
if (previous === 0) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const {
|
|
65
|
+
tooltipText,
|
|
66
|
+
format = 'percentage',
|
|
67
|
+
decimalPlaces = 1,
|
|
68
|
+
} = options;
|
|
69
|
+
|
|
70
|
+
// Calculate the difference
|
|
71
|
+
const difference = current - previous;
|
|
72
|
+
const isPositive = difference >= 0;
|
|
73
|
+
const direction = isPositive ? 'up' : 'down';
|
|
74
|
+
|
|
75
|
+
// Format the value
|
|
76
|
+
let value;
|
|
77
|
+
if (format === 'absolute') {
|
|
78
|
+
// Show absolute difference
|
|
79
|
+
value = Math.abs(difference).toLocaleString();
|
|
80
|
+
} else {
|
|
81
|
+
// Show percentage change
|
|
82
|
+
const percentageChange = (Math.abs(difference) / previous) * 100;
|
|
83
|
+
value = `${percentageChange.toFixed(decimalPlaces)}%`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
value,
|
|
88
|
+
direction,
|
|
89
|
+
tooltipText: tooltipText || undefined,
|
|
90
|
+
};
|
|
91
|
+
};
|
package/src/pages.js
CHANGED
|
@@ -19,6 +19,7 @@ export { default as TablePage } from './@daf/pages/TablePage/index.jsx';
|
|
|
19
19
|
export { default as OperatorSummary } from './@daf/pages/Summary/Operator/index.jsx';
|
|
20
20
|
export { default as RestorationActivitySummary } from './@daf/pages/Summary/Activities/Restoration/index.jsx';
|
|
21
21
|
export { default as PlantingCycleSummary } from './@daf/pages/Summary/Activities/PlantingCycle/index.jsx';
|
|
22
|
+
export { default as MonitoringCampaignSummary } from './@daf/pages/Summary/Activities/MonitoringCampaign/index.jsx';
|
|
22
23
|
export { default as MineSummary } from './@daf/pages/Summary/Minesite/index.jsx';
|
|
23
24
|
|
|
24
25
|
// View
|
package/src/utils.js
CHANGED
|
@@ -31,7 +31,7 @@ export { convertUndefinedToNull, hasKeyInObject, removeKeysFromObject } from './
|
|
|
31
31
|
|
|
32
32
|
export { default as ErrorFormat, formatErrors } from './helpers/ErrorFormater'
|
|
33
33
|
|
|
34
|
-
export { renderNumber, renderPercentage } from "./@daf/utils/numbers.js"
|
|
34
|
+
export { renderNumber, renderPercentage, calculateStatChange } from "./@daf/utils/numbers.js"
|
|
35
35
|
|
|
36
36
|
export { MessageTypes, displayMessage} from './helpers/messages.js'
|
|
37
37
|
|