fix: align fitness_goal/cardio_preference values, make multi-select
Some checks failed
CI/CD - Build, Push & Deploy / Build & Push Docker Image (push) Has been cancelled
CI/CD - Build, Push & Deploy / Update GitOps Manifest (push) Has been cancelled

- Fix Invalid fitness_goal error: frontend values (general, hypertrophy)
  did not match backend enum (general_fitness, muscle_gain)
- Fix Invalid cardio_preference error: frontend values (running, cycling)
  did not match backend enum (low, moderate, high)
- Convert both fields to multi-select checkboxes
- Update backend validation to accept all frontend values with multi-enum

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-02 15:57:31 +00:00
parent 7ef6b6f9ee
commit edbb81a48f
2 changed files with 30 additions and 26 deletions

View File

@@ -1324,27 +1324,25 @@
<input type="number" id="profWorkoutDuration" min="15" max="180" placeholder="60">
</div>
<div class="form-group">
<label>Fitness Hedefi</label>
<select id="profFitnessGoal">
<option value="">Seciniz</option>
<option value="strength">Kuvvet</option>
<option value="hypertrophy">Kas Buyumesi</option>
<option value="endurance">Dayaniklilik</option>
<option value="general">Genel Fitness</option>
</select>
<label>Fitness Hedefi <span class="hint">(birden fazla secilebilir)</span></label>
<div class="checkbox-group">
<label><input type="checkbox" name="profFitnessGoal" value="strength"><span>Kuvvet</span></label>
<label><input type="checkbox" name="profFitnessGoal" value="hypertrophy"><span>Kas Buyumesi</span></label>
<label><input type="checkbox" name="profFitnessGoal" value="endurance"><span>Dayaniklilik</span></label>
<label><input type="checkbox" name="profFitnessGoal" value="general"><span>Genel Fitness</span></label>
</div>
</div>
</div>
<div class="form-group">
<label>Kardiyo Tercihi</label>
<select id="profCardioPreference">
<option value="">Seciniz</option>
<option value="running">Kosma</option>
<option value="cycling">Bisiklet</option>
<option value="swimming">Yuzme</option>
<option value="rowing">Kure</option>
<option value="elliptical">Eliptik</option>
<option value="none">Kardiyo Yapmak Istemiyorum</option>
</select>
<label>Kardiyo Tercihi <span class="hint">(birden fazla secilebilir)</span></label>
<div class="checkbox-group">
<label><input type="checkbox" name="profCardioPreference" value="running"><span>Kosma</span></label>
<label><input type="checkbox" name="profCardioPreference" value="cycling"><span>Bisiklet</span></label>
<label><input type="checkbox" name="profCardioPreference" value="swimming"><span>Yuzme</span></label>
<label><input type="checkbox" name="profCardioPreference" value="rowing"><span>Kure</span></label>
<label><input type="checkbox" name="profCardioPreference" value="elliptical"><span>Eliptik</span></label>
<label><input type="checkbox" name="profCardioPreference" value="none"><span>Kardiyo Yapmak Istemiyorum</span></label>
</div>
</div>
</div>
@@ -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,

View File

@@ -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"),