From 04b34f9217d61d252ea5bb9c2b45846b0c0919b3 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Thu, 23 Apr 2026 21:46:57 +0000 Subject: [PATCH 1/2] Changes Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com> --- src/routes/admin.agente.$id.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/admin.agente.$id.tsx b/src/routes/admin.agente.$id.tsx index 636c46a..39f3428 100644 --- a/src/routes/admin.agente.$id.tsx +++ b/src/routes/admin.agente.$id.tsx @@ -80,7 +80,7 @@ function AgentDetailPage() { const { data: isAdmin, isLoading: roleLoading } = useQuery({ queryKey: ["is-admin", user?.id], - enabled: !!user, + enabled: !authLoading && !!user, queryFn: async () => { const { data, error } = await supabase.rpc("has_role", { _user_id: user!.id, @@ -93,7 +93,7 @@ function AgentDetailPage() { const { data: agent, isLoading: agentLoading, error: agentError } = useQuery({ queryKey: ["agent-detail", id], - enabled: !!isAdmin, + enabled: !authLoading && !!user && isAdmin === true, refetchInterval: 10_000, queryFn: async () => { console.log("[admin.agente] fetching agent detail", { id }); From adba16e1a7c334b160b96c4bb986f993f41eeb83 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Thu, 23 Apr 2026 21:47:11 +0000 Subject: [PATCH 2/2] Changes Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com> --- src/routes/admin.agente.$id.tsx | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/routes/admin.agente.$id.tsx b/src/routes/admin.agente.$id.tsx index 39f3428..461032e 100644 --- a/src/routes/admin.agente.$id.tsx +++ b/src/routes/admin.agente.$id.tsx @@ -259,7 +259,7 @@ function AgentDetailPage() { isAdmin, hasUser: !!user, hasAgent: !!agent, agentError, }); - if (authLoading || roleLoading) { + if (authLoading || (user && roleLoading) || (isAdmin === true && agentLoading)) { return (
@@ -267,7 +267,11 @@ function AgentDetailPage() { ); } - if (!isAdmin) { + if (!user) { + return null; + } + + if (isAdmin === false) { return (
@@ -285,6 +289,22 @@ function AgentDetailPage() { ); } + if (agentError) { + return ( +
+
+

Erro ao carregar agente

+

{agentError.message}

+ +
+
+ ); + } + if (!agent) { return (