cal.com
cal.com copied to clipboard
fix: unable to create managed eventtype via api v1
What does this PR do?
Fixes: #15179
This PR introduces changes to event type creation via api logic. This handles cases to make sure manged event type is created with data consistency as while creating with web. teamId and userId were both set for a eventype before the fix , which is not the case while using web
Before : Loom Video : View After : Loom Video : View
Mandatory Tasks (DO NOT REMOVE)
- [x] I have self-reviewed the code (A decent size PR without self-review might be rejected)
- [ ] I have added a Docs issue here if this PR makes changes that would require a documentation change
- [ ] I have added or modified automated tests that prove my fix is effective or that my feature works (PRs might be rejected if logical changes are not properly tested)
How should this be tested?
-Create a managed event type via api v1 for a team -set userId and create a event type for one of team memebers -event type will be created for team members as required -error occurs before the fix
Checklist
Someone is attempting to deploy a commit to the cal Team on Vercel.
A member of the Team first needs to authorize it.
Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link.
Graphite Automations
"Add community label" took an action on this PR • (05/23/24)
1 label was added to this PR based on Keith Williams's automation.
"Add consumer team as reviewer" took an action on this PR • (05/23/24)
1 reviewer was added to this PR based on Keith Williams's automation.
"Add foundation team as reviewer" took an action on this PR • (07/22/24)
1 reviewer was added to this PR based on Keith Williams's automation.
"Add platform team as reviewer" took an action on this PR • (08/15/24)
1 reviewer was added to this PR based on Keith Williams's automation.
This PR is being marked as stale due to inactivity.
Applied suggested changes , added check for team permissions PTAL @Amit91848
Changes look good @Shaik-Sirajuddin apart from the error below. Left a small suggestion too. When I use some other team id where I am not a owner/admin to create event, I get this error
Updated error message
📦 Next.js Bundle Analysis for @calcom/web
This analysis was generated by the Next.js Bundle Analysis action. 🤖
Eighty-four Pages Changed Size
The following pages changed size from the code in this PR compared to its base branch:
| Page | Size (compressed) | First Load | % of Budget (350 KB) |
|---|---|---|---|
/apps |
277.25 KB |
504.95 KB | 144.27% (🟢 -1.98%) |
/apps/[slug] |
294.63 KB |
522.33 KB | 149.24% (🟢 -2.04%) |
/apps/[slug]/[...pages] |
587.01 KB |
814.71 KB | 232.78% (🟢 -1.62%) |
/apps/categories |
254.3 KB |
482 KB | 137.72% (🟢 -1.79%) |
/apps/categories/[category] |
259.11 KB |
486.81 KB | 139.09% (🟢 -2.06%) |
/apps/installation/[[...step]] |
467.08 KB |
694.79 KB | 198.51% (🔴 +85.55%) |
/apps/installed/[category] |
278.23 KB |
505.94 KB | 144.55% (🟢 -1.82%) |
/auth/saml-idp |
12.22 KB |
239.93 KB | 68.55% (🟢 -20.80%) |
/availability |
426.65 KB |
654.35 KB | 186.96% (🟢 -1.65%) |
/availability/[schedule] |
410.51 KB |
638.22 KB | 182.35% (🟢 -1.66%) |
/booking/[uid] |
236.5 KB |
464.21 KB | 132.63% (🟡 +0.15%) |
/booking/[uid]/embed |
236.51 KB |
464.21 KB | 132.63% (🟡 +0.15%) |
/bookings/[status] |
324.3 KB |
552.01 KB | 157.72% (🟢 -1.69%) |
/enterprise |
254.35 KB |
482.06 KB | 137.73% (🟢 -1.78%) |
/event-types |
559.6 KB |
787.31 KB | 224.95% (🟢 -1.65%) |
/event-types/[type] |
435.38 KB |
663.09 KB | 189.45% (🟢 -1.75%) |
/getting-started/[[...step]] |
448.15 KB |
675.85 KB | 193.10% (🟡 +10.72%) |
/insights |
474.29 KB |
702 KB | 200.57% (🟢 -1.78%) |
/more |
253.86 KB |
481.56 KB | 137.59% (🟢 -1.79%) |
/settings/admin |
260.33 KB |
488.03 KB | 139.44% (🟢 -1.76%) |
/settings/admin/apps |
273.71 KB |
501.41 KB | 143.26% (🟢 -1.75%) |
/settings/admin/apps/[category] |
273.69 KB |
501.4 KB | 143.26% (🟢 -1.75%) |
/settings/admin/flags |
264.16 KB |
491.86 KB | 140.53% (🟢 -1.76%) |
/settings/admin/impersonation |
260.72 KB |
488.42 KB | 139.55% (🟢 -1.76%) |
/settings/admin/lockedSMS |
281.81 KB |
509.52 KB | 145.58% (🟢 -1.74%) |
/settings/admin/lockedSMS/lockedSMSView |
119.51 KB |
347.22 KB | 99.21% (🟢 -0.16%) |
/settings/admin/oAuth |
272.44 KB |
500.14 KB | 142.90% (🟢 -1.76%) |
/settings/admin/oAuth/oAuthView |
95.41 KB |
323.12 KB | 92.32% (🟢 -0.20%) |
/settings/admin/orgMigrations/_OrgMigrationLayout |
249.11 KB |
476.82 KB | 136.23% (🟢 -1.80%) |
/settings/admin/orgMigrations/moveTeamToOrg |
299.03 KB |
526.73 KB | 150.50% (🟢 -1.74%) |
/settings/admin/orgMigrations/moveUserToOrg |
318.86 KB |
546.56 KB | 156.16% (🟢 -1.71%) |
/settings/admin/orgMigrations/removeTeamFromOrg |
298.79 KB |
526.5 KB | 150.43% (🟢 -1.74%) |
/settings/admin/orgMigrations/removeUserFromOrg |
298.8 KB |
526.51 KB | 150.43% (🟢 -1.74%) |
/settings/admin/organizations |
262.21 KB |
489.92 KB | 139.98% (🟢 -1.77%) |
/settings/admin/organizations/[id]/edit |
260.87 KB |
488.58 KB | 139.59% (🟢 -1.76%) |
/settings/admin/users |
262.98 KB |
490.69 KB | 140.20% (🟢 -1.76%) |
/settings/admin/users/[id]/edit |
392.19 KB |
619.89 KB | 177.11% (🟢 -1.72%) |
/settings/admin/users/add |
391.85 KB |
619.56 KB | 177.02% (🟢 -1.73%) |
/settings/billing |
260.53 KB |
488.24 KB | 139.50% (🟢 -1.77%) |
/settings/developer/api-keys |
264.93 KB |
492.63 KB | 140.75% (🟢 -1.76%) |
/settings/developer/webhooks |
265.1 KB |
492.8 KB | 140.80% (🟢 -1.76%) |
/settings/developer/webhooks/[id] |
266.08 KB |
493.79 KB | 141.08% (🟢 -1.74%) |
/settings/developer/webhooks/new |
266.11 KB |
493.81 KB | 141.09% (🟢 -1.75%) |
/settings/my-account/appearance |
313.54 KB |
541.25 KB | 154.64% (🟢 -1.75%) |
/settings/my-account/calendars |
271.95 KB |
499.66 KB | 142.76% (🟢 -1.80%) |
/settings/my-account/conferencing |
272.86 KB |
500.56 KB | 143.02% (🟢 -1.80%) |
/settings/my-account/general |
376.03 KB |
603.74 KB | 172.50% (🟢 -1.76%) |
/settings/my-account/out-of-office |
265.56 KB |
493.26 KB | 140.93% (🟢 -1.76%) |
/settings/my-account/profile |
408.55 KB |
636.25 KB | 181.79% (🟢 -1.74%) |
/settings/organizations/[id]/about |
159.71 KB |
387.41 KB | 110.69% (🟡 +0.48%) |
/settings/organizations/[id]/add-teams |
159.7 KB |
387.4 KB | 110.69% (🟡 +0.48%) |
/settings/organizations/admin-api |
260.48 KB |
488.19 KB | 139.48% (🟢 -1.76%) |
/settings/organizations/appearance |
122.37 KB |
350.08 KB | 100.02% (🟢 -48.01%) |
/settings/organizations/billing |
260.57 KB |
488.27 KB | 139.51% (🟢 -1.76%) |
/settings/organizations/dsync |
293.19 KB |
520.9 KB | 148.83% (🟢 -1.76%) |
/settings/organizations/general |
348.88 KB |
576.58 KB | 164.74% (🟢 -1.76%) |
/settings/organizations/members |
400.05 KB |
627.76 KB | 179.36% (🟢 -1.75%) |
/settings/organizations/new |
159.71 KB |
387.42 KB | 110.69% (🟡 +0.48%) |
/settings/organizations/privacy |
266.08 KB |
493.79 KB | 141.08% (🟢 -1.76%) |
/settings/organizations/profile |
417.09 KB |
644.79 KB | 184.23% (🟡 +2.84%) |
/settings/organizations/sso |
271.16 KB |
498.86 KB | 142.53% (🟢 -1.76%) |
/settings/organizations/teams/other |
261.39 KB |
489.1 KB | 139.74% (🟢 -1.76%) |
/settings/organizations/teams/other/[id]/appearance |
273.3 KB |
501.01 KB | 143.15% (🟢 -1.72%) |
/settings/organizations/teams/other/[id]/members |
267.99 KB |
495.7 KB | 141.63% (🟢 -1.76%) |
/settings/organizations/teams/other/[id]/profile |
471.76 KB |
699.47 KB | 199.85% (🟢 -1.74%) |
/settings/platform |
258.96 KB |
486.66 KB | 139.05% (🟢 -1.79%) |
/settings/platform/new |
120.72 KB |
348.42 KB | 99.55% (🟡 +0.52%) |
/settings/platform/oauth-clients/[clientId]/edit |
257.26 KB |
484.97 KB | 138.56% (🟢 -1.78%) |
/settings/platform/oauth-clients/create |
256.41 KB |
484.11 KB | 138.32% (🟢 -1.79%) |
/settings/security/impersonation |
265.74 KB |
493.44 KB | 140.98% (🟢 -1.76%) |
/settings/security/password |
303.92 KB |
531.63 KB | 151.89% (🟢 -1.73%) |
/settings/security/sso |
270.61 KB |
498.31 KB | 142.38% (🟢 -1.77%) |
/settings/security/two-factor-auth |
269.21 KB |
496.92 KB | 141.98% (🟢 -1.76%) |
/settings/teams |
260.06 KB |
487.77 KB | 139.36% (🟢 -1.76%) |
/settings/teams/[id]/appearance |
273.29 KB |
501 KB | 143.14% (🟢 -1.71%) |
/settings/teams/[id]/billing |
260.57 KB |
488.27 KB | 139.51% (🟢 -1.77%) |
/settings/teams/[id]/members |
378.12 KB |
605.82 KB | 173.09% (🟢 -1.75%) |
/settings/teams/[id]/profile |
472.6 KB |
700.3 KB | 200.09% (🟢 -1.73%) |
/settings/teams/new |
193.05 KB |
420.76 KB | 120.22% (🟢 -1.82%) |
/teams |
254.08 KB |
481.79 KB | 137.65% (🟢 -1.78%) |
/upgrade |
254.21 KB |
481.91 KB | 137.69% (🟢 -1.78%) |
/video/[uid] |
291.31 KB |
519.02 KB | 148.29% (🟢 -0.14%) |
/workflows |
286.11 KB |
513.82 KB | 146.80% (🟢 -1.72%) |
/workflows/[workflow] |
414.4 KB |
642.1 KB | 183.46% (🟢 -1.51%) |
Details
Only the gzipped size is provided here based on an expert tip.
First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.
Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis
The "Budget %" column shows what percentage of your performance budget the First Load total takes up. For example, if your budget was 100kb, and a given page's first load size was 10kb, it would be 10% of your budget. You can also see how much this has increased or decreased compared to the base branch of your PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this. If you see "+/-
Converting the PR to Draft, in order to get this PR approved
-
please refactor the code so that we have clear path defined, and that we return early whenever possible
- avoid checking isSystemWideAdmin multiple times, check once and return early
- avoid checking for the same prop in multiple if cases, write clear code path (teamId is defined / teamId is not defined,...), using if statements, early return, and function to aggregate the logic reused in different paths
-
add e2e tests
This PR is being marked as stale due to inactivity.
Hey @ThyMinimalDev ! I think @Shaik-Sirajuddin is busy, so I have made some changes as you suggested. I wasn't sure how to add e2e as there were no other e2e tests present in v1, would integration tests work?
Yes, let's do integration tests since we already have support for that in v1 and CI.
@Shaik-Sirajuddin We really appreciate this contribution but since API v2 supports creating managed event types, we will not be adding this to v1.
