diff --git a/src/public/index.html b/src/public/index.html index f4cd5f1..c69c4e4 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -1324,27 +1324,25 @@
- - + +
+ + + + +
- - + +
+ + + + + + +
@@ -2159,8 +2157,14 @@ function populateProfileForm(p) { if (p.workout_experience) document.getElementById('profExperience').value = p.workout_experience; if (p.workout_days_per_week) document.getElementById('profWorkoutDays').value = p.workout_days_per_week; if (p.workout_duration_minutes) document.getElementById('profWorkoutDuration').value = p.workout_duration_minutes; - if (p.fitness_goal) document.getElementById('profFitnessGoal').value = p.fitness_goal; - if (p.cardio_preference) document.getElementById('profCardioPreference').value = p.cardio_preference; + if (p.fitness_goal) { + var fgoals = typeof p.fitness_goal === 'string' ? p.fitness_goal.split(',').map(function(s){return s.trim();}) : [p.fitness_goal]; + setCheckedValues('profFitnessGoal', fgoals); + } + if (p.cardio_preference) { + var cprefs = typeof p.cardio_preference === 'string' ? p.cardio_preference.split(',').map(function(s){return s.trim();}) : [p.cardio_preference]; + setCheckedValues('profCardioPreference', cprefs); + } } else if (p.workout_location === 'home') { if (p.workout_experience) document.getElementById('profExperienceHome').value = p.workout_experience; if (p.workout_days_per_week) document.getElementById('profWorkoutDaysHome').value = p.workout_days_per_week; @@ -2316,8 +2320,8 @@ async function saveProfile() { workout_experience: workoutExp || null, workout_days_per_week: workoutDaysVal, workout_duration_minutes: workoutDurVal, - fitness_goal: (wl === 'gym' ? document.getElementById('profFitnessGoal').value : null) || null, - cardio_preference: (wl === 'gym' ? document.getElementById('profCardioPreference').value : null) || null, + fitness_goal: (wl === 'gym' ? getCheckedValues('profFitnessGoal').join(',') : null) || null, + cardio_preference: (wl === 'gym' ? getCheckedValues('profCardioPreference').join(',') : null) || null, has_equipment: (wl === 'home' ? (document.getElementById('profHasEquipment').checked ? 1 : 0) : null), available_equipment: (wl === 'home' ? getCheckedValues('equipment').join(',') : null) || null, diff --git a/src/routes/profile.js b/src/routes/profile.js index c202fd7..c63e5f0 100644 --- a/src/routes/profile.js +++ b/src/routes/profile.js @@ -15,8 +15,8 @@ const VALID_STRESS_LEVELS = ["low", "medium", "high"]; const VALID_JOB_TYPES = ["desk", "standing", "physical", "mixed"]; const VALID_WORKOUT_EXPERIENCE = ["beginner", "intermediate", "advanced"]; const VALID_WORKOUT_LOCATIONS = ["gym", "home", "none"]; -const VALID_FITNESS_GOALS = ["general_fitness", "strength", "endurance", "flexibility", "weight_loss", "muscle_gain", "rehabilitation"]; -const VALID_CARDIO_PREFERENCES = ["low", "moderate", "high", "none"]; +const VALID_FITNESS_GOALS = ["general", "strength", "hypertrophy", "endurance", "flexibility", "weight_loss", "muscle_gain", "rehabilitation", "general_fitness"]; +const VALID_CARDIO_PREFERENCES = ["running", "cycling", "swimming", "rowing", "elliptical", "none", "low", "moderate", "high"]; const VALID_INJURY_AREAS = ["knee", "back", "shoulder", "elbow", "wrist", "ankle", "hip", "neck", "none"]; const VALID_INJURY_SEVERITY = ["mild", "moderate", "severe"]; const VALID_DISABILITY_TYPES = ["none", "visual", "hearing", "motor", "cognitive", "multiple"]; @@ -109,8 +109,8 @@ function validate(body) { validateEnum(body.job_type, VALID_JOB_TYPES, "job_type"), validateEnum(body.workout_experience, VALID_WORKOUT_EXPERIENCE, "workout_experience"), validateEnum(body.workout_location, VALID_WORKOUT_LOCATIONS, "workout_location"), - validateEnum(body.fitness_goal, VALID_FITNESS_GOALS, "fitness_goal"), - validateEnum(body.cardio_preference, VALID_CARDIO_PREFERENCES, "cardio_preference"), + validateMultiEnum(body.fitness_goal, VALID_FITNESS_GOALS, "fitness_goal"), + validateMultiEnum(body.cardio_preference, VALID_CARDIO_PREFERENCES, "cardio_preference"), validateMultiEnum(body.injury_area, VALID_INJURY_AREAS, "injury_area"), validateEnum(body.injury_severity, VALID_INJURY_SEVERITY, "injury_severity"), validateEnum(body.disability_type, VALID_DISABILITY_TYPES, "disability_type"),