fix: team booking page having same slug as the org#12213
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
3 Ignored Deployments
|
|
Current dependencies on/for this PR:
This stack of pull requests is managed by Graphite. |
|
Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link to collect XP and win prizes! |
📦 Next.js Bundle Analysis for @calcom/webThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
351535c to
a83d319
Compare
Current Playwright Test Results Summary✅ 13 Passing - Run may still be in progress, this comment will be updated as current testing workflow or job completes... (Last updated on 11/14/2023 11:43:50am UTC) Run DetailsRunning Workflow PR Update on Github Actions Commit: 8754bee Started: 11/14/2023 11:42:45am UTC
|
| Test Case | Last 7 days Failures | Last 7 days Flakes |
|---|---|---|
|
Popup Tests should be able to reschedule
Retry 2 • Retry 1 • Initial Attempt |
16.13% (45)45 / 279 runsfailed over last 7 days |
79.57% (222)222 / 279 runsflaked over last 7 days |
56d3c7f to
59bc6d7
Compare
| if (!team) return null; | ||
| // HACK: I am not sure how to make Prisma in peace with TypeScript with this repository pattern | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| return team as any; |
There was a problem hiding this comment.
There is a return type on function already that should ensure that the function callers would get typesafey as long as this function is well tested.
59bc6d7 to
04164be
Compare
| // In cases where there are many teams with the same slug, we need to find out the one and only one that matches our criteria | ||
| .filter((team) => { | ||
| // We need an org if isOrgView otherwise we need a team | ||
| return isOrg ? team.metadata?.isOrganization : !team.metadata?.isOrganization; |
There was a problem hiding this comment.
This is what fixes the bug. So, even if we get wrong result, we validate it here and then reject it.
04164be to
e2fd525
Compare
There was a problem hiding this comment.
Edit: can be fixed in another PR
Screen.Recording.2023-11-07.at.9.06.46.PM.mov
I tried creating a team with same slug as my org and it was successfull but on the next page (onboard-members) I get an error. teams.create route returned already existing org instead of creating a team
e2fd525 to
7c93db8
Compare
Thanks I will take it up later. |
6e738ef to
8754bee
Compare

What does this PR do?
Fixes the bug where depending on which team would be fetched first by prisma(which is usually last-modified first), sometimes Org is served for a team page because of slug confusion
Also added a repository for team to kickoff moving to repository pattern for querying.
Motivation to move to the pattern along with this bug fix
metadata.isOrganizationto a column so that querying is faster and more reliable and then we would just need to modify the repository code.Type of change
How should this be tested?
Mandatory Tasks