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">
|
||||
</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,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user