Log machine context errors in portal
This commit is contained in:
parent
545d5bea4b
commit
0fb95147f4
3 changed files with 82 additions and 5 deletions
|
|
@ -23,7 +23,7 @@ const navItems = [
|
|||
export function PortalShell({ children }: PortalShellProps) {
|
||||
const pathname = usePathname()
|
||||
const router = useRouter()
|
||||
const { session, machineContext } = useAuth()
|
||||
const { session, machineContext, machineContextError, machineContextLoading } = useAuth()
|
||||
const [isSigningOut, setIsSigningOut] = useState(false)
|
||||
|
||||
const isMachineSession = session?.user.role === "machine"
|
||||
|
|
@ -136,7 +136,25 @@ export function PortalShell({ children }: PortalShellProps) {
|
|||
</div>
|
||||
</header>
|
||||
<main className="mx-auto flex w-full max-w-6xl flex-1 flex-col gap-6 px-6 py-8">
|
||||
{null}
|
||||
{machineContextError ? (
|
||||
<div className="rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 shadow-sm">
|
||||
<p className="font-semibold text-red-800">Falha ao carregar os dados do colaborador vinculado.</p>
|
||||
<p className="mt-1 text-xs text-red-700/80">
|
||||
{machineContextError.message}
|
||||
{machineContextError.status ? ` (status ${machineContextError.status})` : null}
|
||||
</p>
|
||||
{machineContextError.details && Object.keys(machineContextError.details).length > 0 ? (
|
||||
<pre className="mt-2 overflow-x-auto rounded-lg bg-red-100 px-3 py-2 text-[11px] leading-tight text-red-800">
|
||||
{JSON.stringify(machineContextError.details, null, 2)}
|
||||
</pre>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
{!machineContextError && machineContextLoading ? (
|
||||
<div className="rounded-xl border border-slate-200 bg-slate-50 px-4 py-3 text-sm text-neutral-600 shadow-sm">
|
||||
Recuperando dados do colaborador vinculado...
|
||||
</div>
|
||||
) : null}
|
||||
{children}
|
||||
</main>
|
||||
<footer className="border-t border-slate-200 bg-white/70">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue