"use client"; import { useTransition } from "react"; import { useRouter } from "next/navigation"; import { RotateCcw, Trash2 } from "lucide-react"; import { restoreImages, purgeFromTrash } from "@/app/actions/trash"; import { relativeTime } from "@/lib/utils"; import { thumbUrl } from "@/lib/assetUrls"; export interface TrashCardImage { id: number; thumbPath: string; width: number; height: number; code: string | null; title: string | null; rating: number | null; watched: boolean; studioName: string | null; deletedAt: number; } export function TrashCard({ image }: { image: TrashCardImage }) { const [pending, start] = useTransition(); const router = useRouter(); const onRestore = () => { start(async () => { await restoreImages([image.id]); router.refresh(); }); }; const onPurge = () => { if (!confirm("Permanently delete this cover? Cannot be undone.")) return; start(async () => { await purgeFromTrash([image.id]); router.refresh(); }); }; return (
{/* eslint-disable-next-line @next/next/no-img-element */} {image.title {image.code && ( {image.code} )} deleted {relativeTime(image.deletedAt)}
); }