import React from 'react'; import Icon from '../components/icon'; import Message from '../../booking-wizard/components/message'; export interface SharedConfirmationTranslations { MAIL_SUBJECT: string; TITLE_TEXT_OPTION: string; TITLE_TEXT_OFFER: string; TITLE_TEXT_BOOKING: string; MESSAGE_TEXT1: string; MESSAGE_TEXT2_OFFER: string; MESSAGE_TEXT2_BOOKING: string; QUESTIONS_TEXT1: string; QUESTIONS_TEXT2: string; QUESTIONS_TEXT3: string; QUESTIONS_ALT: string; } export interface SharedConfirmationProps { bookingNumber?: string; isOption?: boolean; isOffer?: boolean; translations: SharedConfirmationTranslations; companyContactPhone?: string; companyContactEmail?: string; homeUrl?: string; } function format(str: string, args: (string | number | undefined)[]): string { // Simple format function: replaces {0}, {1}, ... with args return str.replace(/\{(\d+)\}/g, (match, number) => (typeof args[number] !== 'undefined' ? String(args[number]) : match)); } const SharedConfirmation: React.FC = ({ bookingNumber, isOption, isOffer, translations, companyContactPhone, companyContactEmail, homeUrl = '/' }) => { const encodedMailSubject = encodeURI(translations.MAIL_SUBJECT); const titleText = isOption ? format(translations.TITLE_TEXT_OPTION, [bookingNumber]) : isOffer ? format(translations.TITLE_TEXT_OFFER, [bookingNumber]) : format(translations.TITLE_TEXT_BOOKING, [bookingNumber]); return (
{companyContactPhone && ( )} {companyContactEmail && ( )} {homeUrl && ( )}
) : undefined }> {!isOption ? ( <>

{translations.MESSAGE_TEXT1}
{isOffer ? translations.MESSAGE_TEXT2_OFFER : translations.MESSAGE_TEXT2_BOOKING}

{companyContactEmail && (

{translations.QUESTIONS_TEXT1}{' '} {translations.QUESTIONS_TEXT2} {translations.QUESTIONS_TEXT3}

)} ) : undefined}
); }; export default SharedConfirmation;