"use client"; import React, { useState } from "react"; import { Play, Star, ShieldCheck, X } from "lucide-react"; import { motion, AnimatePresence } from "motion/react"; import Link from "next/link"; import SafeImage from "./SafeImage"; import { useSettingsStore } from "../lib/store/settingsStore"; import { videoService, Video } from "../lib/services/videoService"; export interface TestimonialItem { id?: string; authorName?: string; roleTitle?: string; avatarUrl?: string; content?: string; clinicName?: string; vetName?: string; imageUrl?: string; quote?: string; title?: string; thumbnail?: string; videoUrl?: string; description?: string; isActive?: boolean; } const FALLBACK_VIDEOS = [ { id: "v1", title: "نحوه آماده‌سازی کانی‌هیدروکس GAG", doctor: "دکتر کلاوس هنینگ", duration: "۰۱:۴۵", thumbnail: "https://images.unsplash.com/photo-1576091160550-217359f42f8c?auto=format&fit=crop&q=80&w=400", videoUrl: "https://www.w3schools.com/html/mov_bbb.mp4", description: "آموزش گام به گام آماده‌سازی پودر Canhydrox GAG برای جذب حداکثری در دستگاه گوارش." }, { id: "v2", title: "اهمیت صدف لب‌سبز", doctor: "دکتر النا اشمیت", duration: "۰۲:۲۰", thumbnail: "https://images.unsplash.com/photo-1599443015574-be5fe8a05783?auto=format&fit=crop&q=80&w=400", videoUrl: "https://www.w3schools.com/html/movie.mp4", description: "چرا صدف لب‌سبز نیوزیلندی نایاب‌ترین و موثرترین ماده برای بازسازی مفصل است؟" }, { id: "v3", title: "تغذیه هوشمند توله‌سگ‌ها", doctor: "دکتر هلگا فیشر", duration: "۰۳:۱۰", thumbnail: "/assets/images/regenerated_image_1779109861747.png", videoUrl: "https://www.w3schools.com/html/mov_bbb.mp4", description: "دوز مصرفی مکمل‌های کلسیم در نژادهای بزرگ برای جلوگیری از بدشکلی‌های استخوانی." } ]; interface DisplayVideoItem { id: string; title?: string; doctor?: string; duration?: string; thumbnail?: string; videoUrl?: string; description?: string; quote?: string; imageUrl?: string; vetName?: string; } export default function VetGallery({ testimonials = [] }: { testimonials?: TestimonialItem[] }) { const getText = useSettingsStore(state => state.getText); const [apiVideos, setApiVideos] = useState([]); const [selectedVideo, setSelectedVideo] = useState(null); React.useEffect(() => { videoService.getVideos({ featured: true, limit: 3 }).then((data) => { if (data && data.length > 0) { setApiVideos(data); } }); }, []); const activeTestimonials = testimonials.filter(t => t.isActive !== false); const displayItems: DisplayVideoItem[] = activeTestimonials.length > 0 ? activeTestimonials.map((t, idx) => ({ id: t.id || `t-${idx}`, title: (t.authorName || t.vetName || '') + (t.roleTitle ? ` — ${t.roleTitle}` : (t.clinicName ? ` — ${t.clinicName}` : '')), doctor: (t.authorName || t.vetName || '') + (t.roleTitle ? ` (${t.roleTitle})` : ''), duration: "۰۲:۰۰", thumbnail: t.avatarUrl || t.imageUrl || "https://images.unsplash.com/photo-1576091160550-217359f42f8c?auto=format&fit=crop&q=80&w=400", videoUrl: "https://www.w3schools.com/html/mov_bbb.mp4", description: t.content || t.quote || '', quote: t.content || t.quote || '' })) : (apiVideos.length > 0 ? apiVideos : FALLBACK_VIDEOS); return (
{getText('videos_badge', "Vet Insights")}

{getText('videos_title', "مشاوره ویدئویی")} {getText('videos_title_highlight', "دوست دامپزشک پت شما")}

{getText('videos_desc', "تیم علمی و فرموله‌کنندگان کمپانی کنینا در آلمان مستقیماً با شما صحبت می‌کنند؛ آشنایی با نحوه مصرف، مزایای بالینی و دانش پزشکی پشت هر محصول.")}

{getText('videos_view_all', "مشاهده همه ویدئوها")}
{displayItems.map((video, index) => ( setSelectedVideo(video)} className="w-full text-right block group cursor-pointer focus-visible:ring-4 focus-visible:ring-canina-blue/30 focus-visible:outline-none rounded-[2rem] p-2" >
⏱️ {video.duration || (index === 0 ? '۱:۴۵' : index === 1 ? '۲:۲۰' : '۳:۱۰')}

{video.title || (video.quote ? video.quote.substring(0, 40) + '...' : '')}

{video.doctor || video.vetName}
))}
{/* Video Modal */} {selectedVideo && (
setSelectedVideo(null)} className="absolute inset-0 bg-medical-gray-900/90 backdrop-blur-xl" />
)}
); }