fix: old v2 booking cancel endpoint issue (#19564)

* fix: old v2 booking cancel endpoint issue

* fixup! fix: old v2 booking cancel endpoint issue
This commit is contained in:
Morgan
2025-02-26 13:14:13 +00:00
committed by GitHub
parent 8612fa71c7
commit 52662b3375
2 changed files with 12 additions and 5 deletions
@@ -29,6 +29,7 @@ import {
Query,
NotFoundException,
UseGuards,
BadRequestException,
} from "@nestjs/common";
import { ConfigService } from "@nestjs/config";
import { ApiQuery, ApiExcludeController as DocsExcludeController } from "@nestjs/swagger";
@@ -189,18 +190,24 @@ export class BookingsController_2024_04_15 {
throw new InternalServerErrorException("Could not create booking.");
}
@Post("/:bookingId/cancel")
@Post("/:bookingUid/cancel")
async cancelBooking(
@Req() req: BookingRequest,
@Param("bookingId") bookingId: string,
@Param("bookingUid") bookingUid: string,
@Body() _: CancelBookingInput_2024_04_15,
@Headers(X_CAL_CLIENT_ID) clientId?: string,
@Headers(X_CAL_PLATFORM_EMBED) isEmbed?: string
): Promise<ApiResponse<{ bookingId: number; bookingUid: string; onlyRemovedAttendee: boolean }>> {
const oAuthClientId = clientId?.toString();
if (bookingId) {
const isUidNumber = !isNaN(Number(bookingUid));
if (isUidNumber) {
throw new BadRequestException("Please provide booking uid instead of booking id.");
}
if (bookingUid) {
try {
req.body.id = parseInt(bookingId);
req.body.uid = bookingUid;
const res = await handleCancelBooking(
await this.createNextApiBookingRequest(req, oAuthClientId, undefined, isEmbed)
);
@@ -26,7 +26,7 @@ export const useCancelBooking = (
) => {
const cancelBooking = useMutation<ApiResponse, Error, inputParams>({
mutationFn: (data) => {
return http.post<ApiResponse>(`/bookings/${data.id}/cancel`, data).then((res) => {
return http.post<ApiResponse>(`/bookings/${data.uid}/cancel`, data).then((res) => {
if (res.data.status === SUCCESS_STATUS) {
return res.data;
}