From e1f1386332badbd2fcb1cbb5fb5df03c94562f2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20L=C3=B3pez?= Date: Wed, 22 Sep 2021 05:04:32 -0600 Subject: [PATCH] Feat disable guests for events (#719) * Abstracts CheckboxField * Allows disabling the guests field while booking Co-authored-by: Bailey Pumfleet --- components/booking/pages/BookingPage.tsx | 72 ++++++++++--------- components/ui/form/CheckboxField.tsx | 37 ++++++++++ pages/[user]/book.tsx | 1 + pages/api/availability/eventtype.ts | 1 + pages/event-types/[type].tsx | 53 ++++++-------- pages/team/[slug]/book.tsx | 1 + .../migration.sql | 2 + prisma/schema.prisma | 1 + 8 files changed, 104 insertions(+), 64 deletions(-) create mode 100644 components/ui/form/CheckboxField.tsx create mode 100644 prisma/migrations/20210922004424_add_disable_guests_to_event_type/migration.sql diff --git a/components/booking/pages/BookingPage.tsx b/components/booking/pages/BookingPage.tsx index bb492fa2..295d3a6c 100644 --- a/components/booking/pages/BookingPage.tsx +++ b/components/booking/pages/BookingPage.tsx @@ -329,42 +329,48 @@ const BookingPage = (props: any): JSX.Element => { )} ))} -
- {!guestToggle && ( - - )} - {guestToggle && ( -
+ {!props.eventType.disableGuests && ( +
+ {!guestToggle && ( - { - setGuestEmails(_emails); - }} - getLabel={(email: string, index: number, removeEmail: (index: number) => void) => { - return ( -
- {email} - removeEmail(index)}> - × - -
- ); - }} - /> -
- )} -
+ )} + {guestToggle && ( +
+ + { + setGuestEmails(_emails); + }} + getLabel={( + email: string, + index: number, + removeEmail: (index: number) => void + ) => { + return ( +
+ {email} + removeEmail(index)}> + × + +
+ ); + }} + /> +
+ )} +
+ )}
-
-
- -
-
-
-
- -
-
-

- The booking needs to be manually confirmed before it is pushed to the - integrations and a confirmation mail is sent. -

-
-
-
-
+ + + +
@@ -1153,6 +1143,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) => periodEndDate: true, periodCountCalendarDays: true, requiresConfirmation: true, + disableGuests: true, team: { select: { slug: true, diff --git a/pages/team/[slug]/book.tsx b/pages/team/[slug]/book.tsx index 49daa763..ff88dda3 100644 --- a/pages/team/[slug]/book.tsx +++ b/pages/team/[slug]/book.tsx @@ -33,6 +33,7 @@ export async function getServerSideProps(context) { periodStartDate: true, periodEndDate: true, periodCountCalendarDays: true, + disableGuests: true, team: { select: { slug: true, diff --git a/prisma/migrations/20210922004424_add_disable_guests_to_event_type/migration.sql b/prisma/migrations/20210922004424_add_disable_guests_to_event_type/migration.sql new file mode 100644 index 00000000..840f7f98 --- /dev/null +++ b/prisma/migrations/20210922004424_add_disable_guests_to_event_type/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "EventType" ADD COLUMN "disableGuests" BOOLEAN NOT NULL DEFAULT false; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 6a9bb33a..4d094719 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -38,6 +38,7 @@ model EventType { periodDays Int? periodCountCalendarDays Boolean? requiresConfirmation Boolean @default(false) + disableGuests Boolean @default(false) minimumBookingNotice Int @default(120) schedulingType SchedulingType? Schedule Schedule[]