import { useRouter } from "next/navigation"; import { useCallback, useState } from "react"; import { sdkActionManager } from "@calcom/embed-core/embed-iframe"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry"; import type { RecurringEvent } from "@calcom/types/Calendar"; import { Button, Icon, TextArea } from "@calcom/ui"; type Props = { booking: { title?: string; uid?: string; id?: number; }; profile: { name: string | null; slug: string | null; }; recurringEvent: RecurringEvent | null; team?: string | null; setIsCancellationMode: (value: boolean) => void; theme: string | null; allRemainingBookings: boolean; seatReferenceUid?: string; bookingCancelledEventProps: { booking: unknown; organizer: { name: string; email: string; timeZone?: string; }; eventType: unknown; }; }; export default function CancelBooking(props: Props) { const [cancellationReason, setCancellationReason] = useState(""); const { t } = useLocale(); const router = useRouter(); const { booking, allRemainingBookings, seatReferenceUid, bookingCancelledEventProps } = props; const [loading, setLoading] = useState(false); const telemetry = useTelemetry(); const [error, setError] = useState(booking ? null : t("booking_already_cancelled")); const cancelBookingRef = useCallback((node: HTMLTextAreaElement) => { if (node !== null) { node.scrollIntoView({ behavior: "smooth" }); node.focus(); } // eslint-disable-next-line react-hooks/exhaustive-deps }, []); return ( <> {error && (
)} {!error && (