Spaces:
Runtime error
Runtime error
Download apps/web/src/components/SignOutButton.tsx from Oheha/cybully-api: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/spaces/Oheha/cybully-api/resolve/main/apps/web/src/components/SignOutButton.tsx
- Command line
-
hf download hf://spaces/Oheha/cybully-api/apps/web/src/components/SignOutButton.tsx
-
curl -L -o SignOutButton.tsx https://huggingface.co/spaces/Oheha/cybully-api/resolve/main/apps/web/src/components/SignOutButton.tsx
1.45 kB
| "use client"; | |
| import { HugeiconsIcon } from "@hugeicons/react"; | |
| import { Logout01Icon } from "@hugeicons/core-free-icons"; | |
| import { useRouter } from "next/navigation"; | |
| import { createClient } from "@/utils/supabase/client"; | |
| type SignOutButtonProps = { | |
| fullWidth?: boolean; | |
| variant?: "neutral" | "danger"; | |
| }; | |
| export function SignOutButton({ fullWidth = false, variant = "neutral" }: SignOutButtonProps) { | |
| const router = useRouter(); | |
| const className = | |
| variant === "danger" | |
| ? `focus-ring inline-flex min-h-11 items-center justify-center gap-2 rounded-xl border border-red-200 bg-red-50 px-4 py-2 text-sm font-bold text-red-700 hover:bg-red-100 ${ | |
| fullWidth ? "w-full" : "" | |
| }` | |
| : `ui-secondary-button ${fullWidth ? "w-full" : ""}`; | |
| async function handleSignOut() { | |
| const supabase = createClient(); | |
| try { | |
| await supabase.auth.signOut(); | |
| } catch (e) { | |
| console.warn("[AUTH DIAGNOSTIC] Supabase signOut failed:", e); | |
| } | |
| try { | |
| await fetch("/api/auth/logout", { method: "POST" }); | |
| } catch (e) { | |
| console.error("[AUTH FALLBACK] Failed to call mock logout endpoint:", e); | |
| } | |
| router.push("/sign-in"); | |
| router.refresh(); | |
| } | |
| return ( | |
| <button | |
| className={className} | |
| type="button" | |
| onClick={handleSignOut} | |
| > | |
| <HugeiconsIcon icon={Logout01Icon} size={16} strokeWidth={1.9} aria-hidden /> | |
| Sign out | |
| </button> | |
| ); | |
| } | |