Não foi possível conectar ao servidor.
Verifique sua conexão com a internet e tente novamente em alguns instantes.
"use client" import { type ReactNode, useMemo, useState } from "react" import Image from "next/image" import Link from "next/link" import { usePathname, useRouter } from "next/navigation" import { LogOut, PlusCircle } from "lucide-react" import { toast } from "sonner" import { Button } from "@/components/ui/button" import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" import { cn } from "@/lib/utils" import { useAuth, signOut } from "@/lib/auth-client" interface PortalShellProps { children: ReactNode } const navItems = [ { label: "Meus chamados", href: "/portal/tickets" }, { label: "Abrir chamado", href: "/portal/tickets/new", icon: PlusCircle }, ] export function PortalShell({ children }: PortalShellProps) { const pathname = usePathname() const router = useRouter() const { session, machineContext, machineContextError, machineContextLoading } = useAuth() const [isSigningOut, setIsSigningOut] = useState(false) const isMachineSession = session?.user.role === "machine" || Boolean(machineContext) const personaValue = machineContext?.persona ?? session?.user.machinePersona ?? null const collaboratorName = machineContext?.assignedUserName?.trim() ?? "" const collaboratorEmail = machineContext?.assignedUserEmail?.trim() ?? "" const userName = session?.user.name?.trim() ?? "" const userEmail = session?.user.email?.trim() ?? "" const displayName = collaboratorName || userName || collaboratorEmail || userEmail || "Cliente" const displayEmail = collaboratorEmail || userEmail const personaLabel = personaValue === "manager" ? "Gestor" : "Colaborador" const initials = useMemo(() => { const name = displayName || displayEmail || "Cliente" return name .split(" ") .slice(0, 2) .map((part) => part.charAt(0).toUpperCase()) .join("") }, [displayName, displayEmail]) async function handleSignOut() { if (isSigningOut) return setIsSigningOut(true) toast.loading("Encerrando sessão...", { id: "portal-signout" }) 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) } } const isNavItemActive = (itemHref: string) => { if (itemHref === "/portal/tickets") { if (pathname === "/portal" || pathname === "/portal/tickets") return true if (/^\/portal\/tickets\/[A-Za-z0-9_-]+$/.test(pathname) && !pathname.endsWith("/new")) return true return false } return pathname === itemHref } return (
Não foi possível conectar ao servidor.
Verifique sua conexão com a internet e tente novamente em alguns instantes.