Skip to content

Commit

Permalink
Merge pull request #10 from Deep-Consulting-Solutions/update-add-meta…
Browse files Browse the repository at this point in the history
…data-to-cancel-event-webhook

update metatada assertion cancel event webhook
  • Loading branch information
kampkelly authored Feb 9, 2024
2 parents 5850a7e + f41015c commit 4f089c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion apps/web/components/booking/CancelBooking.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useRouter } from "next/navigation";
import { useRouter, useSearchParams } from "next/navigation";
import { useCallback, useState } from "react";

import { useLocale } from "@calcom/lib/hooks/useLocale";
Expand Down Expand Up @@ -26,6 +26,7 @@ type Props = {
};

export default function CancelBooking(props: Props) {
const searchParams = useSearchParams();
const [cancellationReason, setCancellationReason] = useState<string>("");
const { t } = useLocale();
const router = useRouter();
Expand Down Expand Up @@ -83,11 +84,15 @@ export default function CancelBooking(props: Props) {

telemetry.event(telemetryEventTypes.bookingCancelled, collectPageParameters());

const metadata = searchParams?.get("metadata") ?? "";
const res = await fetch("/api/cancel", {
body: JSON.stringify({
uid: booking?.uid,
cancellationReason: cancellationReason,
allRemainingBookings,
metadata: {
a: metadata,
},
// @NOTE: very important this shouldn't cancel with number ID use uid instead
seatReferenceUid,
}),
Expand Down
4 changes: 2 additions & 2 deletions packages/features/bookings/lib/handleCancelBooking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ async function handler(req: CustomRequest) {
sendPayload(webhook.secret, eventTrigger, new Date().toISOString(), webhook, {
...evt,
...eventTypeInfo,
metadata: req.query.metadata,
metadata: req.body.metadata as { [key: string]: string },
status: "CANCELLED",
smsReminderNumber: bookingToDelete.smsReminderNumber || undefined,
}).catch((e) => {
Expand Down Expand Up @@ -792,7 +792,7 @@ async function handleSeatedEventCancellation(
sendPayload(webhook.secret, WebhookTriggerEvents.BOOKING_CANCELLED, new Date().toISOString(), webhook, {
...evt,
...eventTypeInfo,
metadata: req.query.metadata,
metadata: req.body.metadata as { [key: string]: string },
status: "CANCELLED",
smsReminderNumber: bookingToDelete.smsReminderNumber || undefined,
}).catch((e) => {
Expand Down

0 comments on commit 4f089c1

Please sign in to comment.