Files
web/apps/scandic-web/components/Profile/DeleteCreditCardConfirmation.tsx
Matilda Landström 5de2a993a7 Merged in feat/SW-1711-switch-icons (pull request #1558)
Switches out all the old icons to new ones, and moves them to the design system. The new icons are of three different types: Materialise Symbol, Nucleo, and Customized. Also adds further mapping between facilities/amenities and icons.

Approved-by: Michael Zetterberg
Approved-by: Erik Tiekstra
2025-03-27 09:42:52 +00:00

65 lines
1.9 KiB
TypeScript

"use client"
import { useIntl } from "react-intl"
import { MaterialIcon } from "@scandic-hotels/design-system/Icons"
import { trpc } from "@/lib/trpc/client"
import Dialog from "@/components/Dialog"
import Button from "@/components/TempDesignSystem/Button"
import { toast } from "@/components/TempDesignSystem/Toasts"
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.",
})
)
},
})
function handleProceedDeleteCard(close: () => void) {
deleteCard.mutate({ creditCardId: card.id }, { onSettled: close })
}
const lastFourDigits = card.truncatedNumber.slice(-4)
const bodyText = intl.formatMessage(
{
id: "Are you sure you want to remove the card ending with {lastFourDigits} from your member profile?",
},
{ lastFourDigits }
)
return (
<Dialog
bodyText={bodyText}
cancelButtonText={intl.formatMessage({ id: "No, keep card" })}
proceedOnClick={handleProceedDeleteCard}
proceedText={intl.formatMessage({ id: "Yes, remove my card" })}
titleText={intl.formatMessage({ id: "Remove card from member profile" })}
trigger={
<Button intent="secondary" size="small" theme="base">
<MaterialIcon icon="delete" color="Icon/Interactive/Default" />
</Button>
}
/>
)
}