// Gabarits HTML des mails. Styles inline + tableaux : c'est ce que Gmail, Outlook et Apple Mail rendent pareil. // Chaque mail garde aussi sa version texte (lisible partout, et meilleure délivrabilité). import { esc } from '../http.js'; import { renderMarkdown, inlineMd, parseEvolutions, EFFORTS } from './markdown.js'; const C = { bg: '#f4f5f7', card: '#ffffff', text: '#17191c', muted: '#6b7078', line: '#e2e4e8', accent: '#2f5bea', accentSoft: '#eef2fe', ok: '#15803d', }; const FONT = "-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif"; const MD_STYLES = { p: `margin:0 0 12px;font-size:15px;line-height:1.6;color:${C.text}`, ul: 'margin:0 0 12px;padding-left:20px', ol: 'margin:0 0 12px;padding-left:20px', li: `margin:0 0 6px;font-size:15px;line-height:1.55;color:${C.text}`, strong: `color:${C.text};font-weight:600`, code: `font-family:SFMono-Regular,Consolas,monospace;font-size:13px;background:${C.bg};border:1px solid ${C.line};border-radius:4px;padding:1px 5px`, pre: `margin:0 0 12px;padding:12px;background:${C.bg};border-radius:8px;font-size:13px;white-space:pre-wrap`, a: `color:${C.accent}`, h1: `margin:18px 0 8px;font-size:20px;color:${C.text}`, h2: `margin:18px 0 8px;font-size:18px;color:${C.text}`, h3: `margin:16px 0 8px;font-size:16px;color:${C.text}`, h4: `margin:14px 0 6px;font-size:15px;color:${C.text}`, blockquote: `margin:0 0 12px;padding:4px 12px;border-left:3px solid ${C.accent};color:${C.muted}`, hr: `border:0;border-top:1px solid ${C.line};margin:16px 0`, }; const md = (s) => renderMarkdown(s, { styles: MD_STYLES }); const st = (tag) => (MD_STYLES[tag] ? ` style="${MD_STYLES[tag]}"` : ''); const EFFORT_COLORS = { S: ['#15803d', '#dcfce7'], M: ['#b45309', '#fef3c7'], L: ['#b91c1c', '#fee2e2'], }; /** Mise en page commune des mails envoyés à toi (évolutions, rapport hebdo). */ export function mailLayout({ title, subtitle = '', preheader = '', content, appUrl = '', cta = '' }) { return `
|
| |||
| ${md(e.body)} |
Aucune activité cette semaine.
`} ${quiet.length ? `Sans activité : ${quiet.map((p) => esc(p.name)).join(', ')}.
` : ''}`; return mailLayout({ title: 'Rapport hebdo', subtitle: period, preheader: `${t.sent} mails, ${t.replies} réponses (${pct(t.replies, t.sent)}), ${t.found} prospects trouvés`, content, appUrl, cta: 'Ouvrir le panel', }); } const linkify = (escaped) => escaped.replace(/https?:\/\/[^\s<]+[^\s<.,;:!?)]/g, (u) => `${u}`); /** * Mail de prospection : volontairement sobre, comme un mail écrit à la main * (pas de bannière ni d'images : c'est ce qui passe le mieux les filtres anti-spam). */ export function prospectHtml({ body, notice, unsubUrl }) { const paras = String(body).split(/\n{2,}/).map((p) => p.trim()).filter(Boolean) .map((p) => `${linkify(esc(p)).replace(/\n/g, '
')}