fix: handle cancelation reason when user is host (#18681)
* handle cancelation reason when user is host * add attendee reason warning * add cancellation reason to tests when we are the host * req.body and not req * fix: isloggedIn logic * use new isLoggedInUser from ssr instead of client * update e2e tests to fill in reason when hosts --------- Co-authored-by: Udit Takkar <[email protected]> Co-authored-by: Udit Takkar <[email protected]> Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
9 files changed
+53
-8
No files matched your search
@@ -180,6 +180,13 @@ async function handler(req: CustomRequest) {
|
||||
throw new HttpError({ statusCode: 400, message: "User not found" });
|
||||
}
|
||||
|
||||
if (!cancellationReason && req.bookingToDelete.userId == userId) {
|
||||
throw new HttpError({
|
||||
statusCode: 400,
|
||||
message: "Cancellation reason is required when you are the host",
|
||||
});
|
||||
}
|
||||
|
||||
// If the booking is a seated event and there is no seatReferenceUid we should validate that logged in user is host
|
||||
if (bookingToDelete.eventType?.seatsPerTimeSlot && !seatReferenceUid) {
|
||||
const userIsHost = bookingToDelete.eventType.hosts.find((host) => {
|
||||
|
||||
@@ -1677,6 +1677,7 @@ describe("handleSeats", () => {
|
||||
});
|
||||
|
||||
req.userId = organizer.id;
|
||||
req.body.cancellationReason = "test cancellation reason";
|
||||
|
||||
await handleCancelBooking(req);
|
||||
|
||||
@@ -1817,6 +1818,7 @@ describe("handleSeats", () => {
|
||||
});
|
||||
|
||||
req.userId = organizer.id;
|
||||
req.body.cancellationReason = "test cancellation reason";
|
||||
|
||||
await handleCancelBooking(req);
|
||||
|
||||
@@ -2682,6 +2684,7 @@ describe("handleSeats", () => {
|
||||
});
|
||||
|
||||
req.userId = organizer.id;
|
||||
req.body.cancellationReason = "test cancellation reason";
|
||||
|
||||
await handleCancelBooking(req);
|
||||
|
||||
|
||||
Reference in new issue
Block a user