From c8c210a6e57e45a99a8478a9c2ba1c6792f57676 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Tue, 28 Oct 2025 18:11:44 +0000 Subject: [PATCH] Fix: "Rendered more hooks than during previous render" error --- src/pages/admin/AdminContact.tsx | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/pages/admin/AdminContact.tsx b/src/pages/admin/AdminContact.tsx index cb7fa351..4600fd32 100644 --- a/src/pages/admin/AdminContact.tsx +++ b/src/pages/admin/AdminContact.tsx @@ -97,23 +97,6 @@ export default function AdminContact() { const [emailThreads, setEmailThreads] = useState([]); const [loadingThreads, setLoadingThreads] = useState(false); - // Admin-only access check - if (!isAdmin()) { - return ( -
- - - -

Access Denied

-

- Email response features are only available to administrators. -

-
-
-
- ); - } - // Fetch contact submissions const { data: submissions, isLoading } = useQuery({ queryKey: ['admin-contact-submissions', statusFilter, categoryFilter, searchQuery], @@ -275,6 +258,23 @@ export default function AdminContact() { return cat?.label || category; }; + // Admin-only access check (after all hooks) + if (!isAdmin()) { + return ( +
+ + + +

Access Denied

+

+ Email response features are only available to administrators. +

+
+
+
+ ); + } + // Theme-aware EmailThreadItem component function EmailThreadItem({ thread }: { thread: EmailThread }) { const isOutbound = thread.direction === 'outbound';