2026-05-07 00:00:45 +02:00
import { brandingPrimaryColor , renderShell , type BrandingShell } from '@/lib/email/shell' ;
2026-04-14 12:56:30 -04:00
export interface InquiryClientConfirmationData {
firstName : string ;
mooringNumber : string | null ;
contactEmail : string ;
2026-05-07 00:00:45 +02:00
/** Display name; falls back to "Port Nimara". */
portName? : string ;
2026-04-14 12:56:30 -04:00
}
2026-05-07 00:00:45 +02:00
interface RenderOpts {
branding? : BrandingShell | null ;
}
2026-04-14 12:56:30 -04:00
2026-05-07 00:00:45 +02:00
export function inquiryClientConfirmation (
data : InquiryClientConfirmationData ,
overrides? : RenderOpts ,
) {
const { firstName , mooringNumber , contactEmail } = data ;
const portName = data . portName ? ? 'Port Nimara' ;
2026-04-14 12:56:30 -04:00
2026-05-07 00:00:45 +02:00
const berthText = mooringNumber ? ` Berth ${ mooringNumber } ` : ` a ${ portName } Berth ` ;
2026-04-14 12:56:30 -04:00
const subject = mooringNumber
? ` Thank You for Your Interest in Berth ${ mooringNumber } `
2026-05-07 00:00:45 +02:00
: ` Thank You for Your Interest in a ${ portName } Berth ` ;
const accent = brandingPrimaryColor ( overrides ? . branding ) ;
2026-04-14 12:56:30 -04:00
2026-05-07 00:00:45 +02:00
const body = `
2026-04-14 12:56:30 -04:00
< p style = "margin-bottom:10px; font-size:16px;" > Dear $ { escapeHtml ( firstName ) } , < / p >
< p style = "margin-bottom:10px; font-size:16px;" >
Thank you for expressing interest in $ { escapeHtml ( berthText ) } .
Our team has registered your interest , and we will reach out to you very shortly
by your preferred method of contact with more information .
< / p >
< p style = "margin-bottom:10px; font-size:16px;" >
If you have any questions , please feel free to reach out to us at
2026-05-07 00:00:45 +02:00
< a href = "mailto:${escapeHtml(contactEmail)}" style = "color:${accent}; text-decoration:underline;" > $ { escapeHtml ( contactEmail ) } < / a > .
2026-04-14 12:56:30 -04:00
< / p >
< p style = "font-size:16px;" >
Best regards , < br / >
2026-05-07 00:00:45 +02:00
The $ { escapeHtml ( portName ) } Sales Team
< / p > ` ;
2026-04-14 12:56:30 -04:00
const text = [
` Dear ${ firstName } , ` ,
'' ,
` Thank you for expressing interest in ${ berthText } . Our team has registered your interest, and we will reach out to you very shortly by your preferred method of contact with more information. ` ,
'' ,
` If you have any questions, please feel free to reach out to us at ${ contactEmail } . ` ,
'' ,
'Best regards,' ,
2026-05-07 00:00:45 +02:00
` The ${ portName } Sales Team ` ,
2026-04-14 12:56:30 -04:00
] . join ( '\n' ) ;
2026-05-07 00:00:45 +02:00
return {
subject ,
html : renderShell ( { title : subject , body , branding : overrides?.branding } ) ,
text ,
} ;
2026-04-14 12:56:30 -04:00
}
function escapeHtml ( str : string ) : string {
return str
. replace ( /&/g , '&' )
. replace ( /</g , '<' )
. replace ( />/g , '>' )
. replace ( /"/g , '"' )
. replace ( /'/g , ''' ) ;
}