* refactor: handleNewBooking #3 * refactor: create booking factor * refactor: handleNewBooking * refactor: seats and rescheduleUId * chore: remove comment * fix: type err * chore: add missing statement * chore: use less params and other improvements * chore: name * chore: improvement * fix: type err * Typo fix * chore: fix type err * refactor: more readable * refactor: improve code * fix: conflicts --------- Co-authored-by: Joe Au-Yeung <j.auyeung419@gmail.com> Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com>
21 lines
733 B
TypeScript
21 lines
733 B
TypeScript
import { ErrorCode } from "@calcom/lib/errorCodes";
|
|
import { HttpError } from "@calcom/lib/http-error";
|
|
import { BookingStatus } from "@calcom/prisma/enums";
|
|
|
|
import { type OriginalRescheduledBooking } from "./getOriginalRescheduledBooking";
|
|
|
|
export const validateOriginalRescheduledBooking = async (
|
|
originalRescheduledBooking: OriginalRescheduledBooking
|
|
) => {
|
|
if (!originalRescheduledBooking) {
|
|
throw new HttpError({ statusCode: 404, message: "Could not find original booking" });
|
|
}
|
|
|
|
if (
|
|
originalRescheduledBooking.status === BookingStatus.CANCELLED &&
|
|
!originalRescheduledBooking.rescheduled
|
|
) {
|
|
throw new HttpError({ statusCode: 403, message: ErrorCode.CancelledBookingsCannotBeRescheduled });
|
|
}
|
|
};
|