From c8e20b0c57e1d64b18e4c834fe0b83bf6b24ecc1 Mon Sep 17 00:00:00 2001 From: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Date: Mon, 26 Aug 2024 14:54:58 +0100 Subject: [PATCH] feat: block pending meetings for requires confirmation (#16335) * feat: block pending meetings for requires confirmation * add i18n * fix:typecheck * fix(requires-confirmation-block): Fixes type error * fix(requires-confirmation-block): Fixes type error * Tweak to set BookingWhereInput as the explicit type instead of as * fix: type error --------- Co-authored-by: Alex van Andel --- .../components/eventtype/EventAdvancedTab.tsx | 1 + .../RequiresConfirmationController.tsx | 142 ++++++++++-------- .../views/event-types-single-view.tsx | 1 + apps/web/public/static/locales/en/common.json | 1 + apps/web/test/lib/getSchedule.test.ts | 93 ++++++++++++ packages/core/getBusyTimes.ts | 15 +- packages/features/eventtypes/lib/types.ts | 1 + packages/lib/server/eventTypeSelect.ts | 1 + packages/lib/server/repository/eventType.ts | 1 + packages/lib/test/builder.ts | 1 + .../migration.sql | 2 + packages/prisma/schema.prisma | 1 + packages/prisma/zod-utils.ts | 1 + .../trpc/server/routers/viewer/slots/util.ts | 14 ++ 14 files changed, 213 insertions(+), 62 deletions(-) create mode 100644 packages/prisma/migrations/20240823092832_add_requires_confirmation_will_block_slot/migration.sql diff --git a/apps/web/components/eventtype/EventAdvancedTab.tsx b/apps/web/components/eventtype/EventAdvancedTab.tsx index d6eaa871b3..1e4f8af1dd 100644 --- a/apps/web/components/eventtype/EventAdvancedTab.tsx +++ b/apps/web/components/eventtype/EventAdvancedTab.tsx @@ -279,6 +279,7 @@ export const EventAdvancedTab = ({ eventType, team }: Pick ; requiresConfirmation: boolean; + requiresConfirmationWillBlockSlot: boolean; onRequiresConfirmation: Dispatch>; seatsEnabled: boolean; eventType: EventTypeSetup; @@ -56,6 +57,8 @@ export default function RequiresConfirmationController({ opt.value === (metadata?.requiresConfirmationThreshold?.unit ?? defaultRequiresConfirmationSetup.unit) ); + const requiresConfirmationWillBlockSlot = formMethods.getValues("requiresConfirmationWillBlockSlot"); + return (
@@ -80,6 +83,10 @@ export default function RequiresConfirmationController({ LockedIcon={requiresConfirmationLockedProps.LockedIcon} onCheckedChange={(val) => { formMethods.setValue("requiresConfirmation", val, { shouldDirty: true }); + // If we uncheck requires confirmation, we also uncheck the "will block slot" checkbox + if (!val) { + formMethods.setValue("requiresConfirmationWillBlockSlot", false, { shouldDirty: true }); + } onRequiresConfirmation(val); }}>
@@ -121,73 +128,86 @@ export default function RequiresConfirmationController({ )} {(requiresConfirmationSetup !== undefined || !requiresConfirmationLockedProps.disabled) && ( - - - { - const val = Number(evt.target?.value); - setRequiresConfirmationSetup({ - unit: - requiresConfirmationSetup?.unit ?? - defaultRequiresConfirmationSetup.unit, - time: val, - }); - formMethods.setValue( - "metadata.requiresConfirmationThreshold.time", - val, - { shouldDirty: true } - ); - }} - className="border-default !m-0 block w-16 rounded-r-none border-r-0 text-sm [appearance:textfield] focus:z-10 focus:border-r" - defaultValue={metadata?.requiresConfirmationThreshold?.time || 30} - /> - -
- ), - }} - /> - - } - id="notice" - value="notice" - /> +