fix: align fitness_goal/cardio_preference values, make multi-select
- 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:
@@ -1324,27 +1324,25 @@
|
|||||||
<input type="number" id="profWorkoutDuration" min="15" max="180" placeholder="60">
|
<input type="number" id="profWorkoutDuration" min="15" max="180" placeholder="60">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Fitness Hedefi</label>
|
<label>Fitness Hedefi <span class="hint">(birden fazla secilebilir)</span></label>
|
||||||
<select id="profFitnessGoal">
|
<div class="checkbox-group">
|
||||||
<option value="">Seciniz</option>
|
<label><input type="checkbox" name="profFitnessGoal" value="strength"><span>Kuvvet</span></label>
|
||||||
<option value="strength">Kuvvet</option>
|
<label><input type="checkbox" name="profFitnessGoal" value="hypertrophy"><span>Kas Buyumesi</span></label>
|
||||||
<option value="hypertrophy">Kas Buyumesi</option>
|
<label><input type="checkbox" name="profFitnessGoal" value="endurance"><span>Dayaniklilik</span></label>
|
||||||
<option value="endurance">Dayaniklilik</option>
|
<label><input type="checkbox" name="profFitnessGoal" value="general"><span>Genel Fitness</span></label>
|
||||||
<option value="general">Genel Fitness</option>
|
</div>
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Kardiyo Tercihi</label>
|
<label>Kardiyo Tercihi <span class="hint">(birden fazla secilebilir)</span></label>
|
||||||
<select id="profCardioPreference">
|
<div class="checkbox-group">
|
||||||
<option value="">Seciniz</option>
|
<label><input type="checkbox" name="profCardioPreference" value="running"><span>Kosma</span></label>
|
||||||
<option value="running">Kosma</option>
|
<label><input type="checkbox" name="profCardioPreference" value="cycling"><span>Bisiklet</span></label>
|
||||||
<option value="cycling">Bisiklet</option>
|
<label><input type="checkbox" name="profCardioPreference" value="swimming"><span>Yuzme</span></label>
|
||||||
<option value="swimming">Yuzme</option>
|
<label><input type="checkbox" name="profCardioPreference" value="rowing"><span>Kure</span></label>
|
||||||
<option value="rowing">Kure</option>
|
<label><input type="checkbox" name="profCardioPreference" value="elliptical"><span>Eliptik</span></label>
|
||||||
<option value="elliptical">Eliptik</option>
|
<label><input type="checkbox" name="profCardioPreference" value="none"><span>Kardiyo Yapmak Istemiyorum</span></label>
|
||||||
<option value="none">Kardiyo Yapmak Istemiyorum</option>
|
</div>
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -2159,8 +2157,14 @@ function populateProfileForm(p) {
|
|||||||
if (p.workout_experience) document.getElementById('profExperience').value = p.workout_experience;
|
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_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.workout_duration_minutes) document.getElementById('profWorkoutDuration').value = p.workout_duration_minutes;
|
||||||
if (p.fitness_goal) document.getElementById('profFitnessGoal').value = p.fitness_goal;
|
if (p.fitness_goal) {
|
||||||
if (p.cardio_preference) document.getElementById('profCardioPreference').value = p.cardio_preference;
|
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') {
|
} else if (p.workout_location === 'home') {
|
||||||
if (p.workout_experience) document.getElementById('profExperienceHome').value = p.workout_experience;
|
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;
|
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_experience: workoutExp || null,
|
||||||
workout_days_per_week: workoutDaysVal,
|
workout_days_per_week: workoutDaysVal,
|
||||||
workout_duration_minutes: workoutDurVal,
|
workout_duration_minutes: workoutDurVal,
|
||||||
fitness_goal: (wl === 'gym' ? document.getElementById('profFitnessGoal').value : null) || null,
|
fitness_goal: (wl === 'gym' ? getCheckedValues('profFitnessGoal').join(',') : null) || null,
|
||||||
cardio_preference: (wl === 'gym' ? document.getElementById('profCardioPreference').value : null) || null,
|
cardio_preference: (wl === 'gym' ? getCheckedValues('profCardioPreference').join(',') : null) || null,
|
||||||
has_equipment: (wl === 'home' ? (document.getElementById('profHasEquipment').checked ? 1 : 0) : null),
|
has_equipment: (wl === 'home' ? (document.getElementById('profHasEquipment').checked ? 1 : 0) : null),
|
||||||
available_equipment: (wl === 'home' ? getCheckedValues('equipment').join(',') : null) || null,
|
available_equipment: (wl === 'home' ? getCheckedValues('equipment').join(',') : null) || null,
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ const VALID_STRESS_LEVELS = ["low", "medium", "high"];
|
|||||||
const VALID_JOB_TYPES = ["desk", "standing", "physical", "mixed"];
|
const VALID_JOB_TYPES = ["desk", "standing", "physical", "mixed"];
|
||||||
const VALID_WORKOUT_EXPERIENCE = ["beginner", "intermediate", "advanced"];
|
const VALID_WORKOUT_EXPERIENCE = ["beginner", "intermediate", "advanced"];
|
||||||
const VALID_WORKOUT_LOCATIONS = ["gym", "home", "none"];
|
const VALID_WORKOUT_LOCATIONS = ["gym", "home", "none"];
|
||||||
const VALID_FITNESS_GOALS = ["general_fitness", "strength", "endurance", "flexibility", "weight_loss", "muscle_gain", "rehabilitation"];
|
const VALID_FITNESS_GOALS = ["general", "strength", "hypertrophy", "endurance", "flexibility", "weight_loss", "muscle_gain", "rehabilitation", "general_fitness"];
|
||||||
const VALID_CARDIO_PREFERENCES = ["low", "moderate", "high", "none"];
|
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_AREAS = ["knee", "back", "shoulder", "elbow", "wrist", "ankle", "hip", "neck", "none"];
|
||||||
const VALID_INJURY_SEVERITY = ["mild", "moderate", "severe"];
|
const VALID_INJURY_SEVERITY = ["mild", "moderate", "severe"];
|
||||||
const VALID_DISABILITY_TYPES = ["none", "visual", "hearing", "motor", "cognitive", "multiple"];
|
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.job_type, VALID_JOB_TYPES, "job_type"),
|
||||||
validateEnum(body.workout_experience, VALID_WORKOUT_EXPERIENCE, "workout_experience"),
|
validateEnum(body.workout_experience, VALID_WORKOUT_EXPERIENCE, "workout_experience"),
|
||||||
validateEnum(body.workout_location, VALID_WORKOUT_LOCATIONS, "workout_location"),
|
validateEnum(body.workout_location, VALID_WORKOUT_LOCATIONS, "workout_location"),
|
||||||
validateEnum(body.fitness_goal, VALID_FITNESS_GOALS, "fitness_goal"),
|
validateMultiEnum(body.fitness_goal, VALID_FITNESS_GOALS, "fitness_goal"),
|
||||||
validateEnum(body.cardio_preference, VALID_CARDIO_PREFERENCES, "cardio_preference"),
|
validateMultiEnum(body.cardio_preference, VALID_CARDIO_PREFERENCES, "cardio_preference"),
|
||||||
validateMultiEnum(body.injury_area, VALID_INJURY_AREAS, "injury_area"),
|
validateMultiEnum(body.injury_area, VALID_INJURY_AREAS, "injury_area"),
|
||||||
validateEnum(body.injury_severity, VALID_INJURY_SEVERITY, "injury_severity"),
|
validateEnum(body.injury_severity, VALID_INJURY_SEVERITY, "injury_severity"),
|
||||||
validateEnum(body.disability_type, VALID_DISABILITY_TYPES, "disability_type"),
|
validateEnum(body.disability_type, VALID_DISABILITY_TYPES, "disability_type"),
|
||||||
|
|||||||
Reference in New Issue
Block a user