mirror of
https://github.com/mudabbir-ahmad/peworkshop.git
synced 2026-10-07 19:50:20 +00:00
fixed a bit of stuff the current but API is broken again for logging in so will be fixing that with the next push
This commit is contained in:
1 parent
6ad943a868
commit
ea38775a82
20 files changed
+1643
-1027
No files matched your search
+25
-69
@@ -194,8 +194,6 @@ export default function TeamPage({ params }) {
|
||||
) : (
|
||||
<div className="empty-state">No team members found</div>
|
||||
)}
|
||||
|
||||
{/* Remove the add member button - it was here before */}
|
||||
</div>
|
||||
|
||||
<div className="team-actions">
|
||||
@@ -243,61 +241,31 @@ export default function TeamPage({ params }) {
|
||||
try {
|
||||
setLoading(true);
|
||||
|
||||
if (!huntActive) {
|
||||
// If hunt is not active, redirect to the "not started" page
|
||||
// Use the dedicated start hunt API endpoint
|
||||
const response = await fetch("/api/hunt/start", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Cache-Control": "no-cache, no-store, must-revalidate",
|
||||
},
|
||||
credentials: "include",
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success && data.active) {
|
||||
// Redirect to map page using window.location for a clean reload
|
||||
window.location.href = data.redirectUrl || "/map";
|
||||
} else if (!data.active) {
|
||||
// Hunt is not active
|
||||
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();
|
||||
} else {
|
||||
const error = await response.json();
|
||||
throw new Error(error.message || "Failed to start hunt");
|
||||
}
|
||||
// Some other error
|
||||
throw new Error(data.error || "Failed to start hunt journey");
|
||||
}
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
setLoading(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
Start Hunt
|
||||
</button>
|
||||
)}
|
||||
|
||||
{/* Keep the admin start button which directly starts the hunt */}
|
||||
{session?.user?.role === "admin" && (
|
||||
<button
|
||||
className="action-button start-button"
|
||||
onClick={async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const response = await fetch(
|
||||
`/api/teams/${teamId}/start-hunt`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
credentials: "include",
|
||||
}
|
||||
);
|
||||
|
||||
if (response.ok) {
|
||||
fetchTeamData();
|
||||
} else {
|
||||
const error = await response.json();
|
||||
throw new Error(error.message || "Failed to start hunt");
|
||||
}
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
console.error("Error starting hunt:", err);
|
||||
setError(`Failed to start hunt: ${err.message}`);
|
||||
setLoading(false);
|
||||
}
|
||||
}}
|
||||
@@ -352,7 +320,7 @@ export default function TeamPage({ params }) {
|
||||
.team-info {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
justify-content: space-between; /* This spreads items to opposite ends */
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
@@ -360,13 +328,14 @@ export default function TeamPage({ params }) {
|
||||
margin: 0;
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
color: white; /* Explicitly setting color to white */
|
||||
}
|
||||
|
||||
.team-code {
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
margin-left: auto;
|
||||
color: white; /* Ensuring team code is also white */
|
||||
margin-left: auto; /* Pushes the code to the right */
|
||||
}
|
||||
|
||||
.members-container {
|
||||
@@ -411,19 +380,6 @@ export default function TeamPage({ params }) {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.add-member-button {
|
||||
background-color: #68543c;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
padding: 15px;
|
||||
margin-top: 20px;
|
||||
width: 100%;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.team-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
|
||||
Reference in new issue
Block a user