From 5e6c7559d7bc5cc1dc41526f17671c4486e67463 Mon Sep 17 00:00:00 2001 From: CarinaWolli Date: Thu, 3 Oct 2024 11:08:40 -0400 Subject: [PATCH 01/10] add checkbox --- apps/web/public/static/locales/en/common.json | 3 +- .../teams/pages/team-booking-limits-view.tsx | 31 ++++++++++++++++--- packages/lib/server/queries/teams/index.ts | 1 + .../migration.sql | 2 ++ packages/prisma/schema.prisma | 3 +- .../routers/viewer/teams/update.handler.ts | 2 ++ .../routers/viewer/teams/update.schema.ts | 1 + 7 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 packages/prisma/migrations/20241003145122_add_include_managed_events_in_limits_to_teams/migration.sql diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json index a95f8f683d45d8..c02af63c8c0407 100644 --- a/apps/web/public/static/locales/en/common.json +++ b/apps/web/public/static/locales/en/common.json @@ -1525,6 +1525,7 @@ "workflow_example_4": "Send email reminder 1 hour before events starts to attendee", "workflow_example_5": "Send custom email when event is rescheduled to host", "workflow_example_6": "Send custom SMS when new event is booked to host", + "count_managed_to_limit": "Count bookings from managed event types to limit", "welcome_to_cal_header": "Welcome to {{appName}}!", "edit_form_later_subtitle": "You’ll be able to edit this later.", "connect_calendar_later": "I'll connect my calendar later", @@ -2622,7 +2623,7 @@ "disable_input_if_prefilled": "Disable input if the URL identifier is prefilled", "booking_limits": "Booking Limits", "booking_limits_team_description": "Booking limits for team members across all team event types", - "limit_team_booking_frequency_description": "Limit how many times members can be booked across all team event types (collective and round-robin)", + "limit_team_booking_frequency_description": "Limit how many times members can be booked across all team event types", "booking_limits_updated_successfully": "Booking limits updated successfully", "you_are_unauthorized_to_make_this_change_to_the_booking": "You are unauthorized to make this change to the booking", "hide_calendar_event_details": "Hide calendar event details on shared calendars", diff --git a/packages/features/ee/teams/pages/team-booking-limits-view.tsx b/packages/features/ee/teams/pages/team-booking-limits-view.tsx index 5a8be9a29f831d..892bde1c9ea743 100644 --- a/packages/features/ee/teams/pages/team-booking-limits-view.tsx +++ b/packages/features/ee/teams/pages/team-booking-limits-view.tsx @@ -14,7 +14,7 @@ import { MembershipRole } from "@calcom/prisma/enums"; import { trpc } from "@calcom/trpc/react"; import type { RouterOutputs } from "@calcom/trpc/react"; import type { IntervalLimit } from "@calcom/types/Calendar"; -import { Button, Form, SettingsToggle, showToast } from "@calcom/ui"; +import { Button, CheckboxField, Form, SettingsToggle, showToast } from "@calcom/ui"; type ProfileViewProps = { team: RouterOutputs["viewer"]["teams"]["getMinimal"] }; @@ -22,9 +22,10 @@ const BookingLimitsView = ({ team }: ProfileViewProps) => { const { t } = useLocale(); const utils = trpc.useUtils(); - const form = useForm<{ bookingLimits?: IntervalLimit }>({ + const form = useForm<{ bookingLimits?: IntervalLimit; includeManagedEventsInLimits: boolean }>({ defaultValues: { bookingLimits: team?.bookingLimits || undefined, + includeManagedEventsInLimits: team?.includeManagedEventsInLimits ?? false, }, }); @@ -40,7 +41,10 @@ const BookingLimitsView = ({ team }: ProfileViewProps) => { async onSuccess(res) { await utils.viewer.teams.get.invalidate(); if (res) { - reset({ bookingLimits: res.bookingLimits }); + reset({ + bookingLimits: res.bookingLimits, + includeManagedEventsInLimits: res.includeManagedEventsInLimits, + }); } showToast(t("booking_limits_updated_successfully"), "success"); }, @@ -83,9 +87,12 @@ const BookingLimitsView = ({ team }: ProfileViewProps) => { }); } else { form.setValue("bookingLimits", {}); + form.setValue("includeManagedEventsInLimits", false); } const bookingLimits = form.getValues("bookingLimits"); - mutation.mutate({ bookingLimits, id: team.id }); + const includeManagedEventsInLimits = form.getValues("includeManagedEventsInLimits"); + + mutation.mutate({ bookingLimits, includeManagedEventsInLimits, id: team.id }); }} switchContainerClassName={classNames( "border-subtle mt-6 rounded-lg border py-6 px-4 sm:px-6", @@ -93,7 +100,21 @@ const BookingLimitsView = ({ team }: ProfileViewProps) => { )} childrenClassName="lg:ml-0">
- + ( + onChange(e)} + checked={value} + /> + )} + /> + +
+ +