added map page files and fixed code so that when an admin starts the timer the user can move on and isnt accidentally being redirected to the page to show that the timer isn't active even though it is

This commit is contained in:
bobbert committed 2025-03-14 15:39:05 +00:00
1 parent 6b233c90e7
commit 6ad943a868
7 files changed
+965 -39

No files matched your search

+16 -17
View File
@@ -233,26 +233,25 @@ export default function TeamPage({ params }) {
onClick={async () => {
try {
setLoading(true);
if (!huntActive) {
// If hunt is not active, redirect to the "not started" page
router.push(`/hunt-not-started?teamId=${teamId}`);
} else {
// If hunt is active, try to start the hunt
const response = await fetch(
`/api/teams/${teamId}/start-hunt`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
credentials: "include",
}
);
if (response.ok) {
fetchTeamData();
// Check hunt status first
const response = await fetch("/api/hunt-status", {
method: "GET",
headers: { "Content-Type": "application/json" },
credentials: "include",
});
if (response.ok) {
const data = await response.json();
if (data.active) {
// If hunt is active, navigate to map page
router.push("/map");
} else {
const error = await response.json();
throw new Error(error.message || "Failed to start hunt");
// If hunt is not active, show not started page
router.push(`/hunt-not-started?teamId=${teamId}`);
}
} else {
throw new Error("Failed to check hunt status");
}
} catch (err) {
setError(err.message);