diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json index cdcb3001b3..f72cce4469 100644 --- a/apps/web/public/static/locales/en/common.json +++ b/apps/web/public/static/locales/en/common.json @@ -2988,6 +2988,10 @@ "desc": "Desc", "verify_email": "Verify email", "verify_email_change": "Verify email change", + "rr_reset_interval": "Round Robin Reset Interval", + "interval": "Interval", + "rr_reset_interval_description": "Determines how often the round robin booking count resets to ensure balanced distribution.", + "daily": "Daily", "end_date_not_selected": "You didn't set an end date for your OOO", "my_ooo": "My OOO", "team_ooo": "Team OOO", @@ -3001,6 +3005,7 @@ "ooo_team_redirect_infinite_not_allowed": "There is already a reverse forwarding between these users.", "previous_ooo_empty_title": "No previous OOO found", "previous": "Previous", + "rr_interval_successfully_updated":"Round Robin interval successfully updated", "trial_mode": "Trial mode", "inactive_team_plan": "Inactive team plan", "inactive_team_plan_description": "Your team plan is inactive. Check your subcription or reach out to customer support", diff --git a/packages/features/bookings/lib/handleNewBooking/getEventTypesFromDB.ts b/packages/features/bookings/lib/handleNewBooking/getEventTypesFromDB.ts index 8404b11b27..7bb923a7e3 100644 --- a/packages/features/bookings/lib/handleNewBooking/getEventTypesFromDB.ts +++ b/packages/features/bookings/lib/handleNewBooking/getEventTypesFromDB.ts @@ -42,6 +42,7 @@ export const getEventTypesFromDB = async (eventTypeId: number) => { parentId: true, bookingLimits: true, includeManagedEventsInLimits: true, + rrResetInterval: true, }, }, bookingFields: true, diff --git a/packages/features/ee/teams/components/RoundRobinResetInterval.tsx b/packages/features/ee/teams/components/RoundRobinResetInterval.tsx new file mode 100644 index 0000000000..3683b43704 --- /dev/null +++ b/packages/features/ee/teams/components/RoundRobinResetInterval.tsx @@ -0,0 +1,101 @@ +"use client"; + +import { useForm, Controller } from "react-hook-form"; + +import SectionBottomActions from "@calcom/features/settings/SectionBottomActions"; +import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { MembershipRole, RRResetInterval } from "@calcom/prisma/enums"; +import { trpc } from "@calcom/trpc/react"; +import type { RouterOutputs } from "@calcom/trpc/react"; +import { Form, showToast, Label, Select, Button } from "@calcom/ui"; + +interface ProfileViewProps { + team: RouterOutputs["viewer"]["teams"]["get"]; +} + +const RoundRobinResetInterval = ({ team }: ProfileViewProps) => { + const { t } = useLocale(); + const utils = trpc.useUtils(); + + const intervalOptions: { + value: RRResetInterval; + label: string; + }[] = [ + { + value: RRResetInterval.MONTH, + label: t("monthly"), + }, + { + value: RRResetInterval.DAY, + label: t("daily"), + }, + ]; + + const form = useForm<{ rrResetInterval: RRResetInterval }>({ + defaultValues: { + rrResetInterval: team?.rrResetInterval ?? RRResetInterval.MONTH, + }, + }); + + const mutation = trpc.viewer.teams.update.useMutation({ + onError: (err) => { + showToast(err.message, "error"); + }, + async onSuccess(res) { + await utils.viewer.teams.get.invalidate(); + showToast(t("rr_interval_successfully_updated"), "success"); + }, + }); + + const isAdmin = + team && (team.membership.role === MembershipRole.OWNER || team.membership.role === MembershipRole.ADMIN); + + if (!isAdmin) { + return ( +
+ {t("only_owner_change")} +
+ ); + } + + return ( +
{ + mutation.mutate({ ...values, id: team.id }); + }}> + { + return ( +
+
+

{t("rr_reset_interval")}

+

{t("rr_reset_interval_description")}

+
+
+ +