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,7 +2,7 @@
import { type ReactNode, useMemo, useState } from "react"
import Link from "next/link"
import { usePathname } from "next/navigation"
import { usePathname, useRouter } from "next/navigation"
import { LogOut, PlusCircle } from "lucide-react"
import { toast } from "sonner"
@ -22,6 +22,7 @@ const navItems = [
export function PortalShell({ children }: PortalShellProps) {
const pathname = usePathname()
const router = useRouter()
const { session, isCustomer } = useAuth()
const [isSigningOut, setIsSigningOut] = useState(false)
@ -41,9 +42,11 @@ export function PortalShell({ children }: PortalShellProps) {
try {
await signOut()
toast.success("Sessão encerrada", { id: "portal-signout" })
router.replace("/login")
} catch (error) {
console.error(error)
toast.error("Não foi possível encerrar a sessão", { id: "portal-signout" })
} finally {
setIsSigningOut(false)
}
}