Skip to content

fix: booking fields being overridden whenever saving with atom#19339

Merged
PeerRich merged 4 commits intomainfrom
fix-event-type-atom-bug
Feb 21, 2025
Merged

fix: booking fields being overridden whenever saving with atom#19339
PeerRich merged 4 commits intomainfrom
fix-event-type-atom-bug

Conversation

@Ryukemeister
Copy link
Copy Markdown
Contributor

What does this PR do?

  • Fixes a bug in event type settings atom where previous booking fields would get lost everytime we make some changes to event type settings and try to save again.

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.
  • (N/A) I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

This can be tested in the examples app for atoms

@Ryukemeister Ryukemeister requested a review from a team February 18, 2025 16:09
@keithwillcode keithwillcode added core area: core, team members only platform Anything related to our platform plan labels Feb 18, 2025
@dosubot dosubot Bot added event-types area: event types, event-types 🐛 bug Something isn't working labels Feb 18, 2025
if (
!bookingFields.find((field) => field.type === "email") &&
!bookingFields.find((field) => field.type === "phone")
) {
Copy link
Copy Markdown
Contributor

@supalarry supalarry Feb 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instead of removing code we need to modify it - the removed code exists to ensure that if booking fields are passed that either email or phone fields are defined, because if none of them are defined then the updateEventType from platform libraries which is this function packages/trpc/server/routers/viewer/eventTypes/update.handler.ts will fail because of check ensureEmailOrPhoneNumberIsPresent.

Instead we need to say - ensure that email or phone is present only if body.bookingFields are provided.

await this.checkCanUpdateTeamEventType(user.id, eventTypeId, teamId, body.scheduleId);
    const eventTypeUser = await this.eventTypeService.getUserToUpdateEvent(user);
    const bookingFields = body.bookingFields ? [...body.bookingFields] : undefined;

    if (
      bookingFields?.length &&
      !bookingFields.find((field) => field.type === "email") &&
      !bookingFields.find((field) => field.type === "phone")
    ) {
      bookingFields.push(systemBeforeFieldEmail);
    }

    const eventType = await updateEventType({
      input: { id: eventTypeId, ...body, bookingFields }, 

@github-actions github-actions Bot marked this pull request as draft February 19, 2025 07:39
@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 20, 2025

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

Name Status Preview Comments Updated (UTC)
cal-com-ui-playground ❌ Failed (Inspect) Feb 20, 2025 3:10pm
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Feb 20, 2025 3:10pm
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Feb 20, 2025 3:10pm

@Ryukemeister Ryukemeister marked this pull request as ready for review February 20, 2025 09:16
@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented Feb 20, 2025

Graphite Automations

"Add ready-for-e2e label" took an action on this PR • (02/20/25)

1 label was added to this PR based on Keith Williams's automation.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 20, 2025

E2E results are ready!

@Ryukemeister
Copy link
Copy Markdown
Contributor Author

tested it, good to merge :)

@PeerRich PeerRich merged commit 46f73e7 into main Feb 21, 2025
@PeerRich PeerRich deleted the fix-event-type-atom-bug branch February 21, 2025 11:42
MuhammadAimanSulaiman pushed a commit to hit-pay/cal.com that referenced this pull request Feb 25, 2025
itsalam pushed a commit to itsalam/cal.com that referenced this pull request Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working core area: core, team members only event-types area: event types, event-types platform Anything related to our platform plan ready-for-e2e

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants