import { useMemo } from "react"; import { motion } from "framer-motion"; import Image from "next/image"; import { useKeyPressEvent } from "react-use"; import { BsFillTrashFill } from "react-icons/bs"; import { AiFillCheckCircle } from "react-icons/ai"; import { BsFillArrowLeftSquareFill, BsFillArrowRightSquareFill, } from "react-icons/bs"; import { useCollection } from "./useCollection"; import { Button } from "../button"; import { useUser } from "@/utils/useUser"; interface Props { id: string; onClose: () => void; } const dropIn = { hidden: { opacity: 0, }, visible: { y: "0", opacity: 1, transition: { duration: 0.1, type: "spring", damping: 25, stiffness: 500, }, }, exit: { opacity: 0, }, }; export const Modal: React.FC = ({ id, onClose }) => { const { collection, updateVisibility, remove, next, previous } = useCollection(id); const { user } = useUser(); useKeyPressEvent("ArrowLeft", previous); useKeyPressEvent("ArrowRight", next); const formatDate = useMemo(() => { if (!collection) return; const date = new Date(collection?.createdAt); return date.toLocaleDateString(); }, [collection?.createdAt]); return ( e.stopPropagation()} className="max-w-2xl h-auto w-full z-[10] rounded-3xl overflow-hidden relative flex items-center justify-center flex-col gap-4 bg-white/30 backdrop-blur-sm px-2 pb-2 pt-2" variants={dropIn} initial="hidden" animate="visible" exit="exit" > {user?.is_admin && (
{!collection?.is_visible && ( )}
)} Generated image

{formatDate}

{collection?.prompt}

); };