Adds supabase/functions/ (deno.json, _shared/email.ts) with pure buildBookingNotificationEmail/buildInquiryNotificationEmail functions for Task 6's Edge Functions, tested via Deno's test runner. Excludes supabase/functions/** from the root Vitest config, which otherwise tried to resolve the jsr: import and failed.
29 lines
1.2 KiB
TypeScript
29 lines
1.2 KiB
TypeScript
export interface BookingEmailInput {
|
|
serviceName: string
|
|
date: string
|
|
time: string
|
|
contact: { name: string; phone: string; email: string; notes: string }
|
|
}
|
|
|
|
export function buildBookingNotificationEmail(input: BookingEmailInput): { subject: string; html: string } {
|
|
const notesLine = input.contact.notes ? `<p>Notes: ${input.contact.notes}</p>` : ''
|
|
return {
|
|
subject: `New booking: ${input.serviceName} on ${input.date}`,
|
|
html: `<p><strong>${input.contact.name}</strong> booked <strong>${input.serviceName}</strong> on ${input.date} at ${input.time}.</p>` +
|
|
`<p>Phone: ${input.contact.phone}<br/>Email: ${input.contact.email}</p>${notesLine}`,
|
|
}
|
|
}
|
|
|
|
export interface InquiryEmailInput {
|
|
productName: string
|
|
contact: { name: string; email: string; notes: string }
|
|
}
|
|
|
|
export function buildInquiryNotificationEmail(input: InquiryEmailInput): { subject: string; html: string } {
|
|
const notesLine = input.contact.notes ? `<p>Notes: ${input.contact.notes}</p>` : ''
|
|
return {
|
|
subject: `New inquiry: ${input.productName}`,
|
|
html: `<p><strong>${input.contact.name}</strong> (${input.contact.email}) asked about <strong>${input.productName}</strong>.</p>${notesLine}`,
|
|
}
|
|
}
|