'use client'; import Link from 'next/link'; import { useState } from 'react'; interface VideoData { id: string; title: string; uploader: string; channel_id?: string; thumbnail: string; view_count: number; duration: string; uploaded_date?: string; } function formatViews(views: number): string { if (views >= 1000000) return (views / 1000000).toFixed(1) + 'M'; if (views >= 1000) return (views / 1000).toFixed(1) + 'K'; return views.toString(); } function getRelativeTime(id: string): string { const times = ['2 hours ago', '5 hours ago', '1 day ago', '3 days ago', '1 week ago', '2 weeks ago', '1 month ago']; const index = (id.charCodeAt(0) || 0) % times.length; return times[index]; } export default function VideoCard({ video, hideChannelAvatar }: { video: VideoData; hideChannelAvatar?: boolean }) { const relativeTime = video.uploaded_date || getRelativeTime(video.id); const [isNavigating, setIsNavigating] = useState(false); return (
setIsNavigating(true)} style={{ position: 'relative', display: 'block', width: '100%', aspectRatio: '16/9', overflow: 'hidden', borderRadius: '12px' }} > {/* eslint-disable-next-line @next/next/no-img-element */} {video.title} {video.duration && (
{video.duration}
)} {isNavigating && (
)}
{/* Video Info */}

{video.title}

{video.channel_id ? ( {video.uploader} ) : (
{video.uploader}
)}
{formatViews(video.view_count)} views • {relativeTime}
); }