diff --git a/app/(main)/team/[teamId]/page.js b/app/(main)/team/[teamId]/page.js index 9ebcdb2..a20d048 100644 --- a/app/(main)/team/[teamId]/page.js +++ b/app/(main)/team/[teamId]/page.js @@ -10,9 +10,27 @@ export default function TeamPage({ params }) { const [teamMembers, setTeamMembers] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(""); + const [huntActive, setHuntActive] = useState(false); const router = useRouter(); const { teamId } = params; + const checkHuntStatus = useCallback(async () => { + try { + const response = await fetch("/api/hunt-status", { + method: "GET", + headers: { "Content-Type": "application/json" }, + credentials: "include", + }); + + if (response.ok) { + const data = await response.json(); + setHuntActive(data.active || false); + } + } catch (err) { + console.error("Failed to check hunt status:", err); + } + }, []); + const fetchTeamData = useCallback(async () => { try { if (!teamId || isNaN(parseInt(teamId, 10))) { @@ -63,7 +81,9 @@ export default function TeamPage({ params }) { } finally { setLoading(false); } - }, [teamId, router]); + + await checkHuntStatus(); + }, [teamId, router, checkHuntStatus]); useEffect(() => { // Only attempt to fetch data when session is ready and we have a teamId @@ -141,13 +161,6 @@ export default function TeamPage({ params }) { ) : (