"use client"; import Link from "next/link"; import { motion } from "framer-motion"; import { Lock, Link as LinkIcon, Clock } from "lucide-react"; import { Badge } from "@/components/ui/badge"; import { Snippet } from "@/lib/types"; import { formatExpiry } from "@/lib/expiry-format"; import { cn } from "@/lib/utils"; interface SnippetCardProps { snippet: Snippet; view: "grid" | "list"; index?: number; } function timeAgo(dateStr: string): string { const diff = Date.now() - new Date(dateStr).getTime(); const mins = Math.floor(diff / 60000); if (mins < 60) return `${mins}m ago`; const hrs = Math.floor(mins / 60); if (hrs < 24) return `${hrs}h ago`; const days = Math.floor(hrs / 24); if (days < 7) return `${days}d ago`; return new Date(dateStr).toLocaleDateString(); } export function SnippetCard({ snippet, view, index = 0 }: SnippetCardProps) { const isGrid = view === "grid"; return (

{snippet.title}

{snippet.privacy === "password" ? ( ) : ( )} {snippet.privacy === "password" ? "Password" : "Secret"}
{isGrid && (
                {snippet.code}
              
)}
{snippet.language} {snippet.expiration !== "never" && (() => { const label = formatExpiry(snippet.expiresAt); return label ? ( {label} ) : null; })()} {timeAgo(snippet.createdAt)}
{snippet.tags.length > 0 && (
{snippet.tags.slice(0, 3).map((tag) => ( {tag} ))} {snippet.tags.length > 3 && ( +{snippet.tags.length - 3} )}
)}
); }