"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; export default function DeleteRoundButton({ roundId, hasMatches }: { roundId: string; hasMatches: boolean }) { const router = useRouter(); const [loading, setLoading] = useState(false); const [showConfirm, setShowConfirm] = useState(false); async function handleDelete() { setLoading(true); const res = await fetch("/api/rounds", { method: "DELETE", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ id: roundId }), }); if (res.ok) { router.refresh(); } else { const data = await res.json(); alert(data.error || "خطا در حذف"); } setLoading(false); setShowConfirm(false); } if (hasMatches) { return ( ); } return ( <> {showConfirm && (
setShowConfirm(false)}>
e.stopPropagation()}>

حذف دور

آیا مطمئن هستید که می‌خواهید این دور را حذف کنید؟

)} ); }