Scheduling infrastructure for absolutely everyone.
avoid get error when a user has no schedule defined in getUserAvailability function (#8170)
Efraín Rochín7fde30edf910
diff --git a/packages/core/getUserAvailability.ts b/packages/core/getUserAvailability.tsindex a5a8fdc427c..942ec1b26aa 100644--- a/packages/core/getUserAvailability.ts+++ b/packages/core/getUserAvailability.ts@@ -119,8 +119,9 @@ export async function getUserAvailability(const { username, userId, dateFrom, dateTo, eventTypeId, afterEventBuffer, beforeEventBuffer, duration } =availabilitySchema.parse(query);- if (!dateFrom.isValid() || !dateTo.isValid())+ if (!dateFrom.isValid() || !dateTo.isValid()) {throw new HttpError({ statusCode: 400, message: "Invalid time range given." });+ }const where: Prisma.UserWhereUniqueInput = {};if (username) where.username = username;@@ -196,7 +197,7 @@ export async function getUserAvailability(const startGetWorkingHours = performance.now();- const timeZone = schedule.timeZone || eventType?.timeZone || user.timeZone;+ const timeZone = schedule?.timeZone || eventType?.timeZone || user.timeZone;const availability = (schedule.availability || (eventType?.availability.length ? eventType.availability : user.availability)