import { __ } from '@wordpress/i18n' import { useBookingContext } from '../../providers/BookingFormProvider/BookingFormProvider' import { wbkFormatPrice } from '../../providers/BookingFormProvider/utils' import { useWording } from '../../hooks/useWording' import { ReactComponent as IconCheck } from '../../../../public/images/icon-check.svg' import '../BookingForm/ThankYou/ThankYou.scss' export interface IGiftCardResult { id?: number code?: string amount?: number payment_method?: string payment_id?: string buyer_email?: string buyer_name?: string recipient_name?: string recipient_email?: string } interface IGiftCardThankYouProps { giftCard: IGiftCardResult paymentMethod?: string } const formatGiftCardItemLabel = ( wording: Record, recipientName?: string ) => { if (recipientName) { return ( wording?.gift_card_for || __('Gift card for #recipient_name', 'webba-booking-lite') ).replace(/#recipient_name/g, recipientName) } return wording?.gift_card || __('Gift card', 'webba-booking-lite') } export const GiftCardThankYou = ({ giftCard, paymentMethod, }: IGiftCardThankYouProps) => { const wording = useWording() const { priceFormat } = useBookingContext() const amount = Number(giftCard?.amount || 0) return (

{wording?.payment_successful || __( 'Payment successful', 'webba-booking-lite' )}

{wording?.gift_card_thank_you_message || __( 'Thank you for your gift card purchase. A confirmation email will be sent to you, and the recipient will receive their gift on the selected date.', 'webba-booking-lite' )}

{wording?.cost_breakdown || __('Cost Breakdown', 'webba-booking-lite')}

{formatGiftCardItemLabel( wording, giftCard?.recipient_name )}

{wbkFormatPrice(amount, priceFormat)}
{giftCard?.code && (

{wording?.gift_card_code || __( 'Gift card code', 'webba-booking-lite' )}

{giftCard.code}
)}

{wording?.total_amount_paid || __( 'Total amount', 'webba-booking-lite' )}

{wbkFormatPrice(amount, priceFormat)}
{paymentMethod && (

{wording?.payment || __( 'Payment', 'webba-booking-lite' )}

{paymentMethod.charAt(0).toUpperCase() + paymentMethod.slice(1)}
)}
) }