Files
wehub-resource-sync e4dcfc49aa
Tests / Import Check (Python 3.13) (push) Has been cancelled
Tests / Import Check (Python 3.14) (push) Has been cancelled
Tests / Python Tests (Python 3.11) (push) Has been cancelled
Tests / Python Tests (Python 3.12) (push) Has been cancelled
Tests / Python Tests (Python 3.14) (push) Has been cancelled
Tests / Test Summary (push) Has been cancelled
Tests / Lint and Format (push) Has been cancelled
Tests / Web Node Tests (push) Has been cancelled
Tests / Import Check (Python 3.11) (push) Has been cancelled
Tests / Import Check (Python 3.12) (push) Has been cancelled
Tests / Python Tests (Python 3.13) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:00:43 +08:00

46 lines
1.2 KiB
TypeScript

"use client";
import { LogOut } from "lucide-react";
import { useRouter } from "next/navigation";
import { logout } from "@/lib/auth";
import { useAuthStatus } from "@/hooks/useAuthStatus";
interface LogoutButtonProps {
collapsed?: boolean;
}
export function LogoutButton({ collapsed = false }: LogoutButtonProps) {
const router = useRouter();
const { enabled } = useAuthStatus();
if (!enabled) return null;
async function handleLogout() {
await logout();
router.replace("/login");
}
if (collapsed) {
return (
<button
onClick={handleLogout}
className="rounded-lg p-2 text-[var(--muted-foreground)] transition-colors hover:bg-[var(--background)]/50 hover:text-red-500"
aria-label="Sign out"
title="Sign out"
>
<LogOut size={16} strokeWidth={1.5} />
</button>
);
}
return (
<button
onClick={handleLogout}
className="flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-[13.5px] text-[var(--muted-foreground)] transition-colors hover:bg-[var(--background)]/50 hover:text-red-500"
>
<LogOut size={16} strokeWidth={1.5} />
<span>Sign out</span>
</button>
);
}