Scheduling infrastructure for absolutely everyone.
Run available user check if event type does not have checks (#4646)
Joe Au-Yeung830f42bf9a69
diff --git a/apps/web/components/v2/eventtype/EventAdvancedTab.tsx b/apps/web/components/v2/eventtype/EventAdvancedTab.tsxindex f0d3a8c0043..7e3aa37ece3 100644--- a/apps/web/components/v2/eventtype/EventAdvancedTab.tsx+++ b/apps/web/components/v2/eventtype/EventAdvancedTab.tsx@@ -42,7 +42,7 @@ export const EventAdvancedTab = ({ eventType, team }: Pick<EventTypeSetupInferedconst [hashedLinkVisible, setHashedLinkVisible] = useState(!!eventType.hashedLink);const [hashedUrl, setHashedUrl] = useState(eventType.hashedLink?.link);const [seatsInputVisible, setSeatsInputVisible] = useState(!!eventType.seatsPerTimeSlot);- const [seatsPerTimeSlot, setSeatsPerTimeSlot] = useState(eventType.seatsPerTimeSlot);+ const [seatsPerTimeSlot, setSeatsPerTimeSlot] = useState(eventType.seatsPerTimeSlot || 2);const [customInputs, setCustomInputs] = useState<EventTypeCustomInput[]>(eventType.customInputs.sort((a, b) => a.id - b.id) || []);@@ -324,6 +324,7 @@ export const EventAdvancedTab = ({ eventType, team }: Pick<EventTypeSetupInferedchecked={seatsInputVisible}onCheckedChange={(e) => {setSeatsInputVisible(e);+ formMethods.setValue("seatsPerTimeSlot", seatsPerTimeSlot);onChange(e ? seatsPerTimeSlot : null);}}fitToHeight={true}diff --git a/apps/web/pages/api/book/event.ts b/apps/web/pages/api/book/event.tsindex f5fc833cfff..6f133db7d92 100644--- a/apps/web/pages/api/book/event.ts+++ b/apps/web/pages/api/book/event.ts@@ -327,20 +327,20 @@ async function handler(req: NextApiRequest) {if (!users) throw new HttpError({ statusCode: 404, message: "eventTypeUser.notFound" });- const availableUsers = await ensureAvailableUsers(- {- ...eventType,- users,- },- {- dateFrom: reqBody.start,- dateTo: reqBody.end,- }- );-- // Add an if conditional if there are no seats on the event type- // Assign to only one user when ROUND_ROBINif (!eventType.seatsPerTimeSlot) {+ const availableUsers = await ensureAvailableUsers(+ {+ ...eventType,+ users,+ },+ {+ dateFrom: reqBody.start,+ dateTo: reqBody.end,+ }+ );++ // Add an if conditional if there are no seats on the event type+ // Assign to only one user when ROUND_ROBINif (eventType.schedulingType === SchedulingType.ROUND_ROBIN) {users = [await getLuckyUser("MAXIMIZE_AVAILABILITY", { availableUsers, eventTypeId: eventType.id })];} else {