Lumen & Gesso / website · lumengesso.com / app / lib / order-emails.ts
| 1 | import 'server-only'; |
| 2 | import { env } from './env'; |
| 3 | import { displayOrderId } from './orders'; |
| 4 | |
| 5 | // Branded transactional email templates. All four transactional emails in |
| 6 | // the order lifecycle live here so the visual system stays in one place. |
| 7 | // |
| 8 | // Email-client compatibility: single-column, max-width 600, inline styles |
| 9 | // only, no @media (Gmail Web strips it from <style>), no flexbox/grid. |
| 10 | // Newsreader + DM Sans are pulled from Google Fonts where supported and |
| 11 | // fall back gracefully to system serif/sans elsewhere (Gmail, Outlook). |
| 12 | |
| 13 | // ─── Brand tokens (mirror of :root in app/globals.css) ─────────────── |
| 14 | const ink = '#2a1d18'; |
| 15 | const inkSoft = '#5c4a40'; |
| 16 | const tan = '#c8b29c'; |
| 17 | const creamLight = '#faf3e2'; |
| 18 | const rose = '#c5837a'; |
| 19 | const roseDeep = '#9a574e'; |
| 20 | const rule = 'rgba(42, 29, 24, 0.13)'; |
| 21 | |
| 22 | // CRITICAL: font names use SINGLE quotes. The whole layout's inline |
| 23 | // styles go inside double-quoted style="" attributes, so double- |
| 24 | // quoted font names ("Newsreader", "DM Sans") would terminate the |
| 25 | // attribute mid-stream — Gmail's CSS parser then drops everything |
| 26 | // after the malformed font-family rule, including font-size, |
| 27 | // text-decoration, color, etc. That's why bumping font-size to 56px |
| 28 | // or wrapping in !important spans had no effect for weeks — the |
| 29 | // rules were never reaching the renderer. |
| 30 | const serif = "'Newsreader', Georgia, 'Times New Roman', serif"; |
| 31 | const sans = "'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif"; |
| 32 | |
| 33 | // ─── Shared layout ─────────────────────────────────────────────────── |
| 34 | // Wraps every email in: hidden preheader (inbox preview text), branded |
| 35 | // wordmark header, content slot, and a small footer with order ID + |
| 36 | // studio line. Pre-rendered to a string so call sites can pass content |
| 37 | // straight to sendEmail({ html }). |
| 38 | |
| 39 | type LayoutArgs = { |
| 40 | preheader: string; |
| 41 | content: string; |
| 42 | footerNote?: string; |
| 43 | }; |
| 44 | |
| 45 | function layout({ preheader, content, footerNote }: LayoutArgs): string { |
| 46 | return `<!doctype html> |
| 47 | <html lang="en"> |
| 48 | <head> |
| 49 | <meta charset="utf-8" /> |
| 50 | <meta name="viewport" content="width=device-width,initial-scale=1" /> |
| 51 | <meta name="color-scheme" content="light only" /> |
| 52 | <meta name="supported-color-schemes" content="light" /> |
| 53 | <!-- Tell Apple Mail / iOS to stop auto-linking emails, phone numbers, |
| 54 | addresses, and dates. Gmail web ignores this but Apple respects it. --> |
| 55 | <meta name="format-detection" content="email=no,telephone=no,address=no,date=no" /> |
| 56 | <meta name="x-apple-disable-message-reformatting" /> |
| 57 | <title>Lumen & Gesso</title> |
| 58 | <link rel="preconnect" href="https://fonts.googleapis.com" /> |
| 59 | <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> |
| 60 | <link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=Newsreader:ital,wght@0,400;0,500;1,400;1,500&display=swap" rel="stylesheet" /> |
| 61 | </head> |
| 62 | <body style="margin:0;padding:0;background:${tan};font-family:${sans};color:${ink};-webkit-font-smoothing:antialiased;"> |
| 63 | <div style="display:none;max-height:0;overflow:hidden;opacity:0;visibility:hidden;mso-hide:all;font-size:1px;line-height:1px;color:${tan};">${escapeHtml(preheader)}</div> |
| 64 | <div style="background:${tan};padding:32px 16px 56px;"> |
| 65 | <div style="max-width:560px;margin:0 auto;background:${creamLight};border:1px solid ${rule};"> |
| 66 | <div style="padding:42px 40px 30px;border-bottom:1px solid ${rule};text-align:center;"> |
| 67 | <div style="font-family:${sans};font-size:10px;font-weight:700;letter-spacing:0.28em;text-transform:uppercase;color:${roseDeep};margin-bottom:16px;">Studio dispatch</div> |
| 68 | <div style="font-family:${serif};font-weight:500;font-size:36px;letter-spacing:-0.01em;color:${ink};line-height:1;"> |
| 69 | Lumen <span style="font-style:italic;color:${roseDeep};font-weight:400;">&</span> Gesso |
| 70 | </div> |
| 71 | </div> |
| 72 | <div style="padding:36px 40px 40px;"> |
| 73 | ${content} |
| 74 | </div> |
| 75 | <div style="padding:24px 40px 28px;border-top:1px solid ${rule};text-align:center;font-family:${sans};font-size:12px;line-height:1.65;color:${inkSoft};"> |
| 76 | <div style="margin-bottom:10px;">${footerNote ?? "You're receiving this because you placed a commission with our studio. Questions? Just reply — we read every email."}</div> |
| 77 | <div style="font-family:${serif};font-style:italic;color:${ink};margin-bottom:4px;"> |
| 78 | Lumen <span style="color:${roseDeep};">&</span> Gesso |
| 79 | </div> |
| 80 | <div style="margin-bottom:6px;">A small studio crafting custom pet portraits</div> |
| 81 | <div> |
| 82 | <a href="${env.site.url()}" style="color:${inkSoft} !important;text-decoration:none !important;border-bottom:1px solid ${rule};"><font color="${inkSoft}" style="color:${inkSoft} !important;text-decoration:none !important;"><span style="color:${inkSoft} !important;text-decoration:none !important;">lumengesso.com</span></font></a> |
| 83 | <span style="margin:0 8px;color:${rule};">·</span> |
| 84 | <a href="mailto:hello@lumengesso.com" style="color:${inkSoft} !important;text-decoration:none !important;border-bottom:1px solid ${rule};"><font color="${inkSoft}" style="color:${inkSoft} !important;text-decoration:none !important;"><span style="color:${inkSoft} !important;text-decoration:none !important;">hello@lumengesso.com</span></font></a> |
| 85 | </div> |
| 86 | </div> |
| 87 | </div> |
| 88 | </div> |
| 89 | </body> |
| 90 | </html>`; |
| 91 | } |
| 92 | |
| 93 | // Bulletproof email button. Notes on why each piece matters: |
| 94 | // - <table bgcolor> is the most reliable way to paint a button |
| 95 | // background across Apple Mail, Gmail (web/iOS/Android), Outlook |
| 96 | // (Windows/Mac/Web), Yahoo, ProtonMail. |
| 97 | // - bgcolor uses rose-deep (#9a574e) to match the .btn--rose primary |
| 98 | // CTA on the site (page.tsx, Builder.tsx). The darker rose survives |
| 99 | // Gmail's auto-dark-mode shift without losing contrast with the |
| 100 | // white label. |
| 101 | // - The label is wrapped in a <span style="color:#ffffff"> because |
| 102 | // Gmail and several others override <a> color with their own link |
| 103 | // blue. The inner span wins. |
| 104 | // - mso-padding-alt gives Outlook on Windows the click target it |
| 105 | // otherwise can't compute from CSS padding on an <a>. |
| 106 | function button(label: string, href: string): string { |
| 107 | const safe = escapeHtml(label); |
| 108 | // Four-layer defence against Gmail's link-decoration injector: |
| 109 | // 1. <a> with !important color + text-decoration:none |
| 110 | // 2. <font color> — HTML4 attribute Gmail's sanitizer respects |
| 111 | // 3. <span> with !important — defends against descendant rules |
| 112 | // 4. <u style="text-decoration:none"> — the counter-intuitive |
| 113 | // Gmail trick: the underline tag explicitly forced off, |
| 114 | // which Gmail's web client respects even when its |
| 115 | // auto-link-decoration would otherwise add a blue underline |
| 116 | // to the inner label text. |
| 117 | return `<table role="presentation" cellspacing="0" cellpadding="0" border="0" align="center" style="margin:32px auto 8px;border-collapse:separate;"> |
| 118 | <tr> |
| 119 | <td align="center" bgcolor="${roseDeep}" style="background-color:${roseDeep};border-radius:2px;mso-padding-alt:14px 30px;"> |
| 120 | <a href="${href}" style="display:inline-block;padding:14px 30px;font-family:${sans};font-weight:600;font-size:15px;letter-spacing:0.02em;color:#ffffff !important;text-decoration:none !important;line-height:1;mso-text-raise:2px;border:0;"><font color="#ffffff" style="color:#ffffff !important;text-decoration:none !important;"><span style="color:#ffffff !important;text-decoration:none !important;"><u style="text-decoration:none !important;color:#ffffff !important;">${safe}</u></span></font></a> |
| 121 | </td> |
| 122 | </tr> |
| 123 | </table>`; |
| 124 | } |
| 125 | |
| 126 | function eyebrow(text: string): string { |
| 127 | return `<div style="font-family:${sans};font-size:11px;font-weight:700;letter-spacing:0.24em;text-transform:uppercase;color:${roseDeep};line-height:1;margin-bottom:18px;">${escapeHtml(text)}</div>`; |
| 128 | } |
| 129 | |
| 130 | function heading(text: string): string { |
| 131 | return `<h1 style="font-family:${serif};font-weight:500;font-size:30px;line-height:1.15;letter-spacing:-0.01em;color:${ink};margin:0 0 18px;">${escapeHtml(text)}</h1>`; |
| 132 | } |
| 133 | |
| 134 | function body(html: string): string { |
| 135 | return `<div style="font-family:${sans};font-size:15px;line-height:1.6;color:${ink};">${html}</div>`; |
| 136 | } |
| 137 | |
| 138 | function orderTag(orderId: string): string { |
| 139 | return `<div style="margin-top:28px;padding-top:20px;border-top:1px dashed ${rule};font-family:${sans};font-size:12px;letter-spacing:0.06em;color:${inkSoft};text-align:center;"> |
| 140 | Order reference · <span style="color:${ink};font-weight:600;letter-spacing:0.12em;">${escapeHtml(displayOrderId(orderId))}</span> |
| 141 | </div>`; |
| 142 | } |
| 143 | |
| 144 | function escapeHtml(s: string): string { |
| 145 | return s |
| 146 | .replace(/&/g, '&') |
| 147 | .replace(/</g, '<') |
| 148 | .replace(/>/g, '>') |
| 149 | .replace(/"/g, '"') |
| 150 | .replace(/'/g, '''); |
| 151 | } |
| 152 | |
| 153 | // ─── Templates ─────────────────────────────────────────────────────── |
| 154 | |
| 155 | // Fully branded Lumen & Gesso receipt — replaces Stripe's generic |
| 156 | // "Receipt from Protomota, LLC" auto-receipt (we drop `receipt_email` on |
| 157 | // the Checkout Session so Stripe stops sending its own). Itemised so it |
| 158 | // reads as a real financial document. |
| 159 | export function receiptHtml(orderId: string, cents: number, paidDateLabel: string, itemLabel: string): string { |
| 160 | const amount = `$${(cents / 100).toFixed(2)}`; |
| 161 | const cell = `padding:11px 0;font-family:${sans};font-size:14px;color:${ink};`; |
| 162 | const cellLabel = `padding:11px 0;font-family:${sans};font-size:12px;letter-spacing:0.08em;text-transform:uppercase;color:${inkSoft};`; |
| 163 | return layout({ |
| 164 | preheader: `Your receipt for commission ${displayOrderId(orderId)} — ${amount} paid.`, |
| 165 | content: ` |
| 166 | ${eyebrow('Receipt')} |
| 167 | ${heading('Payment received — thank you.')} |
| 168 | ${body(` |
| 169 | <p style="margin:0 0 18px;">Here's your receipt for your Lumen & Gesso commission. We've started your portrait — your proof arrives within one business day (Mon–Fri).</p> |
| 170 | <table role="presentation" cellspacing="0" cellpadding="0" border="0" style="width:100%;border-collapse:collapse;margin:0;"> |
| 171 | <tr> |
| 172 | <td style="${cellLabel}border-bottom:1px solid ${rule};width:42%;">Receipt</td> |
| 173 | <td style="${cell}border-bottom:1px solid ${rule};font-weight:600;letter-spacing:0.04em;">${escapeHtml(displayOrderId(orderId))}</td> |
| 174 | </tr> |
| 175 | <tr> |
| 176 | <td style="${cellLabel}border-bottom:1px solid ${rule};">Date paid</td> |
| 177 | <td style="${cell}border-bottom:1px solid ${rule};">${escapeHtml(paidDateLabel)}</td> |
| 178 | </tr> |
| 179 | <tr> |
| 180 | <td style="${cellLabel}border-bottom:1px solid ${rule};">Amount paid</td> |
| 181 | <td style="${cell}border-bottom:1px solid ${rule};font-weight:600;">${amount}</td> |
| 182 | </tr> |
| 183 | </table> |
| 184 | <table role="presentation" cellspacing="0" cellpadding="0" border="0" style="width:100%;border-collapse:collapse;margin:18px 0 0;"> |
| 185 | <tr> |
| 186 | <td style="${cell}">${escapeHtml(itemLabel)} · ${escapeHtml(displayOrderId(orderId))}</td> |
| 187 | <td style="${cell}text-align:right;">${amount}</td> |
| 188 | </tr> |
| 189 | <tr> |
| 190 | <td style="${cell}border-top:1px solid ${rule};font-weight:700;">Total</td> |
| 191 | <td style="${cell}border-top:1px solid ${rule};text-align:right;font-weight:700;">${amount}</td> |
| 192 | </tr> |
| 193 | </table> |
| 194 | <p style="margin:20px 0 0;">Questions about your order or this receipt? Just reply, or reach us at <a href="mailto:hello@lumengesso.com" style="color:${roseDeep};">hello@lumengesso.com</a>.</p> |
| 195 | `)} |
| 196 | ${orderTag(orderId)}`, |
| 197 | footerNote: "You're receiving this receipt because you placed a commission with Lumen & Gesso.", |
| 198 | }); |
| 199 | } |
| 200 | |
| 201 | export function customerWelcomeHtml(orderId: string, link: string): string { |
| 202 | return layout({ |
| 203 | preheader: 'Your commission is in the queue — your proof arrives within one business day.', |
| 204 | content: ` |
| 205 | ${eyebrow('Commission received')} |
| 206 | ${heading('Your portrait is in the queue.')} |
| 207 | ${body(` |
| 208 | <p style="margin:0 0 14px;">Thank you — your payment came through and your spot is reserved. Our studio will hand-craft a first proof within <strong style="color:${ink};">one business day</strong> and email you the moment it's ready to review.</p> |
| 209 | <p style="margin:0 0 14px;">Studio hours run Monday through Friday. If you ordered on a Friday, expect your proof Monday morning.</p> |
| 210 | <p style="margin:0;">You'll have <em style="color:${roseDeep};">free revisions</em> until the portrait is right. If we ever can't make it work for you, you'll receive a full refund within 14 days.</p> |
| 211 | `)} |
| 212 | ${button('View your order', link)} |
| 213 | <p style="margin:18px 0 0;font-family:${sans};font-size:12.5px;line-height:1.5;color:${inkSoft};font-style:italic;text-align:center;"> |
| 214 | Shipping outside the US? Your country may collect import duty or VAT at delivery — those aren’t included in your order total. |
| 215 | </p> |
| 216 | ${orderTag(orderId)}`, |
| 217 | }); |
| 218 | } |
| 219 | |
| 220 | // Abandoned-cart reminder. Two-touch sequence driven by the cron route |
| 221 | // (/api/cron/cart-reminders): touch 1 ~1h after the cart was created, |
| 222 | // touch 2 (final) ~24h. `summary` is a short "style · product · size" |
| 223 | // line when we have one. The CTA links to /checkout?orderId=…&resume=1, |
| 224 | // which re-mints a Stripe session from the saved order. |
| 225 | export function cartReminderHtml( |
| 226 | orderId: string, |
| 227 | resumeUrl: string, |
| 228 | opts: { summary?: string | null; finalTouch?: boolean } = {}, |
| 229 | ): string { |
| 230 | const { summary, finalTouch } = opts; |
| 231 | const summaryLine = summary |
| 232 | ? `<p style="margin:0 0 14px;">Your commission so far: <strong style="color:${ink};">${escapeHtml(summary)}</strong>.</p>` |
| 233 | : ''; |
| 234 | // Touch 1 stays light and leaves room for the 24h follow-up. The final |
| 235 | // touch reassures that this is the last nudge. |
| 236 | const closingNote = finalTouch |
| 237 | ? `This is the last we’ll write about it — no charge has been made, and your design stays saved if you change your mind.` |
| 238 | : `No charge has been made; your design is saved and ready whenever you are.`; |
| 239 | return layout({ |
| 240 | preheader: finalTouch |
| 241 | ? 'Your custom pet portrait is still saved — finish whenever you’re ready.' |
| 242 | : 'You left a custom pet portrait in your cart — pick up right where you left off.', |
| 243 | content: ` |
| 244 | ${eyebrow(finalTouch ? 'Still here for you' : 'Your portrait is waiting')} |
| 245 | ${heading(finalTouch ? 'Still thinking it over?' : 'You left a portrait behind.')} |
| 246 | ${body(` |
| 247 | <p style="margin:0 0 14px;">${finalTouch |
| 248 | ? 'Your custom commission is still saved and ready to go. No pressure — but the studio would love to make this one for you, and it only takes a moment to finish.' |
| 249 | : 'You started a custom pet portrait but didn’t quite finish checkout. Good news: nothing was lost — your design is saved exactly as you left it.'}</p> |
| 250 | ${summaryLine} |
| 251 | <p style="margin:0;">${closingNote}</p> |
| 252 | `)} |
| 253 | ${button('Finish your commission', resumeUrl)} |
| 254 | ${orderTag(orderId)}`, |
| 255 | footerNote: 'You’re receiving this because you started a commission with our studio but didn’t finish checkout.', |
| 256 | }); |
| 257 | } |
| 258 | |
| 259 | export function ownerNotificationHtml(orderId: string, email: string, cents: number): string { |
| 260 | const adminUrl = `${env.site.url()}/admin/orders/${orderId}`; |
| 261 | return layout({ |
| 262 | preheader: `New commission from ${email} — $${(cents / 100).toFixed(2)}.`, |
| 263 | content: ` |
| 264 | ${eyebrow('New commission')} |
| 265 | ${heading('A fresh order just landed.')} |
| 266 | ${body(` |
| 267 | <table role="presentation" cellspacing="0" cellpadding="0" border="0" style="width:100%;border-collapse:collapse;margin:8px 0 4px;"> |
| 268 | <tr> |
| 269 | <td style="padding:10px 0;border-bottom:1px solid ${rule};font-family:${sans};font-size:13px;letter-spacing:0.08em;text-transform:uppercase;color:${inkSoft};width:36%;">Order</td> |
| 270 | <td style="padding:10px 0;border-bottom:1px solid ${rule};font-family:${sans};font-size:14px;color:${ink};font-weight:600;letter-spacing:0.04em;">${escapeHtml(displayOrderId(orderId))}</td> |
| 271 | </tr> |
| 272 | <tr> |
| 273 | <td style="padding:10px 0;border-bottom:1px solid ${rule};font-family:${sans};font-size:13px;letter-spacing:0.08em;text-transform:uppercase;color:${inkSoft};">Customer</td> |
| 274 | <td style="padding:10px 0;border-bottom:1px solid ${rule};font-family:${sans};font-size:14px;color:${ink};"><a href="mailto:${escapeHtml(email)}" style="color:${ink} !important;text-decoration:none !important;"><font color="${ink}" style="color:${ink} !important;text-decoration:none !important;"><span style="color:${ink} !important;text-decoration:none !important;">${escapeHtml(email)}</span></font></a></td> |
| 275 | </tr> |
| 276 | <tr> |
| 277 | <td style="padding:10px 0;font-family:${sans};font-size:13px;letter-spacing:0.08em;text-transform:uppercase;color:${inkSoft};">Paid</td> |
| 278 | <td style="padding:10px 0;font-family:${sans};font-size:14px;color:${ink};font-weight:600;">$${(cents / 100).toFixed(2)}</td> |
| 279 | </tr> |
| 280 | </table> |
| 281 | `)} |
| 282 | ${button('Open in admin', adminUrl)}`, |
| 283 | footerNote: 'Internal studio notification', |
| 284 | }); |
| 285 | } |
| 286 | |
| 287 | function studioMessageHtml(message: string): string { |
| 288 | return `<p style="margin:16px 0 4px;font-weight:600;">A note from the studio</p> |
| 289 | <blockquote style="margin:0 0 16px;padding:0 0 0 14px;border-left:2px solid ${rose};">${escapeHtml(message).replace(/\r\n|\r|\n/g, '<br />')}</blockquote>`; |
| 290 | } |
| 291 | |
| 292 | export function studioOrderMessageHtml(orderId: string, link: string, message: string, proofLink = false): string { |
| 293 | return layout({ |
| 294 | preheader: 'The studio sent you a message about your commission.', |
| 295 | content: ` |
| 296 | ${eyebrow('Studio message')} |
| 297 | ${heading('A message about your portrait.')} |
| 298 | ${body(studioMessageHtml(message))} |
| 299 | ${button(proofLink ? 'Review your proof' : 'View order and reply', link)} |
| 300 | ${orderTag(orderId)}`, |
| 301 | }); |
| 302 | } |
| 303 | |
| 304 | export function previewReadyHtml(orderId: string, link: string, frameDescription?: string | null, message?: string): string { |
| 305 | const frameLine = frameDescription |
| 306 | ? `<p style="margin:0 0 14px;">It's mocked up in your chosen <strong style="color:${ink};">${escapeHtml(frameDescription)}</strong> on the approval page so you can see exactly how it'll look on the wall.</p>` |
| 307 | : ''; |
| 308 | return layout({ |
| 309 | preheader: frameDescription |
| 310 | ? `Your portrait proof is ready — shown in your ${frameDescription}.` |
| 311 | : 'Your portrait proof is ready — review and approve, or ask for revisions.', |
| 312 | content: ` |
| 313 | ${eyebrow('Proof ready')} |
| 314 | ${heading('Your portrait is ready to review.')} |
| 315 | ${body(` |
| 316 | <p style="margin:0 0 14px;">Your portrait proof is ready. When you have a moment, take a look — you can approve it as-is, or ask for changes.</p> |
| 317 | ${frameLine} |
| 318 | ${message ? studioMessageHtml(message) : ''} |
| 319 | <p style="margin:0 0 14px;"><em style="color:${roseDeep};">Free revisions</em> are included until it feels right. You won't be charged a second time — your payment from earlier covers the final print.</p> |
| 320 | <p style="margin:0;">Open your proof to review it or reply in your order conversation.</p> |
| 321 | `)} |
| 322 | ${button('Review your portrait', link)} |
| 323 | ${orderTag(orderId)}`, |
| 324 | }); |
| 325 | } |
| 326 | |
| 327 | export function customerApprovedAdminNotificationHtml(orderId: string, email: string, cents: number): string { |
| 328 | const adminUrl = `${env.site.url()}/admin/orders/${orderId}`; |
| 329 | return layout({ |
| 330 | preheader: `${email} approved their portrait. Final review + send to printer.`, |
| 331 | content: ` |
| 332 | ${eyebrow('Customer approved')} |
| 333 | ${heading("It's time for your final review.")} |
| 334 | ${body(` |
| 335 | <p style="margin:0 0 14px;">The customer just approved their proof. The order is sitting in the admin panel waiting for you to give it one last look and click <strong style="color:${ink};">Send to printer</strong> — nothing goes to Prodigi automatically.</p> |
| 336 | <p style="margin:0;">Sanity-check the cropped print file (the one Prodigi receives), confirm the shipping address looks right, and ship it.</p> |
| 337 | `)} |
| 338 | ${button('Open in admin', adminUrl)} |
| 339 | <table role="presentation" cellspacing="0" cellpadding="0" border="0" style="width:100%;border-collapse:collapse;margin:24px 0 4px;"> |
| 340 | <tr> |
| 341 | <td style="padding:10px 0;border-bottom:1px solid ${rule};font-family:${sans};font-size:13px;letter-spacing:0.08em;text-transform:uppercase;color:${inkSoft};width:36%;">Order</td> |
| 342 | <td style="padding:10px 0;border-bottom:1px solid ${rule};font-family:${sans};font-size:14px;color:${ink};font-weight:600;letter-spacing:0.04em;">${escapeHtml(displayOrderId(orderId))}</td> |
| 343 | </tr> |
| 344 | <tr> |
| 345 | <td style="padding:10px 0;border-bottom:1px solid ${rule};font-family:${sans};font-size:13px;letter-spacing:0.08em;text-transform:uppercase;color:${inkSoft};">Customer</td> |
| 346 | <td style="padding:10px 0;border-bottom:1px solid ${rule};font-family:${sans};font-size:14px;color:${ink};"><a href="mailto:${escapeHtml(email)}" style="color:${ink} !important;text-decoration:none !important;"><font color="${ink}" style="color:${ink} !important;text-decoration:none !important;"><span style="color:${ink} !important;text-decoration:none !important;">${escapeHtml(email)}</span></font></a></td> |
| 347 | </tr> |
| 348 | <tr> |
| 349 | <td style="padding:10px 0;font-family:${sans};font-size:13px;letter-spacing:0.08em;text-transform:uppercase;color:${inkSoft};">Paid</td> |
| 350 | <td style="padding:10px 0;font-family:${sans};font-size:14px;color:${ink};font-weight:600;">$${(cents / 100).toFixed(2)}</td> |
| 351 | </tr> |
| 352 | </table>`, |
| 353 | footerNote: 'Internal studio notification', |
| 354 | }); |
| 355 | } |
| 356 | |
| 357 | export function cancellationCustomerHtml(orderId: string, cents: number): string { |
| 358 | const amount = `$${(cents / 100).toFixed(2)}`; |
| 359 | return layout({ |
| 360 | preheader: `Your commission has been cancelled and a full refund of ${amount} is on the way.`, |
| 361 | content: ` |
| 362 | ${eyebrow('Cancellation confirmed')} |
| 363 | ${heading("Your commission has been cancelled.")} |
| 364 | ${body(` |
| 365 | <p style="margin:0 0 14px;">No problem — we've taken your commission out of the studio queue and issued a full refund of <strong style="color:${ink};">${amount}</strong> back to the card you paid with.</p> |
| 366 | <p style="margin:0 0 14px;">Refunds typically take <strong style="color:${ink};">5–10 business days</strong> to land back on your statement, depending on your bank. You'll see it as a "Lumen & Gesso" refund.</p> |
| 367 | <p style="margin:0;">If you'd like to come back later, your photos and selections aren't saved on our end — you'd start a fresh commission from <a href="${env.site.url()}/builder" style="color:${roseDeep};">our builder</a>. Anything we can do better, just reply to this email.</p> |
| 368 | `)} |
| 369 | ${orderTag(orderId)}`, |
| 370 | footerNote: "You're receiving this because you cancelled a commission with our studio. Questions? Just reply — we read every email.", |
| 371 | }); |
| 372 | } |
| 373 | |
| 374 | // Customer-facing cancel confirmation for an order that had NO completed |
| 375 | // payment on file (nothing to refund). Reassures them they weren't charged |
| 376 | // and points anyone who thinks otherwise to the studio. |
| 377 | export function cancellationNoPaymentHtml(orderId: string): string { |
| 378 | return layout({ |
| 379 | preheader: `Your commission has been cancelled. No payment was found, so there's nothing to refund.`, |
| 380 | content: ` |
| 381 | ${eyebrow('Cancellation confirmed')} |
| 382 | ${heading('Your commission has been cancelled.')} |
| 383 | ${body(` |
| 384 | <p style="margin:0 0 14px;">We've taken your commission out of the studio queue. <strong style="color:${ink};">We didn't find a completed payment on this order</strong>, so there's nothing to refund — you haven't been charged.</p> |
| 385 | <p style="margin:0 0 14px;">If you believe this is a mistake — or you think you were charged — please contact the studio at <a href="mailto:hello@lumengesso.com" style="color:${roseDeep};">hello@lumengesso.com</a> and we'll sort it out right away.</p> |
| 386 | <p style="margin:0;">Want to try again? Start a fresh commission from <a href="${env.site.url()}/builder" style="color:${roseDeep};">our builder</a>.</p> |
| 387 | `)} |
| 388 | ${orderTag(orderId)}`, |
| 389 | footerNote: "You're receiving this because you cancelled a commission with our studio. Questions? Just reply — we read every email.", |
| 390 | }); |
| 391 | } |
| 392 | |
| 393 | export function cancellationByStudioHtml(orderId: string, cents: number, reason: string | null): string { |
| 394 | const amount = `$${(cents / 100).toFixed(2)}`; |
| 395 | return layout({ |
| 396 | preheader: `Our studio has cancelled your commission and issued a full refund of ${amount}.`, |
| 397 | content: ` |
| 398 | ${eyebrow('Cancelled by the studio')} |
| 399 | ${heading("We've had to cancel your commission.")} |
| 400 | ${body(` |
| 401 | <p style="margin:0 0 14px;">Our studio has cancelled commission <strong style="color:${ink};">${escapeHtml(displayOrderId(orderId))}</strong>.</p> |
| 402 | ${reason ? `<p style="margin:0 0 14px;">Reason: <em style="color:${ink};">${escapeHtml(reason)}</em></p>` : ''} |
| 403 | <p style="margin:0 0 14px;">A full refund of <strong style="color:${ink};">${amount}</strong> has been issued back to the card you paid with. Refunds typically take <strong style="color:${ink};">5–10 business days</strong> to land on your statement.</p> |
| 404 | <p style="margin:0;">We're sorry for any inconvenience. If you'd like to discuss what happened or try a fresh commission, reply to this email — we read every message.</p> |
| 405 | `)} |
| 406 | ${orderTag(orderId)}`, |
| 407 | footerNote: "You're receiving this because our studio cancelled a commission you placed. Questions? Just reply.", |
| 408 | }); |
| 409 | } |
| 410 | |
| 411 | export function cancellationStudioInternalHtml( |
| 412 | orderId: string, |
| 413 | email: string, |
| 414 | cents: number, |
| 415 | extras: { reason: string | null; refundId: string | null; refundError: string | null; prodigiOrderId: string | null }, |
| 416 | ): string { |
| 417 | const adminUrl = `${env.site.url()}/admin/orders/${orderId}`; |
| 418 | const refundLine = extras.refundError |
| 419 | ? `<span style="color:${roseDeep};font-weight:600;">FAILED — ${escapeHtml(extras.refundError)} (refund manually via Stripe dashboard)</span>` |
| 420 | : extras.refundId |
| 421 | ? `Issued · <span style="font-family:monospace;color:${ink};">${escapeHtml(extras.refundId)}</span>` |
| 422 | : 'No charge on file (nothing to refund)'; |
| 423 | const prodigiLine = extras.prodigiOrderId |
| 424 | ? `<span style="color:${roseDeep};font-weight:600;">EXISTS — ${escapeHtml(extras.prodigiOrderId)} · cancel via Prodigi dashboard separately</span>` |
| 425 | : 'None — order never went to print'; |
| 426 | return layout({ |
| 427 | preheader: `Admin cancelled commission ${displayOrderId(orderId)} for ${email} — refund $${(cents / 100).toFixed(2)}.`, |
| 428 | content: ` |
| 429 | ${eyebrow('Admin cancellation')} |
| 430 | ${heading('You just cancelled an order.')} |
| 431 | ${body(` |
| 432 | <p style="margin:0 0 14px;">Internal record so the studio inbox has a copy. The customer has been emailed separately.</p> |
| 433 | <table role="presentation" cellspacing="0" cellpadding="0" border="0" style="width:100%;border-collapse:collapse;margin:8px 0 4px;"> |
| 434 | <tr> |
| 435 | <td style="padding:10px 0;border-bottom:1px solid ${rule};font-family:${sans};font-size:13px;letter-spacing:0.08em;text-transform:uppercase;color:${inkSoft};width:36%;">Order</td> |
| 436 | <td style="padding:10px 0;border-bottom:1px solid ${rule};font-family:${sans};font-size:14px;color:${ink};font-weight:600;letter-spacing:0.04em;">${escapeHtml(displayOrderId(orderId))}</td> |
| 437 | </tr> |
| 438 | <tr> |
| 439 | <td style="padding:10px 0;border-bottom:1px solid ${rule};font-family:${sans};font-size:13px;letter-spacing:0.08em;text-transform:uppercase;color:${inkSoft};">Customer</td> |
| 440 | <td style="padding:10px 0;border-bottom:1px solid ${rule};font-family:${sans};font-size:14px;color:${ink};"><a href="mailto:${escapeHtml(email)}" style="color:${ink} !important;text-decoration:none !important;"><font color="${ink}" style="color:${ink} !important;text-decoration:none !important;"><span style="color:${ink} !important;text-decoration:none !important;">${escapeHtml(email)}</span></font></a></td> |
| 441 | </tr> |
| 442 | <tr> |
| 443 | <td style="padding:10px 0;border-bottom:1px solid ${rule};font-family:${sans};font-size:13px;letter-spacing:0.08em;text-transform:uppercase;color:${inkSoft};">Refund</td> |
| 444 | <td style="padding:10px 0;border-bottom:1px solid ${rule};font-family:${sans};font-size:13px;color:${ink};">${refundLine}</td> |
| 445 | </tr> |
| 446 | <tr> |
| 447 | <td style="padding:10px 0;border-bottom:1px solid ${rule};font-family:${sans};font-size:13px;letter-spacing:0.08em;text-transform:uppercase;color:${inkSoft};">Prodigi order</td> |
| 448 | <td style="padding:10px 0;border-bottom:1px solid ${rule};font-family:${sans};font-size:13px;color:${ink};">${prodigiLine}</td> |
| 449 | </tr> |
| 450 | <tr> |
| 451 | <td style="padding:10px 0;font-family:${sans};font-size:13px;letter-spacing:0.08em;text-transform:uppercase;color:${inkSoft};">Reason</td> |
| 452 | <td style="padding:10px 0;font-family:${sans};font-size:13px;color:${ink};">${extras.reason ? escapeHtml(extras.reason) : '<span style="color:' + inkSoft + ';">(none provided)</span>'}</td> |
| 453 | </tr> |
| 454 | </table> |
| 455 | `)} |
| 456 | ${button('Open in admin', adminUrl)}`, |
| 457 | footerNote: 'Internal admin notification — record of cancellation action', |
| 458 | }); |
| 459 | } |
| 460 | |
| 461 | export function cancellationStudioHtml(orderId: string, email: string, cents: number): string { |
| 462 | const adminUrl = `${env.site.url()}/admin/orders/${orderId}`; |
| 463 | return layout({ |
| 464 | preheader: `${email} cancelled commission ${displayOrderId(orderId)} — refunded $${(cents / 100).toFixed(2)}.`, |
| 465 | content: ` |
| 466 | ${eyebrow('Cancellation')} |
| 467 | ${heading('An order was just cancelled.')} |
| 468 | ${body(` |
| 469 | <table role="presentation" cellspacing="0" cellpadding="0" border="0" style="width:100%;border-collapse:collapse;margin:8px 0 4px;"> |
| 470 | <tr> |
| 471 | <td style="padding:10px 0;border-bottom:1px solid ${rule};font-family:${sans};font-size:13px;letter-spacing:0.08em;text-transform:uppercase;color:${inkSoft};width:36%;">Order</td> |
| 472 | <td style="padding:10px 0;border-bottom:1px solid ${rule};font-family:${sans};font-size:14px;color:${ink};font-weight:600;letter-spacing:0.04em;">${escapeHtml(displayOrderId(orderId))}</td> |
| 473 | </tr> |
| 474 | <tr> |
| 475 | <td style="padding:10px 0;border-bottom:1px solid ${rule};font-family:${sans};font-size:13px;letter-spacing:0.08em;text-transform:uppercase;color:${inkSoft};">Customer</td> |
| 476 | <td style="padding:10px 0;border-bottom:1px solid ${rule};font-family:${sans};font-size:14px;color:${ink};"><a href="mailto:${escapeHtml(email)}" style="color:${ink} !important;text-decoration:none !important;"><font color="${ink}" style="color:${ink} !important;text-decoration:none !important;"><span style="color:${ink} !important;text-decoration:none !important;">${escapeHtml(email)}</span></font></a></td> |
| 477 | </tr> |
| 478 | <tr> |
| 479 | <td style="padding:10px 0;font-family:${sans};font-size:13px;letter-spacing:0.08em;text-transform:uppercase;color:${inkSoft};">Refunded</td> |
| 480 | <td style="padding:10px 0;font-family:${sans};font-size:14px;color:${ink};font-weight:600;">$${(cents / 100).toFixed(2)}</td> |
| 481 | </tr> |
| 482 | </table> |
| 483 | <p style="margin:18px 0 0;font-size:13px;color:${inkSoft};">Stripe refund was issued automatically. No further action needed.</p> |
| 484 | `)} |
| 485 | ${button('Open in admin', adminUrl)}`, |
| 486 | footerNote: 'Internal studio notification', |
| 487 | }); |
| 488 | } |
| 489 | |
| 490 | export function inProductionHtml(orderId: string, link: string, prodigiOrderId?: string | null): string { |
| 491 | return layout({ |
| 492 | preheader: 'Your portrait is approved and headed to print — we’ll email again when it ships.', |
| 493 | content: ` |
| 494 | ${eyebrow('In production')} |
| 495 | ${heading('Your portrait is on its way to print.')} |
| 496 | ${body(` |
| 497 | <p style="margin:0 0 14px;">Thank you for approving — your commission has been sent to our print partner. Typical production runs three to five business days, and shipping is on top of that.</p> |
| 498 | <p style="margin:0;">We'll email you again the moment a tracking number is ready. In the meantime, you can check the status of your order at any time.</p> |
| 499 | <p style="margin:14px 0 0;">Once your portrait arrives, we’d love to hear what you think. From your order page, you can leave a star rating, write a review, and share a photo of your pet or portrait if you’d like.</p> |
| 500 | `)} |
| 501 | ${button('View your order', link)} |
| 502 | ${prodigiOrderId ? `<p style="margin:24px 0 0;text-align:center;font-family:${sans};font-size:12px;color:${inkSoft};letter-spacing:0.04em;">Print reference · <span style="color:${ink};font-weight:600;">${escapeHtml(prodigiOrderId)}</span></p>` : ''} |
| 503 | ${orderTag(orderId)}`, |
| 504 | }); |
| 505 | } |
| 506 | |
| 507 | export function shippedHtml( |
| 508 | orderId: string, |
| 509 | link: string, |
| 510 | tracking: { number?: string | null; url?: string | null; carrier?: string | null }, |
| 511 | ): string { |
| 512 | const { number, url, carrier } = tracking; |
| 513 | const carrierLine = carrier |
| 514 | ? `<p style="margin:0 0 14px;">Carrier: <strong style="color:${ink};">${escapeHtml(carrier)}</strong></p>` |
| 515 | : ''; |
| 516 | const numberBlock = number |
| 517 | ? `<div style="margin:8px 0 20px;padding:16px 18px;background:${creamLight};border:1px solid ${rule};border-radius:2px;"> |
| 518 | <div style="font-family:${sans};font-size:11px;font-weight:700;letter-spacing:0.16em;text-transform:uppercase;color:${inkSoft};margin-bottom:6px;">Tracking number</div> |
| 519 | <div style="font-family:${sans};font-size:18px;font-weight:600;letter-spacing:0.06em;color:${ink};">${escapeHtml(number)}</div> |
| 520 | </div>` |
| 521 | : ''; |
| 522 | return layout({ |
| 523 | preheader: number |
| 524 | ? `Your portrait has shipped — tracking ${number}.` |
| 525 | : 'Your portrait has shipped — it’s on its way to you.', |
| 526 | content: ` |
| 527 | ${eyebrow('Shipped')} |
| 528 | ${heading('Your portrait is on its way.')} |
| 529 | ${body(` |
| 530 | <p style="margin:0 0 14px;">Great news — your commission has left our print partner and is heading to you.</p> |
| 531 | ${carrierLine} |
| 532 | ${numberBlock} |
| 533 | ${url ? '' : `<p style="margin:0 0 14px;">Tracking details should appear with the carrier shortly.</p>`} |
| 534 | <p style="margin:0;">Questions about delivery? Just reply to this email — we read every one.</p> |
| 535 | `)} |
| 536 | ${url ? button('Track your shipment', url) : button('View your order', link)} |
| 537 | ${url ? `<p style="margin:18px 0 0;text-align:center;font-family:${sans};font-size:13px;"><a href="${link}" style="color:${roseDeep};text-decoration:none;border-bottom:1px solid ${rule};">View your order</a></p>` : ''} |
| 538 | ${orderTag(orderId)}`, |
| 539 | }); |
| 540 | } |