avoid get error when a user has no schedule defined in getUserAvailability function (#8170)
parent
0e22e92cab
commit
7fde30edf9
|
@ -119,8 +119,9 @@ export async function getUserAvailability(
|
||||||
const { username, userId, dateFrom, dateTo, eventTypeId, afterEventBuffer, beforeEventBuffer, duration } =
|
const { username, userId, dateFrom, dateTo, eventTypeId, afterEventBuffer, beforeEventBuffer, duration } =
|
||||||
availabilitySchema.parse(query);
|
availabilitySchema.parse(query);
|
||||||
|
|
||||||
if (!dateFrom.isValid() || !dateTo.isValid())
|
if (!dateFrom.isValid() || !dateTo.isValid()) {
|
||||||
throw new HttpError({ statusCode: 400, message: "Invalid time range given." });
|
throw new HttpError({ statusCode: 400, message: "Invalid time range given." });
|
||||||
|
}
|
||||||
|
|
||||||
const where: Prisma.UserWhereUniqueInput = {};
|
const where: Prisma.UserWhereUniqueInput = {};
|
||||||
if (username) where.username = username;
|
if (username) where.username = username;
|
||||||
|
@ -196,7 +197,7 @@ export async function getUserAvailability(
|
||||||
|
|
||||||
const startGetWorkingHours = performance.now();
|
const startGetWorkingHours = performance.now();
|
||||||
|
|
||||||
const timeZone = schedule.timeZone || eventType?.timeZone || user.timeZone;
|
const timeZone = schedule?.timeZone || eventType?.timeZone || user.timeZone;
|
||||||
|
|
||||||
const availability = (
|
const availability = (
|
||||||
schedule.availability || (eventType?.availability.length ? eventType.availability : user.availability)
|
schedule.availability || (eventType?.availability.length ? eventType.availability : user.availability)
|
||||||
|
|
Loading…
Reference in New Issue