Files
football-next/app/(admin)/admin/rounds/ActivateRoundButton.tsx
a.alinaghipour aa9ed69dd2 first commit
2026-04-05 15:53:20 +03:30

26 lines
820 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use client";
import { useState } from "react";
import { useRouter } from "next/navigation";
export default function ActivateRoundButton({ roundId, isActive }: { roundId: string; isActive: boolean }) {
const router = useRouter();
const [loading, setLoading] = useState(false);
async function activate() {
setLoading(true);
await fetch(`/api/rounds/${roundId}/activate`, { method: "POST" });
router.refresh();
setLoading(false);
}
if (isActive) return <span className="text-xs text-green-600 font-medium px-3 py-1.5"> فعال</span>;
return (
<button onClick={activate} disabled={loading}
className="bg-blue-600 text-white px-3 py-1.5 rounded-lg text-sm hover:bg-blue-700 transition disabled:opacity-50">
{loading ? "..." : "فعال‌سازی"}
</button>
);
}