diff --git a/apps/web/src/features/workout/sortable-workout-element.tsx b/apps/web/src/features/workout/sortable-workout-element.tsx index fd4f039..67e7fc6 100644 --- a/apps/web/src/features/workout/sortable-workout-element.tsx +++ b/apps/web/src/features/workout/sortable-workout-element.tsx @@ -8,6 +8,7 @@ import { FormMessage, } from '@/shared/components/ui/form'; import { Input } from '@/shared/components/ui/input'; +import { Textarea } from '@/shared/components/ui/textarea'; import { Select, SelectContent, @@ -64,6 +65,10 @@ export function SortableWorkoutElement({ const [editingWeight, setEditingWeight] = useState(false); const [editingRest, setEditingRest] = useState(false); const [editingElement, setEditingElement] = useState(false); + const [editingDescription, setEditingDescription] = useState(false); + const [editingExerciseDescription, setEditingExerciseDescription] = useState(false); + const [localDescription, setLocalDescription] = useState(''); + const [localExerciseDescription, setLocalExerciseDescription] = useState(''); const selectRef = useRef(null); const { @@ -87,19 +92,38 @@ export function SortableWorkoutElement({ // Trouver le complex sélectionné const selectedComplex = complexes.find((c) => c.id === selectedComplexId); + + // Trouver l'exercice sélectionné + const selectedExercise = exercises.find((e) => e.id === control._formValues.elements[index].id); - // Mettre à jour selectedComplexId quand l'ID change dans le form + // Mettre à jour selectedComplexId et exercice quand l'ID change dans le form useEffect(() => { const currentId = control._formValues.elements[index].id; - if ( - currentId && - control._formValues.elements[index].type === WORKOUT_ELEMENT_TYPES.COMPLEX - ) { + const currentType = control._formValues.elements[index].type; + + if (currentId && currentType === WORKOUT_ELEMENT_TYPES.COMPLEX) { setSelectedComplexId(currentId); + // Initialiser la description locale avec celle du complexe + const complex = complexes.find(c => c.id === currentId); + if (complex?.description && !localDescription) { + setLocalDescription(complex.description); + } + } + + if (currentId && currentType === WORKOUT_ELEMENT_TYPES.EXERCISE) { + // Initialiser la description locale avec celle de l'exercice + const exercise = exercises.find(e => e.id === currentId); + if (exercise?.description && !localExerciseDescription) { + setLocalExerciseDescription(exercise.description); + } } }, [ control._formValues.elements[index].id, control._formValues.elements[index].type, + complexes, + exercises, + localDescription, + localExerciseDescription, ]); const renderEditableBadge = ( @@ -256,7 +280,14 @@ export function SortableWorkoutElement({ )) : complexes.map((complex) => ( - {complex.complexCategory?.name || 'Complex'} +
+ + {complex.exercises.map(ex => ex.name).join(', ')} + + + {complex.complexCategory?.name} + +
))} @@ -275,7 +306,7 @@ export function SortableWorkoutElement({ > {type === WORKOUT_ELEMENT_TYPES.EXERCISE ? exercises.find((e) => e.id === field.value)?.name - : complexes.find((c) => c.id === field.value)?.complexCategory?.name || 'Complex'} + : complexes.find((c) => c.id === field.value)?.exercises.map(ex => ex.name).join(', ') || 'Complex'} )} @@ -320,6 +351,42 @@ export function SortableWorkoutElement({ )} {renderElementSelect(WORKOUT_ELEMENT_TYPES.EXERCISE)} +
+ {editingExerciseDescription ? ( +