mirror of
https://github.com/mudabbir-ahmad/peworkshop.git
synced 2026-10-08 03:50:21 +00:00
TEAM PAGE WORKS WITH 1 ERROR WOOOOOOOO
This commit is contained in:
1 parent
68e9af2d83
commit
6b87e0f7fb
5 files changed
+284
-234
No files matched your search
@@ -46,7 +46,7 @@ export default function CreateTeam() {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
credentials: "include", // Important for cookies
|
||||
credentials: "include",
|
||||
body: JSON.stringify({ name: teamName }),
|
||||
});
|
||||
|
||||
@@ -56,24 +56,11 @@ export default function CreateTeam() {
|
||||
throw new Error(data.error || "Failed to create team");
|
||||
}
|
||||
|
||||
// Force a session update to get the new teamId
|
||||
try {
|
||||
// Update the client-side session data with the new teamId
|
||||
if (session && session.user) {
|
||||
session.user.teamId = data.teamId;
|
||||
}
|
||||
|
||||
console.log("Team created successfully, redirecting to:", `/team/${data.teamId}`);
|
||||
|
||||
// Add a small delay to allow session update
|
||||
setTimeout(() => {
|
||||
router.push(`/team/${data.teamId}`);
|
||||
}, 100);
|
||||
} catch (navError) {
|
||||
console.error("Navigation error:", navError);
|
||||
// Fallback to direct navigation
|
||||
window.location.href = `/team/${data.teamId}`;
|
||||
}
|
||||
// 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
|
||||
window.location.href = `/${data.teamId}`;
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
setIsLoading(false);
|
||||
|
||||
Reference in new issue
Block a user