fix: redirect after sign out

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
rever-tecnologia 2025-10-06 10:34:03 -03:00
parent 5d9cfde1d2
commit 82b00f206e
2 changed files with 9 additions and 1 deletions

View file

@ -2,6 +2,7 @@
import { useMemo, useState } from "react"
import Link from "next/link"
import { useRouter } from "next/navigation"
import { toast } from "sonner"
import { Settings2, Share2, ShieldCheck, UserCog, UserPlus, Users2, Layers3 } from "lucide-react"
@ -87,6 +88,7 @@ const SETTINGS_ACTIONS: SettingsAction[] = [
export function SettingsContent() {
const { session, isAdmin, isStaff } = useAuth()
const [isSigningOut, setIsSigningOut] = useState(false)
const router = useRouter()
const normalizedRole = session?.user.role?.toLowerCase() ?? "agent"
const roleLabel = ROLE_LABELS[normalizedRole] ?? "Agente"
@ -106,9 +108,12 @@ export function SettingsContent() {
setIsSigningOut(true)
try {
await signOut()
toast.success("Sessão encerrada")
router.replace("/login")
} catch (error) {
console.error(error)
toast.error("Não foi possível encerrar a sessão.")
} finally {
setIsSigningOut(false)
}
}