"use client"; import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { deleteAccount } from "@/actions/settings"; import { Loader2, AlertTriangle } from "lucide-react"; import { useRouter } from "next/navigation"; interface DeleteAccountProps { username: string; } export function DeleteAccount({ username }: DeleteAccountProps) { const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const [confirmation, setConfirmation] = useState(""); const [showConfirm, setShowConfirm] = useState(false); const router = useRouter(); async function handleDelete() { if (confirmation !== username) { setError("Please type your username to confirm"); return; } setLoading(true); setError(null); try { await deleteAccount(); router.push("/"); } catch (err) { setError(err instanceof Error ? err.message : "Failed to delete account"); setLoading(false); } } if (!showConfirm) { return (

Once you delete your account, there is no going back. All your repositories and data will be permanently deleted.

); } return (

This action cannot be undone

This will permanently delete your account, all repositories, and remove all your data from our servers.

setConfirmation(e.target.value)} placeholder="Enter your username" />
{error && (
{error}
)}
); }