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';