fix: total macros count missing

This commit is contained in:
2025-06-13 08:46:26 -03:00
parent e977618983
commit de04ae1fdb
+20 -1
View File
@@ -388,7 +388,26 @@ async function loadFoodEntries(date: Date) {
// Update total calories // Update total calories
updateTotalCalories(); updateTotalCalories();
// Update counters
let totalCalories = 0;
let totalProtein = 0;
let totalFat = 0;
let totalCarbs = 0;
let totalFiber = 0;
entries.forEach(entry => {
totalCalories += entry.calories;
totalProtein += entry.protein;
totalFat += entry.fat;
totalCarbs += entry.carbs;
totalFiber += entry.fiber;
});
getDivById('proteinValue').textContent = (Math.round(totalProtein * 10) / 10).toString();
getDivById('fatValue').textContent = (Math.round(totalFat * 10) / 10).toString();
getDivById('carboValue').textContent = (Math.round(totalCarbs * 10) / 10).toString();
getDivById('fiberValue').textContent = (Math.round(totalFiber * 10) / 10).toString();
} catch (error) { } catch (error) {
console.error('Load food entries error:', error); console.error('Load food entries error:', error);
swal('Oh no!', 'Failed to load food entries: ' + error.message, 'error'); swal('Oh no!', 'Failed to load food entries: ' + error.message, 'error');