From 366f8d014fa95ffcc35fcecfab6077022c25e67a Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Tue, 14 Oct 2025 04:21:37 +0000 Subject: [PATCH] Add loader for opportunity applications cgen-167be79652424f1f9ee00e3c22b7c2e6 --- client/pages/Admin.tsx | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/client/pages/Admin.tsx b/client/pages/Admin.tsx index 67b3dd72..806add5e 100644 --- a/client/pages/Admin.tsx +++ b/client/pages/Admin.tsx @@ -157,6 +157,42 @@ export default function Admin() { loadProjectApplications().catch(() => undefined); }, [loadProjectApplications]); + const loadOpportunityApplications = useCallback(async () => { + const email = user?.email?.toLowerCase(); + if (!email) return; + setOpportunityApplicationsLoading(true); + try { + const response = await fetch( + `/api/opportunities/applications?email=${encodeURIComponent(email)}`, + ); + if (response.ok) { + const data = await response.json(); + setOpportunityApplications(Array.isArray(data) ? data : []); + } else { + const message = await response.text().catch(() => ""); + if (response.status === 403) { + aethexToast.error({ + title: "Access denied", + description: + "You must be signed in as the owner to view opportunity applications.", + }); + } else { + console.warn("Opportunity applications request failed:", message); + } + setOpportunityApplications([]); + } + } catch (error) { + console.warn("Failed to load opportunity applications:", error); + setOpportunityApplications([]); + } finally { + setOpportunityApplicationsLoading(false); + } + }, [user?.email]); + + useEffect(() => { + loadOpportunityApplications().catch(() => undefined); + }, [loadOpportunityApplications]); + useEffect(() => { if (!loading) { if (!user) {