datastake-daf 0.6.777 → 0.6.778
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 +82 -78
- package/dist/pages/index.js +10 -26
- package/package.json +1 -1
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CommunityParticipation/JobsTimeline/index.jsx +5 -4
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleOutcomes/PlantingActivitiesTimeline.jsx +5 -7
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleOutcomes/RestoredArea.jsx +4 -8
- package/src/@daf/utils/timeFilterUtils.js +3 -6
package/dist/components/index.js
CHANGED
|
@@ -8486,22 +8486,20 @@ const useHeader = _ref => {
|
|
|
8486
8486
|
const {
|
|
8487
8487
|
useToken: useToken$m
|
|
8488
8488
|
} = antd.theme;
|
|
8489
|
-
function BreadCrumbs(
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
} = _ref;
|
|
8489
|
+
function BreadCrumbs({
|
|
8490
|
+
breadcrumbs = [],
|
|
8491
|
+
mainContWidth = 0
|
|
8492
|
+
}) {
|
|
8494
8493
|
const [splitIndex, setSplitIndex] = React.useState(0);
|
|
8495
8494
|
const {
|
|
8496
8495
|
token
|
|
8497
8496
|
} = useToken$m();
|
|
8498
|
-
const _renderBreadcrumb =
|
|
8499
|
-
let noOnClickLast = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
8497
|
+
const _renderBreadcrumb = (b, i, isLast, noOnClickLast = false) => {
|
|
8500
8498
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
8501
8499
|
className: "flex breadcrumb-item",
|
|
8502
|
-
onClick: noOnClickLast && isLast ? undefined : b
|
|
8500
|
+
onClick: noOnClickLast && isLast ? undefined : b?.onClick,
|
|
8503
8501
|
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
8504
|
-
children: b
|
|
8502
|
+
children: b?.label
|
|
8505
8503
|
}), !isLast && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
8506
8504
|
className: "flex flex-column justify-content-center",
|
|
8507
8505
|
children: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
|
|
@@ -8511,7 +8509,7 @@ function BreadCrumbs(_ref) {
|
|
|
8511
8509
|
color: token.baseGray50
|
|
8512
8510
|
})
|
|
8513
8511
|
})]
|
|
8514
|
-
},
|
|
8512
|
+
}, `breadcrumb-item-${i}`);
|
|
8515
8513
|
};
|
|
8516
8514
|
React.useEffect(() => {
|
|
8517
8515
|
const _placeholderCont = document.getElementById("header-breadcrumbs");
|
|
@@ -8554,7 +8552,7 @@ function BreadCrumbs(_ref) {
|
|
|
8554
8552
|
placement: "bottomRight",
|
|
8555
8553
|
menu: {
|
|
8556
8554
|
items: groupedBreadCrumbs[2].map((it, i) => ({
|
|
8557
|
-
key:
|
|
8555
|
+
key: `items-${i}`,
|
|
8558
8556
|
label: it.label,
|
|
8559
8557
|
onClick: it.onClick
|
|
8560
8558
|
}))
|
|
@@ -9546,24 +9544,29 @@ const processConditionalTableKeys = (tableKeys, item) => {
|
|
|
9546
9544
|
});
|
|
9547
9545
|
return processedKeys;
|
|
9548
9546
|
};
|
|
9549
|
-
const renderFieldData = (type, value, user, config
|
|
9547
|
+
const renderFieldData = function (type, value, user, config) {
|
|
9548
|
+
let getApiBaseUrl = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : () => {};
|
|
9549
|
+
let getAppHeader = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : () => {};
|
|
9550
|
+
let app = arguments.length > 6 ? arguments[6] : undefined;
|
|
9551
|
+
let allValues = arguments.length > 7 ? arguments[7] : undefined;
|
|
9552
|
+
let formValues = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : {};
|
|
9550
9553
|
switch (type) {
|
|
9551
9554
|
case 'year':
|
|
9552
9555
|
return value !== '-' ? renderDateFormatted(value, 'YYYY', 'en') : '-';
|
|
9553
9556
|
case 'date':
|
|
9554
9557
|
{
|
|
9555
|
-
const language = user
|
|
9558
|
+
const language = user !== null && user !== void 0 && user.language && (user === null || user === void 0 ? void 0 : user.language) === 'sp' ? 'es' : user === null || user === void 0 ? void 0 : user.language;
|
|
9556
9559
|
return value !== '-' ? renderDateFormatted(value, 'DD MMM YYYY', language || 'en') : '-';
|
|
9557
9560
|
}
|
|
9558
9561
|
case 'select':
|
|
9559
9562
|
{
|
|
9560
|
-
const options = config
|
|
9563
|
+
const options = (config === null || config === void 0 ? void 0 : config.options) || [];
|
|
9561
9564
|
const option = findOptions(value, options);
|
|
9562
9565
|
return option;
|
|
9563
9566
|
}
|
|
9564
9567
|
case 'multiselect':
|
|
9565
9568
|
{
|
|
9566
|
-
const options = config
|
|
9569
|
+
const options = (config === null || config === void 0 ? void 0 : config.options) || [];
|
|
9567
9570
|
const _val = typeof value === 'string' ? value.split(',').map(v => v.trim()) : value;
|
|
9568
9571
|
const option = findOptions(_val, options);
|
|
9569
9572
|
return option.join(', ');
|
|
@@ -9578,7 +9581,7 @@ const renderFieldData = (type, value, user, config, getApiBaseUrl = () => {}, ge
|
|
|
9578
9581
|
formValues: formValues
|
|
9579
9582
|
});
|
|
9580
9583
|
case 'percentage':
|
|
9581
|
-
return value === '-' || value === null || value === undefined ? '-' :
|
|
9584
|
+
return value === '-' || value === null || value === undefined ? '-' : "".concat(value, " %");
|
|
9582
9585
|
case 'geolocation':
|
|
9583
9586
|
{
|
|
9584
9587
|
const val = JSON.parse(value) || {};
|
|
@@ -9592,7 +9595,7 @@ const renderFieldData = (type, value, user, config, getApiBaseUrl = () => {}, ge
|
|
|
9592
9595
|
case 'upload':
|
|
9593
9596
|
case 'videoUpload':
|
|
9594
9597
|
{
|
|
9595
|
-
const documentName = allValues
|
|
9598
|
+
const documentName = allValues === null || allValues === void 0 ? void 0 : allValues.map(item => item === null || item === void 0 ? void 0 : item.name).join(', ');
|
|
9596
9599
|
return documentName;
|
|
9597
9600
|
}
|
|
9598
9601
|
default:
|
|
@@ -9600,25 +9603,27 @@ const renderFieldData = (type, value, user, config, getApiBaseUrl = () => {}, ge
|
|
|
9600
9603
|
}
|
|
9601
9604
|
};
|
|
9602
9605
|
|
|
9603
|
-
const renderValue =
|
|
9604
|
-
|
|
9605
|
-
|
|
9606
|
-
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
|
|
9610
|
-
|
|
9611
|
-
|
|
9612
|
-
|
|
9613
|
-
|
|
9614
|
-
|
|
9606
|
+
const renderValue = _ref => {
|
|
9607
|
+
let {
|
|
9608
|
+
value,
|
|
9609
|
+
hasChildren,
|
|
9610
|
+
config,
|
|
9611
|
+
user,
|
|
9612
|
+
getApiBaseUrl = () => {},
|
|
9613
|
+
getAppHeader = () => {},
|
|
9614
|
+
app,
|
|
9615
|
+
allData = {}
|
|
9616
|
+
} = _ref;
|
|
9617
|
+
if ((config === null || config === void 0 ? void 0 : config.type) === 'groupInputs') {
|
|
9618
|
+
if (!(config !== null && config !== void 0 && config.inputs)) return null;
|
|
9615
9619
|
const inputKeys = Object.keys(config.inputs).sort((a, b) => {
|
|
9616
|
-
|
|
9617
|
-
const
|
|
9620
|
+
var _config$inputs$a, _config$inputs$b;
|
|
9621
|
+
const positionA = ((_config$inputs$a = config.inputs[a]) === null || _config$inputs$a === void 0 ? void 0 : _config$inputs$a.position) || 0;
|
|
9622
|
+
const positionB = ((_config$inputs$b = config.inputs[b]) === null || _config$inputs$b === void 0 ? void 0 : _config$inputs$b.position) || 0;
|
|
9618
9623
|
return positionA - positionB;
|
|
9619
9624
|
});
|
|
9620
9625
|
const values = inputKeys.map(inputKey => {
|
|
9621
|
-
let inputValue = value
|
|
9626
|
+
let inputValue = value === null || value === void 0 ? void 0 : value[inputKey];
|
|
9622
9627
|
if (inputValue === null || inputValue === undefined || inputValue === '') {
|
|
9623
9628
|
return '';
|
|
9624
9629
|
} else if (typeof inputValue === 'object' && inputValue !== null) {
|
|
@@ -9659,8 +9664,8 @@ const renderValue = ({
|
|
|
9659
9664
|
} else {
|
|
9660
9665
|
displayValue = String(value);
|
|
9661
9666
|
}
|
|
9662
|
-
const fieldType = config
|
|
9663
|
-
let cssClass =
|
|
9667
|
+
const fieldType = (config === null || config === void 0 ? void 0 : config.type) || 'text';
|
|
9668
|
+
let cssClass = "tree-value ".concat(fieldType, "-type");
|
|
9664
9669
|
if (displayValue === '-') {
|
|
9665
9670
|
cssClass += ' empty';
|
|
9666
9671
|
}
|
|
@@ -9670,19 +9675,21 @@ const renderValue = ({
|
|
|
9670
9675
|
children: displayValue
|
|
9671
9676
|
});
|
|
9672
9677
|
};
|
|
9673
|
-
const determineHasChildren =
|
|
9674
|
-
|
|
9675
|
-
|
|
9676
|
-
|
|
9677
|
-
|
|
9678
|
+
const determineHasChildren = _ref2 => {
|
|
9679
|
+
var _config$meta;
|
|
9680
|
+
let {
|
|
9681
|
+
config,
|
|
9682
|
+
level
|
|
9683
|
+
} = _ref2;
|
|
9684
|
+
if ((config === null || config === void 0 ? void 0 : config.type) === 'groupInputs') {
|
|
9678
9685
|
return false;
|
|
9679
9686
|
}
|
|
9680
|
-
if (config
|
|
9687
|
+
if ((config === null || config === void 0 ? void 0 : config.type) === 'header' && config !== null && config !== void 0 && config.inputs && Object.keys(config.inputs).length > 0) {
|
|
9681
9688
|
return true;
|
|
9682
9689
|
}
|
|
9683
|
-
return config
|
|
9690
|
+
return (config === null || config === void 0 ? void 0 : config.inputs) || (config === null || config === void 0 ? void 0 : config.type) === 'group' || (config === null || config === void 0 ? void 0 : config.type) === 'dataLinkGroup' || (config === null || config === void 0 ? void 0 : config.type) === 'section' || (config === null || config === void 0 ? void 0 : config.type) === 'ajaxSubGroup' ||
|
|
9684
9691
|
// Add this line
|
|
9685
|
-
config
|
|
9692
|
+
(config === null || config === void 0 ? void 0 : config.type) === 'dataLink' && (config === null || config === void 0 || (_config$meta = config.meta) === null || _config$meta === void 0 ? void 0 : _config$meta.tableKeys) || level === 0 && config && typeof config === 'object' && Object.keys(config).some(key => key !== 'id' && key !== 'label' && key !== 'position' && key !== 'subTitle' && typeof config[key] === 'object' && config[key] !== null);
|
|
9686
9693
|
};
|
|
9687
9694
|
|
|
9688
9695
|
const sortByPosition = (items, getConfig) => {
|
|
@@ -9716,19 +9723,18 @@ const resolveDynamicLabel = (labelConfig, item, defaultLabel) => {
|
|
|
9716
9723
|
return labelConfig || defaultLabel;
|
|
9717
9724
|
};
|
|
9718
9725
|
|
|
9719
|
-
const handleSectionChildren =
|
|
9720
|
-
|
|
9721
|
-
|
|
9722
|
-
|
|
9723
|
-
|
|
9724
|
-
|
|
9725
|
-
|
|
9726
|
-
|
|
9727
|
-
|
|
9728
|
-
|
|
9729
|
-
|
|
9730
|
-
|
|
9731
|
-
} = _ref;
|
|
9726
|
+
const handleSectionChildren = ({
|
|
9727
|
+
config,
|
|
9728
|
+
allData,
|
|
9729
|
+
level,
|
|
9730
|
+
t,
|
|
9731
|
+
rootForm,
|
|
9732
|
+
user,
|
|
9733
|
+
getApiBaseUrl = () => {},
|
|
9734
|
+
getAppHeader = () => {},
|
|
9735
|
+
app,
|
|
9736
|
+
TreeNodeComponent
|
|
9737
|
+
}) => {
|
|
9732
9738
|
if (!(level === 0 && config && typeof config === 'object')) {
|
|
9733
9739
|
return null;
|
|
9734
9740
|
}
|
|
@@ -9742,14 +9748,14 @@ const handleSectionChildren = _ref => {
|
|
|
9742
9748
|
let fieldValue;
|
|
9743
9749
|
|
|
9744
9750
|
// Determine field value based on type
|
|
9745
|
-
if (fieldConfig.type === 'dataLinkGroup' && Array.isArray(allData
|
|
9751
|
+
if (fieldConfig.type === 'dataLinkGroup' && Array.isArray(allData?.[fieldKey])) {
|
|
9746
9752
|
fieldValue = allData[fieldKey];
|
|
9747
|
-
} else if (fieldConfig.type === 'dataLinkGroup' && allData
|
|
9753
|
+
} else if (fieldConfig.type === 'dataLinkGroup' && allData?.[fieldKey]) {
|
|
9748
9754
|
fieldValue = allData[fieldKey];
|
|
9749
9755
|
} else if (fieldConfig.type === 'group') {
|
|
9750
9756
|
fieldValue = {};
|
|
9751
9757
|
} else {
|
|
9752
|
-
fieldValue = allData
|
|
9758
|
+
fieldValue = allData?.[fieldKey];
|
|
9753
9759
|
}
|
|
9754
9760
|
return /*#__PURE__*/jsxRuntime.jsx(TreeNodeComponent, {
|
|
9755
9761
|
nodeKey: fieldKey,
|
|
@@ -9768,30 +9774,28 @@ const handleSectionChildren = _ref => {
|
|
|
9768
9774
|
});
|
|
9769
9775
|
};
|
|
9770
9776
|
|
|
9771
|
-
const handleArrayChildren =
|
|
9772
|
-
|
|
9773
|
-
|
|
9774
|
-
|
|
9775
|
-
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
-
|
|
9779
|
-
|
|
9780
|
-
|
|
9781
|
-
|
|
9782
|
-
|
|
9783
|
-
|
|
9784
|
-
|
|
9785
|
-
} = _ref;
|
|
9777
|
+
const handleArrayChildren = ({
|
|
9778
|
+
value,
|
|
9779
|
+
config,
|
|
9780
|
+
label,
|
|
9781
|
+
level,
|
|
9782
|
+
t,
|
|
9783
|
+
rootForm,
|
|
9784
|
+
allData,
|
|
9785
|
+
user,
|
|
9786
|
+
getApiBaseUrl = () => {},
|
|
9787
|
+
getAppHeader = () => {},
|
|
9788
|
+
app,
|
|
9789
|
+
TreeNodeComponent
|
|
9790
|
+
}) => {
|
|
9786
9791
|
if (!Array.isArray(value)) {
|
|
9787
9792
|
return null;
|
|
9788
9793
|
}
|
|
9789
9794
|
return value.map((item, itemIndex) => /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
9790
9795
|
className: "array-item",
|
|
9791
9796
|
children: Object.keys(config.inputs).sort((a, b) => {
|
|
9792
|
-
|
|
9793
|
-
const
|
|
9794
|
-
const positionB = ((_config$inputs$b = config.inputs[b]) === null || _config$inputs$b === void 0 ? void 0 : _config$inputs$b.position) || 0;
|
|
9797
|
+
const positionA = config.inputs[a]?.position || 0;
|
|
9798
|
+
const positionB = config.inputs[b]?.position || 0;
|
|
9795
9799
|
return positionA - positionB;
|
|
9796
9800
|
}).map(subInputKey => {
|
|
9797
9801
|
const subInputConfig = config.inputs[subInputKey];
|
|
@@ -9809,9 +9813,9 @@ const handleArrayChildren = _ref => {
|
|
|
9809
9813
|
getApiBaseUrl: getApiBaseUrl,
|
|
9810
9814
|
getAppHeader: getAppHeader,
|
|
9811
9815
|
app: app
|
|
9812
|
-
},
|
|
9816
|
+
}, `${itemIndex}-${subInputKey}`);
|
|
9813
9817
|
})
|
|
9814
|
-
},
|
|
9818
|
+
}, `${itemIndex}`));
|
|
9815
9819
|
};
|
|
9816
9820
|
|
|
9817
9821
|
const noDafApps = ['tif', 'cukura']; //PACKAGE_CHANGE_LATER (remove sbg)
|
package/dist/pages/index.js
CHANGED
|
@@ -42957,11 +42957,9 @@ const processChartDateData = ({
|
|
|
42957
42957
|
isCumulative = false,
|
|
42958
42958
|
valueField = 'total'
|
|
42959
42959
|
}) => {
|
|
42960
|
-
if (!mainData || !Array.isArray(mainData) || mainData.length === 0) {
|
|
42961
|
-
return [];
|
|
42962
|
-
}
|
|
42963
42960
|
const timeQuantity = getTimeQuantity(filter);
|
|
42964
|
-
const dates = mainData;
|
|
42961
|
+
const dates = mainData || [];
|
|
42962
|
+
const isEmpty = !mainData || !Array.isArray(mainData) || mainData.length === 0;
|
|
42965
42963
|
const _data = [];
|
|
42966
42964
|
let end = filters?.timeframe?.endDate || dayjs__default["default"]();
|
|
42967
42965
|
let start = filters?.timeframe?.startDate || dayjs__default["default"]().add(-12, timeQuantity);
|
|
@@ -42993,7 +42991,7 @@ const processChartDateData = ({
|
|
|
42993
42991
|
let currentDate = start.clone();
|
|
42994
42992
|
while (currentDate.isBefore(end) || currentDate.isSame(end, filter === "daily" ? "day" : filter === "weekly" ? "week" : "month")) {
|
|
42995
42993
|
// Filter data points that fall within this period
|
|
42996
|
-
const score = dates.filter(d => {
|
|
42994
|
+
const score = isEmpty ? 0 : dates.filter(d => {
|
|
42997
42995
|
if (!d.date) return false;
|
|
42998
42996
|
switch (filter) {
|
|
42999
42997
|
case "daily":
|
|
@@ -43139,19 +43137,12 @@ const RestoredArea = ({
|
|
|
43139
43137
|
} = useTimeFilter({
|
|
43140
43138
|
defaultFilter: 'monthly'
|
|
43141
43139
|
});
|
|
43142
|
-
|
|
43143
|
-
// Map restoredAreaChart data to LineChart format with time filter support
|
|
43144
|
-
// Y-axis: total/cumulated value
|
|
43145
|
-
// X-axis: date (formatted based on timeFilter)
|
|
43146
|
-
// Fill all periods in the range, even if empty
|
|
43147
43140
|
const restoredAreaChartData = React.useMemo(() => {
|
|
43148
|
-
|
|
43149
|
-
return [];
|
|
43150
|
-
}
|
|
43141
|
+
const dataToProcess = !restoredAreaChart || !Array.isArray(restoredAreaChart) || restoredAreaChart.length === 0 ? [] : restoredAreaChart;
|
|
43151
43142
|
|
|
43152
43143
|
// Process data with cumulative calculation (for restored area)
|
|
43153
43144
|
return processChartDateData({
|
|
43154
|
-
mainData:
|
|
43145
|
+
mainData: dataToProcess,
|
|
43155
43146
|
isCumulative: true,
|
|
43156
43147
|
valueField: 'total'
|
|
43157
43148
|
});
|
|
@@ -43289,18 +43280,12 @@ const PlantingActivitiesTimeline = ({
|
|
|
43289
43280
|
} = useTimeFilter({
|
|
43290
43281
|
defaultFilter: 'monthly'
|
|
43291
43282
|
});
|
|
43292
|
-
|
|
43293
|
-
// Map activitiesTimelineChart data to ColumnChart format with time filter support
|
|
43294
|
-
// Data structure: [{count: 2, date: "2025-11-03"}]
|
|
43295
|
-
// Fill all periods in the range, even if empty
|
|
43296
43283
|
const activitiesTimelineData = React.useMemo(() => {
|
|
43297
|
-
|
|
43298
|
-
return [];
|
|
43299
|
-
}
|
|
43284
|
+
const dataToProcess = !activitiesTimelineChart || !Array.isArray(activitiesTimelineChart) || activitiesTimelineChart.length === 0 ? [] : activitiesTimelineChart;
|
|
43300
43285
|
|
|
43301
43286
|
// Process data without cumulative calculation (for activities timeline)
|
|
43302
43287
|
return processChartDateData({
|
|
43303
|
-
mainData:
|
|
43288
|
+
mainData: dataToProcess,
|
|
43304
43289
|
isCumulative: false,
|
|
43305
43290
|
valueField: 'count'
|
|
43306
43291
|
});
|
|
@@ -44225,14 +44210,13 @@ const JobsTimeline = ({
|
|
|
44225
44210
|
});
|
|
44226
44211
|
const jobsData = Array.isArray(dayJobsTimeline) ? dayJobsTimeline : dayJobsTimeline?.jobsTimeline || dayJobsTimeline?.jobs || dayJobsTimeline?.timeline || [];
|
|
44227
44212
|
const jobsTimelineData = React.useMemo(() => {
|
|
44228
|
-
if
|
|
44229
|
-
|
|
44230
|
-
}
|
|
44213
|
+
// Always process data, even if empty, to generate default date range for x-axis
|
|
44214
|
+
const dataToProcess = !jobsData || !Array.isArray(jobsData) || jobsData.length === 0 ? [] : jobsData;
|
|
44231
44215
|
|
|
44232
44216
|
// Process data without cumulative calculation (for jobs timeline)
|
|
44233
44217
|
// Try to find value in total, count, jobs, or value fields
|
|
44234
44218
|
return processChartDateData({
|
|
44235
|
-
mainData:
|
|
44219
|
+
mainData: dataToProcess,
|
|
44236
44220
|
isCumulative: false,
|
|
44237
44221
|
valueField: 'total' // Will fallback to count/jobs/value if total doesn't exist
|
|
44238
44222
|
});
|
package/package.json
CHANGED
|
@@ -21,14 +21,15 @@ const JobsTimeline = ({
|
|
|
21
21
|
: (dayJobsTimeline?.jobsTimeline || dayJobsTimeline?.jobs || dayJobsTimeline?.timeline || []);
|
|
22
22
|
|
|
23
23
|
const jobsTimelineData = useMemo(() => {
|
|
24
|
-
if
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
// Always process data, even if empty, to generate default date range for x-axis
|
|
25
|
+
const dataToProcess = (!jobsData || !Array.isArray(jobsData) || jobsData.length === 0)
|
|
26
|
+
? []
|
|
27
|
+
: jobsData;
|
|
27
28
|
|
|
28
29
|
// Process data without cumulative calculation (for jobs timeline)
|
|
29
30
|
// Try to find value in total, count, jobs, or value fields
|
|
30
31
|
return processChartDateData({
|
|
31
|
-
mainData:
|
|
32
|
+
mainData: dataToProcess,
|
|
32
33
|
isCumulative: false,
|
|
33
34
|
valueField: 'total', // Will fallback to count/jobs/value if total doesn't exist
|
|
34
35
|
});
|
|
@@ -15,17 +15,15 @@ const PlantingActivitiesTimeline = ({
|
|
|
15
15
|
}) => {
|
|
16
16
|
const { timeFilter, setTimeFilter, formatDateAxis, processChartDateData } = useTimeFilter({ defaultFilter: 'monthly' });
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
// Data structure: [{count: 2, date: "2025-11-03"}]
|
|
20
|
-
// Fill all periods in the range, even if empty
|
|
18
|
+
|
|
21
19
|
const activitiesTimelineData = useMemo(() => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const dataToProcess = (!activitiesTimelineChart || !Array.isArray(activitiesTimelineChart) || activitiesTimelineChart.length === 0)
|
|
21
|
+
? []
|
|
22
|
+
: activitiesTimelineChart;
|
|
25
23
|
|
|
26
24
|
// Process data without cumulative calculation (for activities timeline)
|
|
27
25
|
return processChartDateData({
|
|
28
|
-
mainData:
|
|
26
|
+
mainData: dataToProcess,
|
|
29
27
|
isCumulative: false,
|
|
30
28
|
valueField: 'count',
|
|
31
29
|
});
|
package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleOutcomes/RestoredArea.jsx
CHANGED
|
@@ -15,18 +15,14 @@ const RestoredArea = ({
|
|
|
15
15
|
}) => {
|
|
16
16
|
const { timeFilter, setTimeFilter, formatDateAxis, processChartDateData } = useTimeFilter({ defaultFilter: 'monthly' });
|
|
17
17
|
|
|
18
|
-
// Map restoredAreaChart data to LineChart format with time filter support
|
|
19
|
-
// Y-axis: total/cumulated value
|
|
20
|
-
// X-axis: date (formatted based on timeFilter)
|
|
21
|
-
// Fill all periods in the range, even if empty
|
|
22
18
|
const restoredAreaChartData = useMemo(() => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
const dataToProcess = (!restoredAreaChart || !Array.isArray(restoredAreaChart) || restoredAreaChart.length === 0)
|
|
20
|
+
? []
|
|
21
|
+
: restoredAreaChart;
|
|
26
22
|
|
|
27
23
|
// Process data with cumulative calculation (for restored area)
|
|
28
24
|
return processChartDateData({
|
|
29
|
-
mainData:
|
|
25
|
+
mainData: dataToProcess,
|
|
30
26
|
isCumulative: true,
|
|
31
27
|
valueField: 'total',
|
|
32
28
|
});
|
|
@@ -99,12 +99,9 @@ export const processChartDateData = ({
|
|
|
99
99
|
isCumulative = false,
|
|
100
100
|
valueField = 'total'
|
|
101
101
|
}) => {
|
|
102
|
-
if (!mainData || !Array.isArray(mainData) || mainData.length === 0) {
|
|
103
|
-
return [];
|
|
104
|
-
}
|
|
105
|
-
|
|
106
102
|
const timeQuantity = getTimeQuantity(filter);
|
|
107
|
-
const dates = mainData;
|
|
103
|
+
const dates = mainData || [];
|
|
104
|
+
const isEmpty = !mainData || !Array.isArray(mainData) || mainData.length === 0;
|
|
108
105
|
|
|
109
106
|
const _data = [];
|
|
110
107
|
let end = filters?.timeframe?.endDate || dayjs();
|
|
@@ -140,7 +137,7 @@ export const processChartDateData = ({
|
|
|
140
137
|
let currentDate = start.clone();
|
|
141
138
|
while (currentDate.isBefore(end) || currentDate.isSame(end, filter === "daily" ? "day" : filter === "weekly" ? "week" : "month")) {
|
|
142
139
|
// Filter data points that fall within this period
|
|
143
|
-
const score = dates
|
|
140
|
+
const score = isEmpty ? 0 : dates
|
|
144
141
|
.filter((d) => {
|
|
145
142
|
if (!d.date) return false;
|
|
146
143
|
switch (filter) {
|