"use client"; import { AnimatePresence, motion } from "framer-motion"; import Image from "next/image"; import { useEffect, useState } from "react"; import ProjectCardDropdown from "./dropdown"; import { Clock, Globe, Lock } from "lucide-react"; import { Sandbox } from "@/lib/types"; import { Card } from "@/components/ui/card"; import { useRouter } from "next/navigation"; export default function ProjectCard({ children, sandbox, onVisibilityChange, onDelete, deletingId, }: { children?: React.ReactNode; sandbox: Sandbox; onVisibilityChange: (sandbox: Sandbox) => void; onDelete: (sandbox: Sandbox) => void; deletingId: string; }) { const [hovered, setHovered] = useState(false); const [date, setDate] = useState(); const router = useRouter(); useEffect(() => { const createdAt = new Date(sandbox.createdAt); const now = new Date(); const diffInMinutes = Math.floor( (now.getTime() - createdAt.getTime()) / 60000 ); if (diffInMinutes < 1) { setDate("Now"); } else if (diffInMinutes < 60) { setDate(`${diffInMinutes}m ago`); } else if (diffInMinutes < 1440) { setDate(`${Math.floor(diffInMinutes / 60)}h ago`); } else { setDate(`${Math.floor(diffInMinutes / 1440)}d ago`); } }, [sandbox]); return ( router.push(`/code/${sandbox.id}`)} onMouseEnter={() => setHovered(true)} onMouseLeave={() => setHovered(false)} className={`group/canvas-card p-4 h-48 flex flex-col justify-between items-start hover:border-muted-foreground/50 relative overflow-hidden transition-all`} > {/* {hovered && ( {children} )} */}
{sandbox.name}
{sandbox.visibility === "private" ? ( <> Private ) : ( <> Public )}
{date}
); }