import { useState } from "react"; import type { Dispatch, SetStateAction } from "react"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc/react"; import { Button, Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader, showToast, } from "@calcom/ui"; import { CreditCard, AlertTriangle } from "@calcom/ui/components/icon"; interface IRescheduleDialog { isOpenDialog: boolean; setIsOpenDialog: Dispatch>; bookingId: number; paymentAmount: number; paymentCurrency: string; } export const ChargeCardDialog = (props: IRescheduleDialog) => { const { t } = useLocale(); const utils = trpc.useContext(); const { isOpenDialog, setIsOpenDialog, bookingId } = props; const [chargeError, setChargeError] = useState(false); const chargeCardMutation = trpc.viewer.payments.chargeCard.useMutation({ onSuccess: () => { utils.viewer.bookings.invalidate(); setIsOpenDialog(false); showToast("Charge successful", "success"); }, onError: () => { setChargeError(true); }, }); const currencyStringParams = { amount: props.paymentAmount / 100.0, formatParams: { amount: { currency: props.paymentCurrency } }, }; return (

{t("charge_card_dialog_body", currencyStringParams)}

{chargeError && (
)}
); };