"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; interface DeleteImageButtonProps { imageId: string; } export default function DeleteImageButton({ imageId }: DeleteImageButtonProps) { const [deleting, setDeleting] = useState(false); const router = useRouter(); const handleDelete = async () => { setDeleting(true); try { const res = await fetch(`/api/user/monument/image/${imageId}`, { method: "DELETE" }); if (res.ok) { router.refresh(); } else { const data = await res.json(); alert(data.error || "Failed to delete image"); } } catch { alert("Something went wrong"); } finally { setDeleting(false); } }; return ( ); }