import { useCallback, useState } from "react"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc/react"; import { Button, TextArea } from "@calcom/ui"; type Props = { booking: { uid?: string | null; id: number; recurringEventId: string | null; }; setIsRejectionMode: () => void; }; export default function RejectBooking(props: Props) { const [rejectionReason, setRejectionReason] = useState(""); const { t } = useLocale(); const utils = trpc.useUtils(); const { booking } = props; const isRecurring = booking.recurringEventId !== null; const mutation = trpc.viewer.bookings.confirm.useMutation({ onSuccess: () => { props.setIsRejectionMode(); utils.viewer.bookings.invalidate(); }, onError: () => { utils.viewer.bookings.invalidate(); }, }); const bookingConfirm = async (confirm: boolean) => { let body = { bookingId: booking.id, confirmed: confirm, reason: rejectionReason, }; if (isRecurring) { body = Object.assign({}, body, { recurringEventId: booking.recurringEventId }); } mutation.mutate(body); }; const rejectBookingRef = useCallback((node: HTMLTextAreaElement) => { if (node !== null) { node.scrollIntoView({ behavior: "smooth" }); node.focus(); } // eslint-disable-next-line react-hooks/exhaustive-deps }, []); return ( <>