Skip to content

Hide other attendees on event types with seats#4766

Merged
zomars merged 57 commits intomainfrom
seats-hide-attendees
Oct 18, 2022
Merged

Hide other attendees on event types with seats#4766
zomars merged 57 commits intomainfrom
seats-hide-attendees

Conversation

@joeauyeung
Copy link
Copy Markdown
Contributor

What does this PR do?

This PR allows hiding attendee information from other attendees on event types with seats. The .ics file that is generated for attendees will also not contain other attendee information as well.

image

Fixes # (issue)

Environment: Staging(main branch) / Production

Type of change

  • New feature (non-breaking change which adds functionality)

How should this be tested?

  • Edit an event type to contain seats and check the box to hide attendee information
  • Book at least two seats in one time slot
    • In the second email you should see the .ics file for the organizer contains two attendees while the .ics file to the attendee should only contain their information and the organizer'
  • Now disable hide attendee information
  • When booking seats in the same time slot the attendee information should stack

Checklist

  • I haven't added tests that prove my fix is effective or that my feature works
  • I haven't checked if new and existing unit tests pass locally with my changes

@vercel
Copy link
Copy Markdown

vercel Bot commented Sep 29, 2022

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

Name Status Preview Updated
cal ✅ Ready (Inspect) Visit Preview Oct 18, 2022 at 6:38PM (UTC)

Comment on lines +120 to +121
name: bookingForm.getValues("name"),
email: bookingForm.getValues("email"),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Future proofing if someone wants payments for event types with seats

Comment on lines +135 to +136
name: bookingForm.getValues("name"),
email: bookingForm.getValues("email"),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For seats we want to pass the current attendee to the success page

Comment on lines +546 to +554
<Icon.FiUser
className={`mr-[10px] ml-[2px] mt-[2px] inline-block h-4 w-4 ${
booking && booking.attendees.length / eventType.seatsPerTimeSlot >= 0.5
? "text-rose-600"
: booking && booking.attendees.length / eventType.seatsPerTimeSlot >= 0.33
? "text-yellow-500"
: "text-bookinghighlight"
}`}
/>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Change the seats color along with the number of seats left

Comment thread apps/web/pages/v2/success.tsx Outdated
const {
location: _location,
name,
email,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The change is that we are reading the email that is in the URL params

Comment thread apps/web/pages/v2/success.tsx Outdated
Comment on lines +364 to +371
? bookingInfo?.attendees
.filter((attendee) => attendee.email === email)
.map((attendee) => (
<div key={attendee.name} className="mb-3">
<p>{attendee.name}</p>
<p className="text-bookinglight">{attendee.email}</p>
</div>
))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since emails are unique across attendees, we can filter to display just the current attendee if seatsHideAttendees is true

reminders: {
useDefault: true,
},
guestsCanSeeOtherGuests: !calEventRaw.seatsHideAttendees,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Google Cal is the only calendar service we integrate right now that can natively hide the guest list

Comment thread packages/emails/email-manager.ts Outdated
new Promise((resolve, reject) => {
try {
const scheduledEmail = new AttendeeScheduledEmail(calEvent, invitee);
const scheduledEmail = new AttendeeScheduledEmail(calEvent, invitee, hideAttendees);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Only pass hideAttendees to the email being sent out to the attendee

Comment on lines +26 to +32
if (this.hideAttendees) {
this.calEvent.attendees = [
{
...this.attendee,
},
];
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Only pass the current attendee as the event attendee

Comment on lines +25 to +27
id?: number;
bookingId?: number;
locale?: string;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Current attendees have these fields

Comment on lines +91 to +93
...calEventRaw.attendees.map(({ id, ...rest }) => ({
rest,
responseStatus: "accepted",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We don't need id here and not all attendees will have an id if they are new to the event

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's add a eslint-ignore comment then

Comment on lines +179 to +182
...event.attendees.map(({ id, ...rest }) => ({
rest,
responseStatus: "accepted",
})),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We don't need id here and not all attendees will have an id if they are new to the event

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here

@@ -1,4 +1,5 @@
import CloseCom from "@calcom/lib/CloseCom";
import type { CloseComAttendees, CloseComCalendarEvent } from "@calcom/lib/CloseCom";
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@leog heads up, not sure why these tests were failing but I had to create Close.com specific types

Comment thread packages/lib/CloseCom.ts Outdated
Comment on lines +140 to +149
export type CloseComAttendees = {
attendees: { email: string; id: string; timeZone?: string }[];
};

export type CloseComCalendarEvent = {
attendees?: CloseComAttendees["attendees"];
startTime: string;
additionalNotes?: string;
};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@leog here are the new types

const event = {
attendees,
} as CalendarEvent;
} as { attendees: { email: string; name: string | null; id: string }[] };
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Simplify this type to pass test

startTime: now.toISOString(),
additionalNotes: "Some comment!",
} as CalendarEvent;
} as any;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Even though this is similar to line 171 it was still failing. Passes when cast as any type. This variable is declared anyways and does not rely on any external calls

@zomars zomars disabled auto-merge October 18, 2022 19:41
@zomars zomars merged commit 8fc4d34 into main Oct 18, 2022
@zomars zomars deleted the seats-hide-attendees branch October 18, 2022 19:41
haffla pushed a commit to tourlane/cal.com that referenced this pull request Nov 22, 2022
* Add seatsHideAttendees to schema

* Add migration

* Add frontend option to hide attendees

* Pass hide attendees to email

* Hide attendee names on success email

* Add types for existing attendees

* Hide other attendees if hidden

* Pass seatsHideAttendees to Google Cal

* Add translation

* Reduce redundancy

* Fix type error

* Change toggle to show attendee information

* Minor text change

* Fix type errors

* Update snapshots

* Merge branch 'main' into seats-hide-attendees

* Add back email

* Add close.com specific types

* Add eslint ignore comments

* Merge branch 'seats-hide-attendees' of https://github.com/calcom/cal.com into seats-hide-attendees

* Simplify tests

Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
haffla pushed a commit to tourlane/cal.com that referenced this pull request Nov 22, 2022
* Add seatsHideAttendees to schema

* Add migration

* Add frontend option to hide attendees

* Pass hide attendees to email

* Hide attendee names on success email

* Add types for existing attendees

* Hide other attendees if hidden

* Pass seatsHideAttendees to Google Cal

* Add translation

* Reduce redundancy

* Fix type error

* Change toggle to show attendee information

* Minor text change

* Fix type errors

* Update snapshots

* Merge branch 'main' into seats-hide-attendees

* Add back email

* Add close.com specific types

* Add eslint ignore comments

* Merge branch 'seats-hide-attendees' of https://github.com/calcom/cal.com into seats-hide-attendees

* Simplify tests

Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

❗️ migrations contains migration files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants