|
@@ -4,13 +4,15 @@ import { useState } from "react";
|
|
|
import Image from "next/image";
|
|
|
import { Play, Shuffle, MoreVertical, Trash2, Info, Target } from "lucide-react";
|
|
|
|
|
|
-import { useI18n } from "locales/client";
|
|
|
+import { useCurrentLocale, useI18n } from "locales/client";
|
|
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
|
|
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
|
|
|
import { Card, CardContent, CardHeader } from "@/components/ui/card";
|
|
|
import { Button } from "@/components/ui/button";
|
|
|
import { Badge } from "@/components/ui/badge";
|
|
|
|
|
|
+import { ExerciseVideoModal } from "./exercise-video-modal";
|
|
|
+
|
|
|
import type { ExerciseWithAttributes } from "../types";
|
|
|
|
|
|
interface ExerciseCardProps {
|
|
@@ -23,7 +25,9 @@ interface ExerciseCardProps {
|
|
|
|
|
|
export function ExerciseCard({ exercise, muscle, onShuffle, onPick, onDelete }: ExerciseCardProps) {
|
|
|
const t = useI18n();
|
|
|
+ const locale = useCurrentLocale();
|
|
|
const [imageError, setImageError] = useState(false);
|
|
|
+ const [showVideo, setShowVideo] = useState(false);
|
|
|
|
|
|
// Extraire les attributs utiles
|
|
|
const equipmentAttributes =
|
|
@@ -34,6 +38,13 @@ export function ExerciseCard({ exercise, muscle, onShuffle, onPick, onDelete }:
|
|
|
|
|
|
const mechanicsType = exercise.attributes?.find((attr) => attr.attributeName.name === "MECHANICS_TYPE")?.attributeValue.value;
|
|
|
|
|
|
+ const exerciseName = locale === "fr" ? exercise.name : exercise.nameEn
|
|
|
+
|
|
|
+ const handlePlayVideo = () => {
|
|
|
+ setShowVideo(true);
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
return (
|
|
|
<TooltipProvider>
|
|
|
<Card className="group relative overflow-hidden bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 hover:shadow-lg transition-all duration-200 hover:border-blue-200 dark:hover:border-blue-800">
|
|
@@ -51,7 +62,12 @@ export function ExerciseCard({ exercise, muscle, onShuffle, onPick, onDelete }:
|
|
|
src={exercise.fullVideoImageUrl}
|
|
|
/>
|
|
|
<div className="absolute inset-0 bg-black/20 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center">
|
|
|
- <Button className="bg-white/90 text-slate-900" size="small" variant="secondary">
|
|
|
+ <Button
|
|
|
+ className="bg-white/90 text-slate-900"
|
|
|
+ onClick={handlePlayVideo}
|
|
|
+ size="small"
|
|
|
+ variant="secondary"
|
|
|
+ >
|
|
|
<Play className="h-4 w-4 mr-2" />
|
|
|
{t("workout_builder.exercise.watch_video")}
|
|
|
</Button>
|
|
@@ -166,6 +182,15 @@ export function ExerciseCard({ exercise, muscle, onShuffle, onPick, onDelete }:
|
|
|
</div>
|
|
|
</CardContent>
|
|
|
</Card>
|
|
|
- </TooltipProvider>
|
|
|
+ {/* Video Modal */}
|
|
|
+ {exercise.fullVideoUrl && (
|
|
|
+ <ExerciseVideoModal
|
|
|
+ onOpenChange={setShowVideo}
|
|
|
+ open={showVideo}
|
|
|
+ title={exerciseName || exercise.name}
|
|
|
+ videoUrl={exercise.fullVideoUrl}
|
|
|
+ />
|
|
|
+ )}
|
|
|
+ </TooltipProvider >
|
|
|
);
|
|
|
}
|