-
Notifications
You must be signed in to change notification settings - Fork 0
Add guest management functionality to existing bookings #2
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
base: guest-management-base
Are you sure you want to change the base?
Add guest management functionality to existing bookings #2
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 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
Greptile OverviewConfidence Score: 1/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant BookingListItem
participant AddGuestsDialog
participant MultiEmail
participant tRPC
participant addGuestsHandler
participant Prisma
participant EventManager
participant EmailService
User->>BookingListItem: Click "Additional Guests"
BookingListItem->>AddGuestsDialog: Open dialog
AddGuestsDialog->>MultiEmail: Render email inputs
User->>MultiEmail: Enter guest emails
MultiEmail->>AddGuestsDialog: Update email array
User->>AddGuestsDialog: Click "Add"
AddGuestsDialog->>AddGuestsDialog: Validate emails (zod)
AddGuestsDialog->>tRPC: addGuests.mutate({bookingId, guests})
tRPC->>addGuestsHandler: Route to handler
addGuestsHandler->>Prisma: Fetch booking with attendees
Prisma-->>addGuestsHandler: Return booking data
addGuestsHandler->>addGuestsHandler: Check authorization (admin/owner/organizer/attendee)
addGuestsHandler->>addGuestsHandler: Filter unique guests & blacklist
addGuestsHandler->>Prisma: Create new attendees
Prisma-->>addGuestsHandler: Return updated booking
addGuestsHandler->>EventManager: updateCalendarAttendees(evt, booking)
EventManager-->>addGuestsHandler: Calendar updated
addGuestsHandler->>EmailService: sendAddGuestsEmails(evt, guests)
EmailService->>EmailService: Send OrganizerAddGuestsEmail
EmailService->>EmailService: Send AttendeeScheduledEmail (new guests)
EmailService->>EmailService: Send AttendeeAddGuestsEmail (existing)
EmailService-->>addGuestsHandler: Emails sent
addGuestsHandler-->>tRPC: Success response
tRPC-->>AddGuestsDialog: onSuccess callback
AddGuestsDialog->>AddGuestsDialog: Show success toast
AddGuestsDialog->>AddGuestsDialog: Close dialog & reset
AddGuestsDialog->>tRPC: Invalidate bookings cache
tRPC->>BookingListItem: Refresh booking data
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
15 files reviewed, 3 comments
| const isTeamAdminOrOwner = | ||
| (await isTeamAdmin(user.id, booking.eventType?.teamId ?? 0)) && | ||
| (await isTeamOwner(user.id, booking.eventType?.teamId ?? 0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: incorrect logic - user must be both admin AND owner (impossible), should be OR
| const isTeamAdminOrOwner = | |
| (await isTeamAdmin(user.id, booking.eventType?.teamId ?? 0)) && | |
| (await isTeamOwner(user.id, booking.eventType?.teamId ?? 0)); | |
| const isTeamAdminOrOwner = | |
| (await isTeamAdmin(user.id, booking.eventType?.teamId ?? 0)) || | |
| (await isTeamOwner(user.id, booking.eventType?.teamId ?? 0)); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts
Line: 46:48
Comment:
**logic:** incorrect logic - user must be both admin AND owner (impossible), should be OR
```suggestion
const isTeamAdminOrOwner =
(await isTeamAdmin(user.id, booking.eventType?.teamId ?? 0)) ||
(await isTeamOwner(user.id, booking.eventType?.teamId ?? 0));
```
How can I resolve this? If you propose a fix, please make it concise.| const uniqueGuests = guests.filter( | ||
| (guest) => | ||
| !booking.attendees.some((attendee) => guest === attendee.email) && | ||
| !blacklistedGuestEmails.includes(guest) | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: empty strings not filtered - if user enters and removes emails in UI, empty strings reach backend
| const uniqueGuests = guests.filter( | |
| (guest) => | |
| !booking.attendees.some((attendee) => guest === attendee.email) && | |
| !blacklistedGuestEmails.includes(guest) | |
| ); | |
| const uniqueGuests = guests | |
| .filter((guest) => guest.trim().length > 0) | |
| .filter( | |
| (guest) => | |
| !booking.attendees.some((attendee) => guest === attendee.email) && | |
| !blacklistedGuestEmails.includes(guest.toLowerCase()) | |
| ); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts
Line: 74:78
Comment:
**logic:** empty strings not filtered - if user enters and removes emails in UI, empty strings reach backend
```suggestion
const uniqueGuests = guests
.filter((guest) => guest.trim().length > 0)
.filter(
(guest) =>
!booking.attendees.some((attendee) => guest === attendee.email) &&
!blacklistedGuestEmails.includes(guest.toLowerCase())
);
```
How can I resolve this? If you propose a fix, please make it concise.| const validationResult = ZAddGuestsInputSchema.safeParse(multiEmailValue); | ||
| if (validationResult.success) { | ||
| addGuestsMutation.mutate({ bookingId, guests: multiEmailValue }); | ||
| } else { | ||
| setIsInvalidEmail(true); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: validation doesn't filter empty strings before checking uniqueness and emails
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/web/components/dialog/AddGuestsDialog.tsx
Line: 52:57
Comment:
**logic:** validation doesn't filter empty strings before checking uniqueness and emails
How can I resolve this? If you propose a fix, please make it concise.
Test 10
Replicated from ai-code-review-evaluation/cal.com-greptile#10