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) <noreply@anthropic.com>
This commit is contained in:
@@ -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 = '<div class="stat-value">' + mealData.daily_calories + '</div><div class="stat-label">Gunluk Kalori (kcal)</div>';
|
||||
if (mealData.macros) {
|
||||
calCard.innerHTML += '<div class="stat-sub">P:' + mealData.macros.protein_g + 'g K:' + mealData.macros.carbs_g + 'g Y:' + mealData.macros.fat_g + 'g</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
function calculateBMI(weight, height) {
|
||||
@@ -2432,7 +2445,8 @@ function renderStats() {
|
||||
html += '<div class="stat-card"><div class="stat-value">' + bmiHtml + '</div><div class="stat-label">BMI</div>';
|
||||
html += '<div class="stat-sub">' + p.height + ' cm / ' + p.weight + ' kg</div></div>';
|
||||
|
||||
html += '<div class="stat-card"><div class="stat-value">' + (goalNames[p.goal] || p.goal) + '</div><div class="stat-label">Hedef</div>';
|
||||
var goalDisplay = (p.goal || '').split(',').map(function(g) { return goalNames[g.trim()] || g.trim(); }).join(', ');
|
||||
html += '<div class="stat-card"><div class="stat-value">' + goalDisplay + '</div><div class="stat-label">Hedef</div>';
|
||||
if (targetSub) html += '<div class="stat-sub">' + targetSub + '</div>';
|
||||
html += '</div>';
|
||||
|
||||
@@ -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 += '<div class="stat-card" style="border-left:4px solid var(--orange);"><div class="stat-value" style="color:var(--orange);font-size:1.2rem;">' + (injAreas[p.injury_area] || '-') + '</div><div class="stat-label">Sakatlik</div></div>';
|
||||
var injDisplay = (p.injury_area || '').split(',').map(function(a) { return injAreas[a.trim()] || a.trim(); }).filter(function(a) { return a && a !== 'none'; }).join(', ') || '-';
|
||||
html += '<div class="stat-card" style="border-left:4px solid var(--orange);"><div class="stat-value" style="color:var(--orange);font-size:1.2rem;">' + injDisplay + '</div><div class="stat-label">Sakatlik</div></div>';
|
||||
}
|
||||
|
||||
if (p.has_disability) {
|
||||
@@ -2544,7 +2559,7 @@ function renderWorkout(el) {
|
||||
|
||||
html += '<div class="day-card">';
|
||||
html += '<div class="day-header" onclick="toggleDayBody(this)">';
|
||||
html += '<h3>' + day.day + ' - ' + (day.title || '') + '</h3>';
|
||||
html += '<h3>' + (day.name || ('Gun ' + day.day)) + '</h3>';
|
||||
html += '<div class="day-meta">';
|
||||
if (day.estimated_duration) html += '<span class="day-duration">' + day.estimated_duration + ' dk</span>';
|
||||
if (day.estimated_calories) html += '<span class="day-duration">' + day.estimated_calories + ' kcal</span>';
|
||||
|
||||
@@ -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: [
|
||||
|
||||
Reference in New Issue
Block a user