import type { ReactNode } from "react"; import { Layout } from "../components/Layout.js"; import { Button, Footer, Heading, Paragraph, Spacer } from "../components/primitives.js"; export interface GenericStepEmailCopy { readonly defaultCta: string; readonly fallbackRecipient: string; readonly footerReason: (productName: string) => ReactNode; readonly unsubscribe: string; readonly greeting: (recipientName: string) => ReactNode; readonly signoff: (productName: string) => ReactNode; } export interface GenericStepEmailProps { readonly recipientName?: string; readonly productName: string; readonly headline: string; /** * Body paragraphs. Each entry is rendered as a separate . * Markdown is intentionally NOT supported here — the admin UI passes * plain text and trusted variables only. */ readonly bodyParagraphs: readonly string[]; readonly ctaUrl?: string; readonly ctaLabel?: string; readonly unsubscribeUrl: string; readonly preface?: ReactNode; readonly copy?: Partial; } const defaultCopy: GenericStepEmailCopy = { defaultCta: "Open dashboard", fallbackRecipient: "there", footerReason: (productName) => `You receive this email because you signed up at ${productName}.`, unsubscribe: "Unsubscribe", greeting: (recipientName) => `Hi ${recipientName},`, signoff: (productName) => `\u2014 The ${productName} team`, }; /** * Configurable step template used for the onboarding-drip and for any * generic-step in an operator-defined sequence. Variables are passed * pre-substituted by the engine; React escapes everything it renders * so there is no XSS risk from PII in `bodyParagraphs`. */ export function GenericStepEmail({ recipientName, productName, headline, bodyParagraphs, ctaUrl, ctaLabel, unsubscribeUrl, preface, copy, }: GenericStepEmailProps) { const resolvedCopy = { ...defaultCopy, ...copy }; const greetingTarget = recipientName?.trim() || resolvedCopy.fallbackRecipient; return ( {resolvedCopy.footerReason(productName)}
{resolvedCopy.unsubscribe} } > {headline} {resolvedCopy.greeting(greetingTarget)} {preface ?? null} {bodyParagraphs.map((line, idx) => ( {line} ))} {ctaUrl ? ( <> ) : null} {resolvedCopy.signoff(productName)}
); }