datastake-daf 0.6.774 → 0.6.776
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 +2583 -2504
- package/dist/hooks/index.js +0 -72
- package/dist/pages/index.js +1769 -835
- package/dist/style/datastake/mapbox-gl.css +330 -0
- package/dist/utils/index.js +0 -13
- package/package.json +1 -1
- package/src/@daf/core/components/Dashboard/Map/ChainIcon/Markers/StakeholderMarker.js +76 -8
- package/src/@daf/core/components/Dashboard/Map/ChainIcon/index.js +8 -116
- package/src/@daf/core/components/Dashboard/Map/ChainIcon/utils.js +17 -73
- package/src/@daf/core/components/Dashboard/Map/helper.js +0 -1
- package/src/@daf/core/components/Dashboard/Map/hook.js +29 -53
- package/src/@daf/core/components/Dashboard/Map/style.js +5 -20
- package/src/@daf/hooks/useTimeFilter.js +56 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/AssociatedInformation/config.js +548 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/AssociatedInformation/index.jsx +137 -24
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CommunityParticipation/JobsTimeline/index.jsx +33 -102
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleIndicators/HealthAndSafety/helper.js +8 -6
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleIndicators/HealthAndSafety/index.jsx +73 -4
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleIndicators/index.jsx +1 -1
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleOutcomes/PlantingActivitiesTimeline.jsx +148 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleOutcomes/RestoredArea.jsx +150 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleOutcomes/index.jsx +11 -390
- package/src/@daf/pages/Summary/Activities/PlantingCycle/index.jsx +3 -4
- package/src/@daf/utils/object.js +1 -3
- package/src/@daf/utils/timeFilterUtils.js +226 -0
- package/src/hooks.js +1 -2
- package/src/utils.js +1 -1
|
@@ -5,14 +5,13 @@ const VILLAGE = "village";
|
|
|
5
5
|
const EXPORTER = "exporter";
|
|
6
6
|
const PROCESSOR = "mineralProcessor";
|
|
7
7
|
const DEPOT = "depot";
|
|
8
|
-
const OPERATOR = "miningOperator";
|
|
9
8
|
|
|
10
9
|
const MAX_EXTRA_SMALL_ZOOM_THRESHOLD = 2;
|
|
11
10
|
const MAX_SMALL_ZOOM_THRESHOLD = 3;
|
|
12
11
|
const MAX_MEDIUM_ZOOM_THRESHOLD = 6;
|
|
13
12
|
|
|
14
13
|
const LOCATION_TYPES = [MINE_SITE, VILLAGE];
|
|
15
|
-
const STAKEHOLDER_TYPES = [EXPORTER, PROCESSOR, DEPOT
|
|
14
|
+
const STAKEHOLDER_TYPES = [EXPORTER, PROCESSOR, DEPOT];
|
|
16
15
|
|
|
17
16
|
const RADIUS_SMALL = 15;
|
|
18
17
|
const RADIUS_MEDIUM = 35;
|
|
@@ -101,6 +100,7 @@ export function getStakeholderPosition({ zoom, totalMarkers, markerIndex }) {
|
|
|
101
100
|
|
|
102
101
|
let radius;
|
|
103
102
|
let center = {
|
|
103
|
+
// NOT BEING USED FOR NOW AND MAYBE NEVER
|
|
104
104
|
left: 0,
|
|
105
105
|
top: 0,
|
|
106
106
|
};
|
|
@@ -117,32 +117,6 @@ export function getStakeholderPosition({ zoom, totalMarkers, markerIndex }) {
|
|
|
117
117
|
return { x, y, center, radius, angleDeg };
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
function applyAnimationDirect(el, isShortLink) {
|
|
121
|
-
if (!(el instanceof SVGElement) || isShortLink) return;
|
|
122
|
-
|
|
123
|
-
el.style.strokeDasharray = "10, 10";
|
|
124
|
-
el.style.strokeDashoffset = "0";
|
|
125
|
-
|
|
126
|
-
el.style.animation = "dash-flow 1.2s linear infinite";
|
|
127
|
-
|
|
128
|
-
el.classList.add('animated-polyline');
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function removeAnimationFromElement(element) {
|
|
132
|
-
if (!element) return;
|
|
133
|
-
|
|
134
|
-
element.classList.remove('animated-polyline');
|
|
135
|
-
element.style.animation = '';
|
|
136
|
-
element.style.strokeDasharray = '';
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function applyAnimationToPolyline(polyline, isShortLink) {
|
|
140
|
-
const element = polyline.getElement();
|
|
141
|
-
if (element) {
|
|
142
|
-
applyAnimationDirect(element, isShortLink);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
120
|
export function createPolyline({
|
|
147
121
|
L,
|
|
148
122
|
startLatLng,
|
|
@@ -153,62 +127,32 @@ export function createPolyline({
|
|
|
153
127
|
listOfPolylines = [],
|
|
154
128
|
isFromStakeholder = false,
|
|
155
129
|
isForceOpen = false,
|
|
156
|
-
stakeholderType = null,
|
|
157
|
-
animated = false,
|
|
158
|
-
mapRef
|
|
159
130
|
}) {
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
const isShortLink = stakeholderType === OPERATOR || isFromStakeholder;
|
|
163
|
-
const shouldAnimate = animated;
|
|
131
|
+
const width = isFromStakeholder && isExtraSmallMarker(zoom) && !isForceOpen ? 0 : 1.2;
|
|
164
132
|
|
|
165
|
-
const
|
|
133
|
+
const coordinates = [
|
|
166
134
|
[startLatLng.lat, startLatLng.lng],
|
|
167
135
|
[endLatLng.lat, endLatLng.lng],
|
|
168
136
|
];
|
|
169
|
-
|
|
170
|
-
const polylineStyle = {
|
|
137
|
+
const style = {
|
|
171
138
|
color: "var(--base-gray-70)",
|
|
172
|
-
weight:
|
|
173
|
-
opacity:
|
|
174
|
-
smoothFactor:
|
|
139
|
+
weight: width,
|
|
140
|
+
opacity: 0.5,
|
|
141
|
+
smoothFactor: 1,
|
|
175
142
|
id,
|
|
176
|
-
dashArray:
|
|
177
|
-
renderer: L.svg()
|
|
143
|
+
dashArray: !isSelected ? "5, 5" : "0, 0",
|
|
178
144
|
};
|
|
179
145
|
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
if (existingPolyline) {
|
|
183
|
-
removeAnimationFromElement(existingPolyline.getElement());
|
|
184
|
-
|
|
185
|
-
existingPolyline.setLatLngs(lineCoordinates);
|
|
186
|
-
existingPolyline.setStyle(polylineStyle);
|
|
187
|
-
|
|
188
|
-
if (shouldAnimate && isSelected) {
|
|
189
|
-
existingPolyline.once('add', () => {
|
|
190
|
-
applyAnimationToPolyline(existingPolyline, isShortLink);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
applyAnimationToPolyline(existingPolyline, isShortLink);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return existingPolyline;
|
|
197
|
-
}
|
|
146
|
+
const newPolyline = L.polyline(coordinates, style);
|
|
198
147
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
newPolyline.once('add', () => {
|
|
206
|
-
applyAnimationToPolyline(newPolyline, isShortLink);
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
applyAnimationToPolyline(newPolyline, isShortLink);
|
|
148
|
+
if (listOfPolylines.find((p) => p.options.id === id)) {
|
|
149
|
+
const polylineToUpdateCoordinates = listOfPolylines.find((p) => p.options.id === id);
|
|
150
|
+
polylineToUpdateCoordinates.setLatLngs(coordinates);
|
|
151
|
+
polylineToUpdateCoordinates.setStyle(style);
|
|
152
|
+
} else {
|
|
153
|
+
listOfPolylines.push(newPolyline);
|
|
210
154
|
}
|
|
211
|
-
|
|
155
|
+
|
|
212
156
|
return newPolyline;
|
|
213
157
|
}
|
|
214
158
|
|
|
@@ -31,7 +31,7 @@ export const useMap = ({
|
|
|
31
31
|
const container = createRef();
|
|
32
32
|
const [data, setData] = useState([]);
|
|
33
33
|
const [mapRef, setMapRef] = useState(null);
|
|
34
|
-
const { TILE_LAYER_URL, MAP_TOKEN } = useMapConfig({ app, isSatellite
|
|
34
|
+
const { TILE_LAYER_URL, MAP_TOKEN } = useMapConfig({ app, isSatellite });
|
|
35
35
|
const [initialMarkerSetIsDone, setInitialMarkerSetIsDone] = useState(false);
|
|
36
36
|
const [mapCenter, setMapCenter] = useState([0, 0]);
|
|
37
37
|
const [emptyStateIsVisible, setEmptyStateIsVisible] = useState(false);
|
|
@@ -48,7 +48,6 @@ export const useMap = ({
|
|
|
48
48
|
const stakeToLoc = new Map();
|
|
49
49
|
const nodeTypes = new Map();
|
|
50
50
|
|
|
51
|
-
// Build the graph
|
|
52
51
|
for (const loc of data) {
|
|
53
52
|
const locId = loc.datastakeId;
|
|
54
53
|
nodeTypes.set(locId, loc.type);
|
|
@@ -82,45 +81,34 @@ export const useMap = ({
|
|
|
82
81
|
|
|
83
82
|
const highlightTable = {};
|
|
84
83
|
|
|
85
|
-
// Perform BFS/DFS to find all connected nodes in the entire chain
|
|
86
84
|
for (const [node] of graph) {
|
|
87
85
|
const highlighted = new Set();
|
|
88
|
-
const queue = [node];
|
|
89
|
-
const visited = new Set([node]);
|
|
90
86
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
visited.add(parentLoc);
|
|
102
|
-
queue.push(parentLoc);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
87
|
+
highlighted.add(node);
|
|
88
|
+
|
|
89
|
+
const nodeIsStakeholder = !isLocation(nodeTypes.get(node));
|
|
90
|
+
if (nodeIsStakeholder && stakeToLoc.has(node)) {
|
|
91
|
+
const parentLoc = stakeToLoc.get(node);
|
|
92
|
+
highlighted.add(parentLoc);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
for (const neighbor of graph.get(node) || []) {
|
|
96
|
+
const neighborIsStakeholder = !isLocation(nodeTypes.get(neighbor));
|
|
105
97
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
98
|
+
if (neighborIsStakeholder && stakeToLoc.has(neighbor)) {
|
|
99
|
+
const neighborParent = stakeToLoc.get(neighbor);
|
|
100
|
+
|
|
101
|
+
if (
|
|
102
|
+
(isLocation(nodeTypes.get(node)) && neighborParent === node) ||
|
|
103
|
+
(nodeIsStakeholder && stakeToLoc.get(node) === neighborParent)
|
|
104
|
+
) {
|
|
105
|
+
highlighted.add(neighbor);
|
|
106
|
+
} else {
|
|
111
107
|
highlighted.add(neighbor);
|
|
112
|
-
|
|
113
|
-
// If neighbor is stakeholder, add its parent location
|
|
114
|
-
const neighborIsStakeholder = !isLocation(nodeTypes.get(neighbor));
|
|
115
|
-
if (neighborIsStakeholder && stakeToLoc.has(neighbor)) {
|
|
116
|
-
const neighborParent = stakeToLoc.get(neighbor);
|
|
117
|
-
if (!visited.has(neighborParent)) {
|
|
118
|
-
highlighted.add(neighborParent);
|
|
119
|
-
visited.add(neighborParent);
|
|
120
|
-
queue.push(neighborParent);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
108
|
+
highlighted.add(neighborParent);
|
|
123
109
|
}
|
|
110
|
+
} else {
|
|
111
|
+
highlighted.add(neighbor);
|
|
124
112
|
}
|
|
125
113
|
}
|
|
126
114
|
|
|
@@ -203,22 +191,12 @@ export const useMap = ({
|
|
|
203
191
|
});
|
|
204
192
|
}
|
|
205
193
|
}
|
|
206
|
-
|
|
207
|
-
if (type === "chain" && selectedMarkersId.length === 0) {
|
|
208
|
-
if (polylinesRef.current.length) {
|
|
209
|
-
polylinesRef.current.forEach((polyline) => {
|
|
210
|
-
if (mapRef.hasLayer(polyline)) {
|
|
211
|
-
mapRef.removeLayer(polyline);
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
polylinesRef.current = [];
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
194
|
clearMapMarkers();
|
|
219
195
|
if (data) {
|
|
196
|
+
// Filters out locations that are not connected to any stakeholders
|
|
197
|
+
const excludedType = ['village', 'town', 'area', 'territory']
|
|
220
198
|
const filteredData = data?.filter((obj) =>
|
|
221
|
-
obj
|
|
199
|
+
!excludedType.includes(obj?.type) && (obj?.stakeholders?.length > 0 ||
|
|
222
200
|
data.some((other) =>
|
|
223
201
|
other.datastakeId !== obj.datastakeId &&
|
|
224
202
|
(other.stakeholders || []).some((stk) =>
|
|
@@ -240,11 +218,9 @@ export const useMap = ({
|
|
|
240
218
|
);
|
|
241
219
|
});
|
|
242
220
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
});
|
|
247
|
-
}
|
|
221
|
+
polylinesRef.current.forEach((polyline) => {
|
|
222
|
+
mapRef.addLayer(polyline);
|
|
223
|
+
});
|
|
248
224
|
|
|
249
225
|
mapRef.invalidateSize();
|
|
250
226
|
mapRef.fire("moveend");
|
|
@@ -7,8 +7,6 @@ const Style = styled.div`
|
|
|
7
7
|
width: 100%;
|
|
8
8
|
height: 472px;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
10
|
.filter-cont {
|
|
13
11
|
position: absolute;
|
|
14
12
|
top: 24px;
|
|
@@ -111,24 +109,11 @@ const Style = styled.div`
|
|
|
111
109
|
align-items: center;
|
|
112
110
|
}
|
|
113
111
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
.animated-polyline {
|
|
121
|
-
stroke-dasharray: 10 10;
|
|
122
|
-
animation: dash-flow 1.5s linear infinite;
|
|
123
|
-
stroke-linecap: round;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
@keyframes dash-flow {
|
|
127
|
-
to {
|
|
128
|
-
stroke-dashoffset: -20;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
112
|
+
.marker-chain {
|
|
113
|
+
display: flex;
|
|
114
|
+
align-items: center;
|
|
115
|
+
justify-content: center;
|
|
116
|
+
}
|
|
132
117
|
|
|
133
118
|
}
|
|
134
119
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useState, useMemo, useCallback } from 'react';
|
|
2
|
+
import { getFormatDate, getTimeQuantity, processChartDateData, formatDateAxis } from '../utils/timeFilterUtils.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Custom hook for time filtering functionality
|
|
6
|
+
* Provides state management and formatting functions for time-based charts
|
|
7
|
+
*
|
|
8
|
+
* @param {Object} options - Configuration options
|
|
9
|
+
* @param {string} options.defaultFilter - Default time filter ('daily', 'weekly', 'monthly')
|
|
10
|
+
* @returns {Object} Time filter state and utilities
|
|
11
|
+
*/
|
|
12
|
+
export const useTimeFilter = ({ defaultFilter = 'monthly' } = {}) => {
|
|
13
|
+
const [timeFilter, setTimeFilter] = useState(defaultFilter);
|
|
14
|
+
|
|
15
|
+
// Memoized format date function bound to current timeFilter
|
|
16
|
+
const getFormatDateFn = useCallback(
|
|
17
|
+
(date, breakLine = false) => getFormatDate(date, breakLine, timeFilter),
|
|
18
|
+
[timeFilter]
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
// Memoized time quantity function bound to current timeFilter
|
|
22
|
+
const getTimeQuantityFn = useCallback(
|
|
23
|
+
() => getTimeQuantity(timeFilter),
|
|
24
|
+
[timeFilter]
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
// Memoized date axis formatter
|
|
28
|
+
const formatDateAxisFn = useMemo(
|
|
29
|
+
() => (label) => formatDateAxis(label, getFormatDateFn),
|
|
30
|
+
[getFormatDateFn]
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
// Process chart data with current time filter
|
|
34
|
+
const processData = useCallback(
|
|
35
|
+
({ mainData, filters = {}, isCumulative = false, valueField = 'total' }) => {
|
|
36
|
+
return processChartDateData({
|
|
37
|
+
mainData,
|
|
38
|
+
timeFilter,
|
|
39
|
+
filters,
|
|
40
|
+
isCumulative,
|
|
41
|
+
valueField,
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
[timeFilter]
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
timeFilter,
|
|
49
|
+
setTimeFilter,
|
|
50
|
+
getFormatDate: getFormatDateFn,
|
|
51
|
+
getTimeQuantity: getTimeQuantityFn,
|
|
52
|
+
formatDateAxis: formatDateAxisFn,
|
|
53
|
+
processChartDateData: processData,
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|