import { usePathname, useRouter, useSearchParams } from "next/navigation"; import { useCallback, useState } from "react"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry"; import type { RecurringEvent } from "@calcom/types/Calendar"; import { Button, TextArea } from "@calcom/ui"; import { X } from "@calcom/ui/components/icon"; 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; }; export default function CancelBooking(props: Props) { const pathname = usePathname(); const searchParams = useSearchParams(); const asPath = `${pathname}?${searchParams.toString()}`; const [cancellationReason, setCancellationReason] = useState(""); const { t } = useLocale(); const router = useRouter(); const { booking, allRemainingBookings, seatReferenceUid } = 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 && (