"use client" import { Dialog, DialogTrigger, Heading, Modal, ModalOverlay, } from "react-aria-components" import { useIntl } from "react-intl" import { trpc } from "@/lib/trpc/client" import { Delete } from "@/components/Icons" import LoadingSpinner from "@/components/LoadingSpinner" import Button from "@/components/TempDesignSystem/Button" import { toast } from "@/components/TempDesignSystem/Toasts" import styles from "./deleteCreditCardConfirmation.module.css" import type { DeleteCreditCardConfirmationProps } from "@/types/components/myPages/myProfile/creditCards" export default function DeleteCreditCardConfirmation({ card, }: DeleteCreditCardConfirmationProps) { const intl = useIntl() const trpcUtils = trpc.useUtils() const deleteCard = trpc.user.creditCard.delete.useMutation({ onSuccess() { trpcUtils.user.creditCards.invalidate() toast.success( intl.formatMessage({ id: "Your card was successfully removed!" }) ) }, onError() { toast.error( intl.formatMessage({ id: "Something went wrong and we couldn't remove your card. Please try again later.", }) ) }, }) const lastFourDigits = card.truncatedNumber.slice(-4) return (
{({ close }) => (
{intl.formatMessage({ id: "Remove card from member profile", })}

{`${intl.formatMessage({ id: "Are you sure you want to remove the card ending with", })} ${lastFourDigits} ${intl.formatMessage({ id: "from your member profile?" })}`}

{deleteCard.isPending ? ( ) : (
)}
)}
) }