"use client"; import { useState } from "react"; import { Unlink, Loader2, Trash2 } from "lucide-react"; import { disconnectAccount } from "@/app/dashboard/settings/actions"; import { useRouter } from "next/navigation"; interface DisconnectButtonProps { accountId: string; username: string; } export default function DisconnectButton({ accountId, username }: DisconnectButtonProps) { const [isPending, setIsPending] = useState(false); const router = useRouter(); const handleDisconnect = async () => { if (!confirm(`Are you sure you want to disconnect @${username}?`)) return; setIsPending(true); try { await disconnectAccount(accountId); router.refresh(); } catch (error) { console.error("Failed to disconnect:", error); alert("Failed to disconnect account. Please try again."); } finally { setIsPending(false); } }; return ( ); }