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:
@@ -1287,6 +1287,7 @@
|
||||
"default_calendar_selected": "Default calendar",
|
||||
"hide_from_profile": "Hide from profile",
|
||||
"event_setup_tab_title": "Event Setup",
|
||||
"availability_not_found_in_schedule_error":"No availability found in schedule",
|
||||
"event_limit_tab_title": "Limits",
|
||||
"event_limit_tab_description": "How often you can be booked",
|
||||
"event_advanced_tab_description": "Calendar settings & more...",
|
||||
|
||||
@@ -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