-
Notifications
You must be signed in to change notification settings - Fork 8.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: migrate api for team upgrade to App Router #19100
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Skipped Deployments
|
Graphite Automations"Add consumer team as reviewer" took an action on this PR • (02/04/25)1 reviewer was added to this PR based on Keith Williams's automation. "Add foundation team as reviewer" took an action on this PR • (02/06/25)1 reviewer was added to this PR based on Keith Williams's automation. |
9d6a062
to
f17db39
Compare
E2E results are ready! |
const searchParams = req.nextUrl.searchParams; | ||
const { team: id, session_id } = querySchema.parse({ | ||
team: params.team, | ||
session_id: searchParams.get("session_id"), | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replacing const { team: id, session_id } = querySchema.parse(req.query);
in the pages router api file
? `${WEBAPP_URL}/settings/organizations/profile?upgraded=true` | ||
: `${WEBAPP_URL}/settings/teams/${team.id}/profile?upgraded=true`; | ||
|
||
return NextResponse.redirect(redirectUrl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replacing res.redirect(302, redirectUrl);
in the pages router api file
const session = await getServerSession({ req: buildLegacyRequest(headers(), cookies()) }); | ||
|
||
if (!session) { | ||
return NextResponse.json({ message: "Team upgraded successfully" }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replacing { message: "Team upgraded successfully" };
team = await prisma.team.update({ where: { id }, data: { slug } }); | ||
} catch (error) { | ||
const { message, statusCode } = getRequestedSlugError(error, slug); | ||
return NextResponse.json({ message }, { status: statusCode }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replacing return res.status(statusCode).json({ message });
What does this PR do?
/api/teams/[team]/upgrade.ts
to App RouterMandatory Tasks (DO NOT REMOVE)
How should this be tested?
/api/teams/${this.team.id}/upgrade?session_id=${paymentId}
and see if teamId and session_id are being passed correctly.e.g., I went to
http://localhost:3000/api/teams/12/upgrade?session_id=1010
and hadconsole.log(params.team, searchParams.get("session_id"));
.result: