feat(scheduling): booking reminder emails
This commit is contained in:
@@ -75,6 +75,45 @@ export function confirmationEmail(ctx: BookingEmailContext): RenderedEmail {
|
||||
return { subject, text, html }
|
||||
}
|
||||
|
||||
// Human-friendly lead time, e.g. 1440 -> "tomorrow", 60 -> "in 1 hour".
|
||||
function fmtLeadTime(minutes: number): string {
|
||||
if (minutes % 1440 === 0) {
|
||||
const days = minutes / 1440
|
||||
return days === 1 ? 'tomorrow' : `in ${days} days`
|
||||
}
|
||||
if (minutes % 60 === 0) {
|
||||
const hours = minutes / 60
|
||||
return `in ${hours} hour${hours === 1 ? '' : 's'}`
|
||||
}
|
||||
return `in ${minutes} minutes`
|
||||
}
|
||||
|
||||
export function reminderEmail(ctx: BookingEmailContext & { offsetMinutes: number }): RenderedEmail {
|
||||
const accent = ctx.brandColor || '#1a1a1a'
|
||||
const when = fmtRange(ctx.startUtc, ctx.endUtc, ctx.attendeeTimezone)
|
||||
const lead = fmtLeadTime(ctx.offsetMinutes)
|
||||
const subject = `Reminder: ${ctx.eventTitle} with ${ctx.hostName} ${lead}`
|
||||
const text = [
|
||||
`Hi ${ctx.attendeeName},`,
|
||||
``,
|
||||
`This is a reminder of your upcoming booking ${lead}.`,
|
||||
``,
|
||||
`${ctx.eventTitle} with ${ctx.hostName}`,
|
||||
when,
|
||||
ctx.location ? `Location: ${ctx.location}` : '',
|
||||
``,
|
||||
`Need to change it? ${ctx.manageUrl}`,
|
||||
].filter(Boolean).join('\n')
|
||||
const html = shell(accent, ctx.brandName, `Your booking is ${lead}`, `
|
||||
<p style="margin:0 0 12px;color:#444">This is a reminder of your upcoming booking ${escapeHtml(lead)}.</p>
|
||||
<p style="margin:0 0 6px"><strong>${escapeHtml(ctx.eventTitle)}</strong> with ${escapeHtml(ctx.hostName)}</p>
|
||||
<p style="margin:0 0 4px;color:#444">${escapeHtml(when)}</p>
|
||||
${ctx.location ? `<p style="margin:0 0 4px;color:#444">${escapeHtml(ctx.location)}</p>` : ''}
|
||||
<p style="margin:18px 0 0"><a href="${ctx.manageUrl}" style="display:inline-block;background:${accent};color:#fff;text-decoration:none;padding:10px 18px;border-radius:8px;font-size:14px">Reschedule or cancel</a></p>
|
||||
`)
|
||||
return { subject, text, html }
|
||||
}
|
||||
|
||||
export function cancellationEmail(ctx: BookingEmailContext): RenderedEmail {
|
||||
const accent = ctx.brandColor || '#1a1a1a'
|
||||
const when = fmtRange(ctx.startUtc, ctx.endUtc, ctx.attendeeTimezone)
|
||||
|
||||
Reference in New Issue
Block a user