import { useState } from "react"; import Image from "next/image"; import { Play, Shuffle, Star, Trash2, GripVertical } from "lucide-react"; import { CSS } from "@dnd-kit/utilities"; import { useSortable } from "@dnd-kit/sortable"; import { useCurrentLocale, useI18n } from "locales/client"; import { InlineTooltip } from "@/components/ui/tooltip"; import { Button } from "@/components/ui/button"; import { ExerciseVideoModal } from "./exercise-video-modal"; import type { ExerciseWithAttributes } from "../types"; interface ExerciseListItemProps { exercise: ExerciseWithAttributes; muscle: string; onShuffle: (exerciseId: string, muscle: string) => void; onPick: (exerciseId: string) => void; onDelete: (exerciseId: string, muscle: string) => void; } export function ExerciseListItem({ exercise, muscle, onShuffle, onPick, onDelete }: ExerciseListItemProps) { const t = useI18n(); const [isHovered, setIsHovered] = useState(false); const locale = useCurrentLocale(); const exerciseName = locale === "fr" ? exercise.name : exercise.nameEn; const [showVideo, setShowVideo] = useState(false); // dnd-kit sortable const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ id: exercise.id }); const style = { transform: CSS.Transform.toString(transform), transition, zIndex: isDragging ? 50 : undefined, boxShadow: isDragging ? "0 4px 16px 0 rgba(0,0,0,0.10)" : undefined, }; const handleOpenVideo = () => { setShowVideo(true); }; // Déterminer la couleur du muscle const getMuscleConfig = (muscle: string) => { const configs: Record = { ABDOMINALS: { color: "text-red-600 dark:text-red-400", bg: "bg-red-50 dark:bg-red-950/50" }, BICEPS: { color: "text-purple-600 dark:text-purple-400", bg: "bg-purple-50 dark:bg-purple-950/50" }, BACK: { color: "text-blue-600 dark:text-blue-400", bg: "bg-blue-50 dark:bg-blue-950/50" }, CHEST: { color: "text-green-600 dark:text-green-400", bg: "bg-green-50 dark:bg-green-950/50" }, SHOULDERS: { color: "text-orange-600 dark:text-orange-400", bg: "bg-orange-50 dark:bg-orange-950/50" }, OBLIQUES: { color: "text-pink-600 dark:text-pink-400", bg: "bg-pink-50 dark:bg-pink-950/50" }, }; return configs[muscle] || { color: "text-slate-600 dark:text-slate-400", bg: "bg-slate-50 dark:bg-slate-950/50" }; }; const muscleConfig = getMuscleConfig(muscle); return (
setIsHovered(true)} onMouseLeave={() => setIsHovered(false)} >
{/* Section gauche - Infos principales */}
{/* Drag handle */} {/* Image de l'exercice */} {exercise.fullVideoImageUrl && (
{exerciseName { // Fallback si l'image ne charge pas e.currentTarget.style.display = "none"; }} src={exercise.fullVideoImageUrl} width={40} /> {/* Overlay play icon */}
)} {/* Badge muscle avec animation */}
{muscle.charAt(0)}
{/* Nom de l'exercice avec indicateurs */}

{exerciseName}

{/* Section droite - Actions */}
{/* Bouton shuffle */} {/* Bouton pick */} {/* Bouton delete */}
{/* Video Modal */} {exercise.fullVideoUrl && }
); }