mirror of
https://github.com/mudabbir-ahmad/peworkshop.git
synced 2026-10-07 19:50:20 +00:00
back to square 1. Now convert the json format info into readable webpage info
This commit is contained in:
1 parent
b039af238f
commit
68e9af2d83
6 files changed
+112
-50
No files matched your search
@@ -43,7 +43,10 @@ export default function CreateTeam() {
|
||||
try {
|
||||
const response = await fetch("/api/teams", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
credentials: "include", // Important for cookies
|
||||
body: JSON.stringify({ name: teamName }),
|
||||
});
|
||||
|
||||
@@ -53,7 +56,24 @@ export default function CreateTeam() {
|
||||
throw new Error(data.error || "Failed to create team");
|
||||
}
|
||||
|
||||
router.push(`/team/${data.teamId}`);
|
||||
// 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}`;
|
||||
}
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
setIsLoading(false);
|
||||
|
||||
Reference in new issue
Block a user