chore: add error message for no availability (#13230)
* chore: add error message for no default user availability * chore: check only availability * chore: change message * chore: add eventType
This commit is contained in:
1 parent
7ec3d04acc
commit
29b1f7bf51
3 files changed
+11
-1
No files matched your search
@@ -6,6 +6,7 @@ import dayjs from "@calcom/dayjs";
|
||||
import { parseBookingLimit, parseDurationLimit } from "@calcom/lib";
|
||||
import { getWorkingHours } from "@calcom/lib/availability";
|
||||
import { buildDateRanges, subtract } from "@calcom/lib/date-ranges";
|
||||
import { ErrorCode } from "@calcom/lib/errorCodes";
|
||||
import { HttpError } from "@calcom/lib/http-error";
|
||||
import { descendingLimitKeys, intervalLimitKeyToUnit } from "@calcom/lib/intervalLimit";
|
||||
import logger from "@calcom/lib/logger";
|
||||
@@ -258,6 +259,7 @@ const _getUserAvailability = async function getUsersWorkingHoursLifeTheUniverseA
|
||||
|
||||
const useHostSchedulesForTeamEvent = eventType?.metadata?.config?.useHostSchedulesForTeamEvent;
|
||||
const schedule = !useHostSchedulesForTeamEvent && eventType?.schedule ? eventType.schedule : userSchedule;
|
||||
|
||||
log.debug(
|
||||
"Using schedule:",
|
||||
safeStringify({
|
||||
@@ -272,8 +274,14 @@ const _getUserAvailability = async function getUsersWorkingHoursLifeTheUniverseA
|
||||
|
||||
const timeZone = schedule?.timeZone || eventType?.timeZone || user.timeZone;
|
||||
|
||||
if (
|
||||
!(schedule?.availability || (eventType?.availability.length ? eventType.availability : user.availability))
|
||||
) {
|
||||
throw new HttpError({ statusCode: 400, message: ErrorCode.AvailabilityNotFoundInSchedule });
|
||||
}
|
||||
|
||||
const availability = (
|
||||
schedule.availability || (eventType?.availability.length ? eventType.availability : user.availability)
|
||||
schedule?.availability || (eventType?.availability.length ? eventType.availability : user.availability)
|
||||
).map((a) => ({
|
||||
...a,
|
||||
userId: user.id,
|
||||
|
||||
@@ -6,5 +6,6 @@ export enum ErrorCode {
|
||||
AlreadySignedUpForBooking = "already_signed_up_for_this_booking_error",
|
||||
HostsUnavailableForBooking = "hosts_unavailable_for_booking",
|
||||
EventTypeNotFound = "event_type_not_found_error",
|
||||
AvailabilityNotFoundInSchedule = "availability_not_found_in_schedule_error",
|
||||
CancelledBookingsCannotBeRescheduled = "cancelled_bookings_cannot_be_rescheduled",
|
||||
}
|
||||
Reference in new issue
Block a user