fix(ui): add error handling to sign-out
Add try/catch with toast notification for sign-out failures.
This commit is contained in:
@@ -3,15 +3,19 @@
|
||||
import { signOut, useSession } from "@/lib/auth-client"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { toast } from "sonner"
|
||||
|
||||
export default function SignIn() {
|
||||
const { data: session, isPending } = useSession()
|
||||
const router = useRouter()
|
||||
|
||||
const handleSignOut = async () => {
|
||||
try {
|
||||
await signOut()
|
||||
router.push("/")
|
||||
router.refresh()
|
||||
} catch (error) {
|
||||
toast.error("Failed to sign out. Please try again.")
|
||||
}
|
||||
}
|
||||
|
||||
if (isPending) {
|
||||
|
||||
Reference in New Issue
Block a user