From ab330c64eeed9edfc2a6ef6a6f5cd38587ba0996 Mon Sep 17 00:00:00 2001
From: l3wdfut4pwr <l3wdfut4pwr@gmail.com>
Date: Mon, 27 Apr 2026 13:45:25 +0300
Subject: add username change and logout

---
 src/components/settings/LogoutButton.tsx | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 src/components/settings/LogoutButton.tsx

(limited to 'src/components/settings/LogoutButton.tsx')

diff --git a/src/components/settings/LogoutButton.tsx b/src/components/settings/LogoutButton.tsx
new file mode 100644
index 0000000..22cbb27
--- /dev/null
+++ b/src/components/settings/LogoutButton.tsx
@@ -0,0 +1,31 @@
+'use client';
+
+import { Button } from '@/components/ui/button';
+import { useAuthContext } from '@/lib/contexts/Auth.context';
+import { useRouter } from 'next/navigation';
+import { useState } from 'react';
+
+export default function LogoutButton() {
+    const { logout } = useAuthContext();
+    const router = useRouter();
+    const [loading, setLoading] = useState(false);
+
+    const handleLogout = async () => {
+        if (loading) return;
+
+        setLoading(true);
+
+        try {
+            await logout();
+            router.push('/');
+        } finally {
+            setLoading(false);
+        }
+    };
+
+    return (
+        <Button className="w-[310px]" onClick={handleLogout} disabled={loading}>
+            {loading ? 'Выход...' : 'Выйти из аккаунта'}
+        </Button>
+    );
+}
-- 
cgit v1.3-3-g829e

