mirror of
https://github.com/mudabbir-ahmad/peworkshop.git
synced 2026-10-08 03:50:21 +00:00
FIX OF ALL ISSUES WITH LOG IN PAGE. EVERYTHING TO THE POINT OF TESTING THE MAP WORKS SO FAR.
This commit is contained in:
1 parent
84f010cb87
commit
c79a9636a7
10 files changed
+228
-233
No files matched your search
@@ -15,8 +15,8 @@ export default function CreateTeam() {
|
||||
|
||||
useEffect(() => {
|
||||
if (status === "authenticated") {
|
||||
if (session.user.teamId) {
|
||||
router.push(`/team/${session.user.teamId}`);
|
||||
if (session?.user?.teamId) {
|
||||
router.push(`/${session.user.teamId}`);
|
||||
} else {
|
||||
setIsLoading(false);
|
||||
}
|
||||
@@ -31,12 +31,17 @@ export default function CreateTeam() {
|
||||
setError("");
|
||||
|
||||
try {
|
||||
// Add a check to ensure session is valid
|
||||
if (status !== "authenticated") {
|
||||
throw new Error("You must be logged in to create a team");
|
||||
}
|
||||
|
||||
const response = await fetch("/api/teams", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
credentials: "include",
|
||||
credentials: "include", // Important: include credentials
|
||||
body: JSON.stringify({ name: teamName }),
|
||||
});
|
||||
|
||||
@@ -46,12 +51,18 @@ export default function CreateTeam() {
|
||||
throw new Error(data.error || "Failed to create team");
|
||||
}
|
||||
|
||||
// Navigate with the correct URL pattern for the page component
|
||||
console.log("Team created successfully with ID:", data.teamId);
|
||||
|
||||
// Hard navigation to make sure we're going to the page component not the API route
|
||||
// Force a session refresh to update the session with the new teamId
|
||||
await fetch("/api/auth/session", {
|
||||
method: "GET",
|
||||
credentials: "include",
|
||||
});
|
||||
|
||||
// Hard navigation to make sure we're going to the right page
|
||||
window.location.href = `/${data.teamId}`;
|
||||
} catch (err) {
|
||||
console.error("Team creation error:", err);
|
||||
setError(err.message);
|
||||
setIsLoading(false);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user