diff --git a/web/src/components/portal/portal-shell.tsx b/web/src/components/portal/portal-shell.tsx index b861046..252de57 100644 --- a/web/src/components/portal/portal-shell.tsx +++ b/web/src/components/portal/portal-shell.tsx @@ -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) } } diff --git a/web/src/components/settings/settings-content.tsx b/web/src/components/settings/settings-content.tsx index 6536d27..636f596 100644 --- a/web/src/components/settings/settings-content.tsx +++ b/web/src/components/settings/settings-content.tsx @@ -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) } }