"use client"; import { useCallback, useRef, useState } from "react"; import Link from "next/link"; import { useTranslations } from "next-intl"; import { Crown, Loader2 } from "lucide-react"; import { VideoPlayOverlay } from "@/components/sections/VideoPlayOverlay"; import { getTemplatePreviewVideoSrc } from "@/lib/template-preview-media"; import type { VideoCatalogTemplate } from "@/lib/video-templates-catalog"; import { getVideoTemplateImageSrc } from "@/lib/video-templates-catalog"; import { cn } from "@/lib/utils"; interface VideoTemplateCompactCardProps { template: VideoCatalogTemplate; onUse: () => void; isUsing?: boolean; className?: string; } export function VideoTemplateCompactCard({ template, onUse, isUsing = false, className, }: VideoTemplateCompactCardProps) { const t = useTranslations("auto.componentsTemplatesVideoVideoTemplateCompactCard"); const [isHovered, setIsHovered] = useState(false); const videoRef = useRef(null); const imageSrc = getVideoTemplateImageSrc(template.id); const videoSrc = getTemplatePreviewVideoSrc(template.id); const detailHref = `/templates/${template.id}`; const handleEnter = useCallback(() => { setIsHovered(true); const video = videoRef.current; if (video) { video.currentTime = 0; void video.play().catch(() => undefined); } }, []); const handleLeave = useCallback(() => { setIsHovered(false); videoRef.current?.pause(); }, []); const handleUseClick = (event: React.MouseEvent) => { event.preventDefault(); event.stopPropagation(); if (!isUsing) onUse(); }; return (
{/* eslint-disable-next-line @next/next/no-img-element */}
{template.name}

{t("sceneCount", { count: template.sceneCount })}

); }