Add guest management functionality to existing bookings - #3
Conversation
* feat: ability to add guests via app.cal.com/bookings * fix: some update * fix: minor issue * fix: final update * update * update * add requested changes * fix type error * small update * final update * fix type error * fix location * update calender event --------- Co-authored-by: Somay Chauhan <somaychauhan98@gmail.com>
There was a problem hiding this comment.
Walkthrough
This PR implements a comprehensive feature for adding guests to existing bookings. The implementation includes a new UI dialog component with email validation, backend tRPC mutation handler with authorization checks, and email notification system. The feature allows authorized users (organizers, team admins, or attendees) to add multiple guests via email to calendar events. New guests receive scheduled event emails while existing attendees are notified of the additions. The system validates email uniqueness, updates calendar providers, and maintains booking integrity across recurring events and various booking configurations. A reusable MultiEmail form component is introduced to support the multi-email input functionality.
Changes
| File(s) | Summary |
|---|---|
apps/web/components/booking/BookingListItem.tsx |
Added 'Add Guests' menu item with user-plus icon in booking actions dropdown, integrated AddGuestsDialog component with state management for dialog visibility. |
apps/web/components/dialog/AddGuestsDialog.tsx |
Introduced new modal dialog component for adding guests with Zod email validation, tRPC mutation integration, loading states, toast notifications, and automatic cache invalidation. |
apps/web/public/static/locales/en/common.json |
Added i18n strings for guest addition feature including notification messages, email subject templates, error messages, and UI labels. |
packages/emails/email-manager.ts |
Added sendAddGuestsEmails function to send differentiated notifications to organizers, team members, newly added guests, and existing attendees. |
packages/emails/src/templates/AttendeeAddGuestsEmail.tsxpackages/emails/src/templates/OrganizerAddGuestsEmail.tsx |
Introduced specialized email template components wrapping existing scheduled email templates with customized props for add-guests notifications. |
packages/emails/templates/attendee-add-guests-email.tspackages/emails/templates/organizer-add-guests-email.ts |
Implemented email template classes extending scheduled email classes to generate ICS calendar attachments and localized notifications for guest additions. |
packages/emails/src/templates/index.ts |
Exported new OrganizerAddGuestsEmail and AttendeeAddGuestsEmail templates to public API. |
packages/trpc/server/routers/viewer/bookings/_router.tsx |
Added addGuests mutation endpoint with lazy-loaded handler and input schema validation. |
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts |
Implemented tRPC handler with authorization checks, guest validation, database updates, calendar synchronization, and email notifications. |
packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts |
Defined Zod schema for validating booking ID and guest email array inputs. |
packages/ui/form/MultiEmail.tsx |
Created dynamic multi-email input component with add/remove functionality, validation, and dark mode support. |
packages/ui/form/MultiEmailLazy.tsx |
Introduced lazy-loading wrapper for MultiEmail component using Next.js dynamic imports to optimize bundle size. |
packages/ui/index.tsx |
Exported MultiEmail component from UI package's main entry point. |
Sequence Diagram
This diagram shows the interactions between components:
sequenceDiagram
actor User
participant BookingDetails
participant MenuSystem
participant AddGuestsDialog
participant State
User->>BookingDetails: Views booking details page
BookingDetails->>State: Initialize isOpenAddGuestsDialog = false
BookingDetails->>MenuSystem: Render menu with "additional_guests" option
User->>MenuSystem: Clicks "additional_guests" menu item
MenuSystem->>BookingDetails: onClick handler triggered
BookingDetails->>State: setIsOpenAddGuestsDialog(true)
State-->>BookingDetails: State updated
BookingDetails->>AddGuestsDialog: Render with props<br/>(isOpenDialog, bookingId)
AddGuestsDialog->>User: Display dialog
alt User adds guests
User->>AddGuestsDialog: Submits guest information
Note over AddGuestsDialog: Guest addition logic<br/>(implementation in dialog)
AddGuestsDialog->>BookingDetails: Close dialog request
else User cancels
User->>AddGuestsDialog: Clicks cancel/close
AddGuestsDialog->>BookingDetails: Close dialog request
end
BookingDetails->>State: setIsOpenAddGuestsDialog(false)
State-->>BookingDetails: State updated
AddGuestsDialog->>User: Dialog closes
🔗 Cross-Repository Impact Analysis
Enable automatic detection of breaking changes across your dependent repositories. → Set up now
Learn more about Cross-Repository Analysis
What It Does
- Automatically identifies repositories that depend on this code
- Analyzes potential breaking changes across your entire codebase
- Provides risk assessment before merging to prevent cross-repo issues
How to Enable
- Visit Settings → Code Management
- Configure repository dependencies
- Future PRs will automatically include cross-repo impact analysis!
Benefits
- 🛡️ Prevent breaking changes across repositories
- 🔍 Catch integration issues before they reach production
- 📊 Better visibility into your multi-repo architecture
Install the extension
Note for Windsurf
Please change the default marketplace provider to the following in the windsurf settings:Marketplace Extension Gallery Service URL: https://marketplace.visualstudio.com/_apis/public/gallery
Marketplace Gallery Item URL: https://marketplace.visualstudio.com/items
Entelligence.ai can learn from your feedback. Simply add 👍 / 👎 emojis to teach it your preferences. More shortcuts below
Emoji Descriptions:
⚠️ Potential Issue - May require further investigation.- 🔒 Security Vulnerability - Fix to ensure system safety.
- 💻 Code Improvement - Suggestions to enhance code quality.
- 🔨 Refactor Suggestion - Recommendations for restructuring code.
- ℹ️ Others - General comments and information.
Interact with the Bot:
- Send a message or request using the format:
@entelligenceai + *your message*
Example: @entelligenceai Can you suggest improvements for this code?
- Help the Bot learn by providing feedback on its responses.
@entelligenceai + *feedback*
Example: @entelligenceai Do not comment on `save_auth` function !
Also you can trigger various commands with the bot by doing
@entelligenceai command
The current supported commands are
config- shows the current configretrigger_review- retriggers the review
More commands to be added soon.
|
|
||
| emailsToSend.push( | ||
| ...calendarEvent.attendees.map((attendee) => { | ||
| if (newGuests.includes(attendee.email)) { |
There was a problem hiding this comment.
Correctness: In sendAddGuestsEmails, both AttendeeScheduledEmail and AttendeeAddGuestsEmail are passed the calendarEvent object without respecting the hideCalendarNotes flag. This leaks private notes to attendees. Mirror the sanitization used in sendScheduledEmails: pass { ...calendarEvent, ...(calendarEvent.hideCalendarNotes && { additionalNotes: undefined }) } to these constructors.
🤖 AI Agent Prompt for Cursor/Windsurf
📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue
In `packages/emails/email-manager.ts` around line 541, update the new-guest branch in `sendAddGuestsEmails` so `AttendeeScheduledEmail` receives a sanitized event object that removes `additionalNotes` when `hideCalendarNotes` is true (same behavior as `sendScheduledEmails`). Apply the provided diff and keep formatting consistent.
|
|
||
| const isTeamAdminOrOwner = | ||
| (await isTeamAdmin(user.id, booking.eventType?.teamId ?? 0)) && |
There was a problem hiding this comment.
Correctness: The isTeamAdminOrOwner check (lines 48-50) uses &&, which requires a user to be both an admin and an owner. This will incorrectly block team admins who are not owners. Change && to ||.
🤖 AI Agent Prompt for Cursor/Windsurf
📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue
In `packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts` around lines 45-47, change the admin/owner permission check to use logical OR instead of AND so either role grants access. Apply the provided diff exactly.
Test 10nn
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.
nn---n*Replicated from [ai-code-review-evaluation/cal.com-coderabbit#10](https://github.com/ai-code-review-evaluation/cal.com-coderabbit/pull/10)*EntelligenceAI PR Summary
This PR adds functionality to add guests to existing bookings with full email notification support and calendar synchronization.