Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

hbjORbj
Copy link
Contributor

@hbjORbj hbjORbj commented Feb 4, 2025

What does this PR do?

  • Migrates /api/teams/[team]/upgrade.ts to App Router
  • Other than the comments I left, all code stays the same

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • N/A - I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • Try calling /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 had console.log(params.team, searchParams.get("session_id"));.

result:

Screenshot 2025-02-06 at 5 53 23 PM

@graphite-app graphite-app bot requested a review from a team February 4, 2025 18:26
@keithwillcode keithwillcode added consumer core area: core, team members only labels Feb 4, 2025
Copy link

vercel bot commented Feb 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
cal-com-ui-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 6, 2025 11:05pm
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Feb 6, 2025 11:05pm
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Feb 6, 2025 11:05pm

@hbjORbj hbjORbj changed the title chore: migrate api team upgrade chore: migrate api for team upgrade to App Router Feb 4, 2025
@hbjORbj hbjORbj marked this pull request as draft February 4, 2025 18:26
@dosubot dosubot bot added api area: API, enterprise API, access token, OAuth teams area: teams, round robin, collective, managed event-types labels Feb 4, 2025
@hbjORbj hbjORbj added the high-risk Requires approval by Foundation team label Feb 4, 2025
Copy link

graphite-app bot commented Feb 4, 2025

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.

Copy link
Contributor

github-actions bot commented Feb 4, 2025

E2E results are ready!

Comment on lines +24 to +28
const searchParams = req.nextUrl.searchParams;
const { team: id, session_id } = querySchema.parse({
team: params.team,
session_id: searchParams.get("session_id"),
});
Copy link
Contributor Author

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);
Copy link
Contributor Author

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" });
Copy link
Contributor Author

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 });
Copy link
Contributor Author

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 });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api area: API, enterprise API, access token, OAuth consumer core area: core, team members only high-risk Requires approval by Foundation team ready-for-e2e teams area: teams, round robin, collective, managed event-types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants