feat: Add option to include no shows in RR calculations (#21063)

* Show distribution option for RR scheduling type

* Add `includeNoShowInRRCalculation` to event type schema

* Add `includeNoShowInRRCalculation` initial event type data

* Add FE option for `includeNoShowInRRCalculation`

* Consider `includeNoShowInRRCalculation` when building `where` clause when getting bookings for RR

* Add `includeNoShowInRRCalculation` param to `getAllBookingsForRoundRobin`

* Add `includeNoShow...` param to `GetLuckyUserParams`

* Pass `includeNoShow...` param to `getBookingsOfInterval` calls

* Add FE option for `includeNoShow...` (actual commit)

* Type fixes

* Fix brackets

* Add booking repository test

* Remove unused method

* Add translation

* Type fix

* Type fix

* Test passing

* Fix tests

* Fix tests

* Fix test

* Type fixes
This commit is contained in:
Joe Au-Yeung authored and GitHub committed 2025-05-09 16:29:57 +00:00
1 parent 93bad282d7
commit b1cbeebe48
16 files changed
+304 -83

No files matched your search

@@ -62,6 +62,7 @@ export const getEventTypesFromDB = async (eventTypeId: number) => {
requiresConfirmationForFreeEmail: true,
requiresBookerEmailVerification: true,
maxLeadThreshold: true,
includeNoShowInRRCalculation: true,
minimumBookingNotice: true,
userId: true,
price: true,
@@ -50,6 +50,7 @@ type EventType = Pick<
| "isRRWeightsEnabled"
| "rescheduleWithSameRoundRobinHost"
| "teamId"
| "includeNoShowInRRCalculation"
>;
type InputProps = {
@@ -621,7 +621,7 @@ export const EventTeamAssignmentTab = ({
);
});
const isManagedEventType = eventType.schedulingType === SchedulingType.MANAGED;
const { getValues, setValue } = useFormContext<FormValues>();
const { getValues, setValue, control } = useFormContext<FormValues>();
const [assignAllTeamMembers, setAssignAllTeamMembers] = useState<boolean>(
getValues("assignAllTeamMembers") ?? false
);
@@ -632,6 +632,11 @@ export const EventTeamAssignmentTab = ({
setAssignAllTeamMembers(false);
};
const schedulingType = useWatch({
control,
name: "schedulingType",
});
return (
<div>
{team && !isManagedEventType && (
@@ -682,44 +687,61 @@ export const EventTeamAssignmentTab = ({
/>
</div>
</div>
<div className="border-subtle mt-4 flex flex-col rounded-md">
<div className="border-subtle rounded-t-md border p-6 pb-5">
<Label className="mb-1 text-sm font-semibold">{t("rr_distribution_method")}</Label>
<p className="text-subtle max-w-full break-words text-sm leading-tight">
{t("rr_distribution_method_description")}
</p>
{schedulingType === "ROUND_ROBIN" && (
<div className="border-subtle mt-4 flex flex-col rounded-md">
<div className="border-subtle rounded-t-md border p-6 pb-5">
<Label className="mb-1 text-sm font-semibold">{t("rr_distribution_method")}</Label>
<p className="text-subtle max-w-full break-words text-sm leading-tight">
{t("rr_distribution_method_description")}
</p>
</div>
<div className="border-subtle rounded-b-md border border-t-0 p-6">
<Controller
name="maxLeadThreshold"
render={({ field: { value, onChange } }) => (
<RadioArea.Group
onValueChange={(val) => {
if (val === "loadBalancing") onChange(3);
else onChange(null);
}}
className="mt-1 flex flex-col gap-4">
<RadioArea.Item
value="maximizeAvailability"
checked={value === null}
className="w-full text-sm"
classNames={{ container: "w-full" }}>
<strong className="mb-1 block">
{t("rr_distribution_method_availability_title")}
</strong>
<p>{t("rr_distribution_method_availability_description")}</p>
</RadioArea.Item>
<RadioArea.Item
value="loadBalancing"
checked={value !== null}
className="text-sm"
classNames={{ container: "w-full" }}>
<strong className="mb-1 block">{t("rr_distribution_method_balanced_title")}</strong>
<p>{t("rr_distribution_method_balanced_description")}</p>
</RadioArea.Item>
</RadioArea.Group>
)}
/>
<div className="mt-4">
<Controller
name="includeNoShowInRRCalculation"
render={({ field: { value, onChange } }) => (
<SettingsToggle
title={t("include_no_show_in_rr_calculation")}
labelClassName="mt-1.5"
checked={value}
onCheckedChange={(val) => onChange(val)}
/>
)}
/>
</div>
</div>
</div>
<div className="border-subtle rounded-b-md border border-t-0 p-6">
<Controller
name="maxLeadThreshold"
render={({ field: { value, onChange } }) => (
<RadioArea.Group
onValueChange={(val) => {
if (val === "loadBalancing") onChange(3);
else onChange(null);
}}
className="mt-1 flex flex-col gap-4">
<RadioArea.Item
value="maximizeAvailability"
checked={value === null}
className="w-full text-sm"
classNames={{ container: "w-full" }}>
<strong className="mb-1 block">{t("rr_distribution_method_availability_title")}</strong>
<p>{t("rr_distribution_method_availability_description")}</p>
</RadioArea.Item>
<RadioArea.Item
value="loadBalancing"
checked={value !== null}
className="text-sm"
classNames={{ container: "w-full" }}>
<strong className="mb-1 block">{t("rr_distribution_method_balanced_title")}</strong>
<p>{t("rr_distribution_method_balanced_description")}</p>
</RadioArea.Item>
</RadioArea.Group>
)}
/>
</div>
</div>
)}
<Hosts
orgId={orgId}
isSegmentApplicable={isSegmentApplicable}