Spaces:
Runtime error
Runtime error
Download src/components/dashboard/settings/DisconnectButton.tsx from damndeepesh-dev/RippleWorkers: direct link, hf CLI and curl.
- Browser
- Download file 1.51 kB
-
https://huggingface.co/spaces/damndeepesh-dev/RippleWorkers/resolve/main/src/components/dashboard/settings/DisconnectButton.tsx
- Command line
-
hf download hf://spaces/damndeepesh-dev/RippleWorkers/src/components/dashboard/settings/DisconnectButton.tsx
-
curl -L -o DisconnectButton.tsx https://huggingface.co/spaces/damndeepesh-dev/RippleWorkers/resolve/main/src/components/dashboard/settings/DisconnectButton.tsx
1.51 kB
| "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 ( | |
| <button | |
| onClick={handleDisconnect} | |
| disabled={isPending} | |
| className="group flex items-center justify-center p-2 rounded-lg text-gray-400 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition-all disabled:opacity-50 disabled:cursor-not-allowed" | |
| title="Disconnect Account" | |
| > | |
| {isPending ? ( | |
| <Loader2 size={18} className="animate-spin" /> | |
| ) : ( | |
| <Trash2 size={18} /> | |
| )} | |
| </button> | |
| ); | |
| } | |