"use client"; import Button from "@/app/components/ui/Button"; import Card from "@/app/components/ui/Card"; import PageHeading from "@/app/components/ui/PageHeading"; import Toast, { ToastRef } from "@/app/components/ui/Toast"; import { useSupabase } from "@/app/supabase-provider"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { useRef, useState } from "react"; export default function Logout() { const { supabase } = useSupabase(); const [isPending, setIsPending] = useState(false); const logoutToast = useRef(null); const [error, setError] = useState("Unknown Error"); const router = useRouter(); const handleLogout = async () => { setIsPending(true); const { error } = await supabase.auth.signOut(); if (error) { console.error("Error logging out:", error.message); setError(error.message); logoutToast.current?.publish({ variant: "danger", text: `Error logging out: ${error.message}`, }); } else { console.log("User logged out"); logoutToast.current?.publish({ variant: "success", text: "Logged out successfully", }); router.replace("/"); } setIsPending(false); }; // useEffect(() => { // handleLogout(); // }, []); return (

Are you sure you want to sign out?

Logged Out Successfully {error}
); }