From 1d3c6d1caaf96c9a76e2b49a31b20bf094b41611 Mon Sep 17 00:00:00 2001 From: infinicaretech Date: Thu, 2 Apr 2026 16:07:44 +0000 Subject: [PATCH] fix: dashboard undefined values, missing workouts, multi-value display - Add mesocycle_phase to all workout program return objects - Fix day.title undefined: use day.name which is the actual field name - Fix goal display: parse comma-separated values to Turkish labels - Fix injury area display: parse comma-separated values to Turkish labels - Pre-load meal data on dashboard to show daily calories immediately - Fixes: 'Hafta undefined/4', 'Temel' badge, empty workouts, raw 'lose_weight,build_muscle' display, missing calorie stat Co-Authored-By: Claude Opus 4.6 (1M context) --- src/public/index.html | 21 ++++++++++++++++++--- src/services/trainer.js | 4 ++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/public/index.html b/src/public/index.html index c69c4e4..d600b3c 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -2401,6 +2401,19 @@ async function loadDashboard() { document.getElementById('dashGreeting').textContent = 'Merhaba, ' + (currentUser ? currentUser.name : '') + '!'; renderStats(); await loadWorkout(); + // Pre-load meal data to fill calorie stat card + try { + mealData = await api('/api/program/meal'); + if (mealData && mealData.daily_calories) { + var calCard = document.getElementById('calorieStatCard'); + if (calCard) { + calCard.innerHTML = '
' + mealData.daily_calories + '
Gunluk Kalori (kcal)
'; + if (mealData.macros) { + calCard.innerHTML += '
P:' + mealData.macros.protein_g + 'g K:' + mealData.macros.carbs_g + 'g Y:' + mealData.macros.fat_g + 'g
'; + } + } + } + } catch (e) {} } function calculateBMI(weight, height) { @@ -2432,7 +2445,8 @@ function renderStats() { html += '
' + bmiHtml + '
BMI
'; html += '
' + p.height + ' cm / ' + p.weight + ' kg
'; - html += '
' + (goalNames[p.goal] || p.goal) + '
Hedef
'; + var goalDisplay = (p.goal || '').split(',').map(function(g) { return goalNames[g.trim()] || g.trim(); }).join(', '); + html += '
' + goalDisplay + '
Hedef
'; if (targetSub) html += '
' + targetSub + '
'; html += '
'; @@ -2445,7 +2459,8 @@ function renderStats() { if (p.has_injury) { var injAreas = { knee:'Diz', back:'Sirt', shoulder:'Omuz', elbow:'Dirsek', wrist:'Bilek', ankle:'Ayak Bilegi', hip:'Kalca', neck:'Boyun' }; - html += '
' + (injAreas[p.injury_area] || '-') + '
Sakatlik
'; + var injDisplay = (p.injury_area || '').split(',').map(function(a) { return injAreas[a.trim()] || a.trim(); }).filter(function(a) { return a && a !== 'none'; }).join(', ') || '-'; + html += '
' + injDisplay + '
Sakatlik
'; } if (p.has_disability) { @@ -2544,7 +2559,7 @@ function renderWorkout(el) { html += '
'; html += '
'; - html += '

' + day.day + ' - ' + (day.title || '') + '

'; + html += '

' + (day.name || ('Gun ' + day.day)) + '

'; html += '
'; if (day.estimated_duration) html += '' + day.estimated_duration + ' dk'; if (day.estimated_calories) html += '' + day.estimated_calories + ' kcal'; diff --git a/src/services/trainer.js b/src/services/trainer.js index b669976..9790ae9 100644 --- a/src/services/trainer.js +++ b/src/services/trainer.js @@ -1239,6 +1239,7 @@ function generateWorkoutProgram(profile, week = 1) { title: "Personal Light Activity Plan", description: "A gentle daily activity plan designed for your current situation. Focus on movement quality, breathing, and gradual improvement.", week: normalizedWeek, + mesocycle_phase: mesocycleConfig.phase, workout_location: "none", experience_level: experience, notes: [ @@ -1264,6 +1265,7 @@ function generateWorkoutProgram(profile, week = 1) { title: "Personal Wheelchair-Adapted Training Program", description: "Upper body focused program adapted for wheelchair users. All exercises are seated or upper body only.", week: normalizedWeek, + mesocycle_phase: mesocycleConfig.phase, workout_location: workoutLocation, experience_level: experience, notes: [ @@ -1284,6 +1286,7 @@ function generateWorkoutProgram(profile, week = 1) { title: "Personal Gentle Movement Plan", description: "A gentle movement plan adapted for your mobility level. Focus on what you can do comfortably.", week: normalizedWeek, + mesocycle_phase: mesocycleConfig.phase, workout_location: workoutLocation, experience_level: experience, notes: [ @@ -1327,6 +1330,7 @@ function generateWorkoutProgram(profile, week = 1) { title: title, description: description, week: normalizedWeek, + mesocycle_phase: mesocycleConfig.phase, workout_location: workoutLocation, experience_level: experience, notes: [