import { formatAssessmentReports, formatLangLabel, formatOptional, formatPartnerCategory } from '~/server/utils/form-mail-labels' import { buildMailHtml, buildMailText, sendMail } from '~/server/utils/mail' type SiteLang = 'en' | 'zh' export async function notifyAssessmentSubmission(input: { lang: SiteLang firstName: string lastName?: string | null email: string condition: string reports?: string | null message?: string | null createdAt: string }) { const rows = [ { label: '表单类型', value: '免费评估表' }, { label: '提交语言', value: formatLangLabel(input.lang) }, { label: '提交时间', value: input.createdAt }, { label: '患者名', value: input.firstName }, { label: '患者姓', value: formatOptional(input.lastName, input.lang) }, { label: '联系邮箱', value: input.email }, { label: '主要病情/诊断', value: input.condition }, { label: '是否有近期医疗报告/影像?', value: formatAssessmentReports(input.reports, input.lang) }, { label: '简要留言/具体问题', value: formatOptional(input.message, input.lang) } ] const title = '【优医官网】免费评估表新提交' const subject = `${title} - ${input.firstName}` await sendMail({ subject, text: buildMailText(title, rows), html: buildMailHtml(title, rows), replyTo: input.email }) } export async function notifyPartnerSubmission(input: { lang: SiteLang firstName: string lastName: string companyName: string country: string email: string category: string collaborate: string createdAt: string }) { const rows = [ { label: '表单类型', value: '加入我们' }, { label: '提交语言', value: formatLangLabel(input.lang) }, { label: '提交时间', value: input.createdAt }, { label: '名', value: input.firstName }, { label: '姓', value: input.lastName }, { label: '公司名称', value: input.companyName }, { label: '国家/地区', value: input.country }, { label: '电子邮箱', value: input.email }, { label: '合作类别', value: formatPartnerCategory(input.category, input.lang) }, { label: '我们如何合作?', value: input.collaborate } ] const title = '【优医官网】合作申请新提交' const subject = `${title} - ${input.companyName}` await sendMail({ subject, text: buildMailText(title, rows), html: buildMailHtml(title, rows), replyTo: input.email }) }