From 1c7ca8fe320fb6f82ab312d00e9c31fa73b8fe92 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:17:10 +0000 Subject: [PATCH] Fix AdminContact loading state --- src/pages/admin/AdminContact.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/pages/admin/AdminContact.tsx b/src/pages/admin/AdminContact.tsx index c8c5d2f5..3755787b 100644 --- a/src/pages/admin/AdminContact.tsx +++ b/src/pages/admin/AdminContact.tsx @@ -87,7 +87,7 @@ interface EmailThread { export default function AdminContact() { const queryClient = useQueryClient(); const { theme } = useTheme(); - const { isAdmin } = useUserRole(); + const { isAdmin, loading: rolesLoading } = useUserRole(); const [statusFilter, setStatusFilter] = useState('all'); const [categoryFilter, setCategoryFilter] = useState('all'); const [searchQuery, setSearchQuery] = useState(''); @@ -259,7 +259,16 @@ export default function AdminContact() { return cat?.label || category; }; - // Admin-only access check (after all hooks) + // Show loading state while roles are being fetched + if (rolesLoading) { + return ( +
+

Loading...

+
+ ); + } + + // Admin-only access check (after loading complete) if (!isAdmin()) { return (