email templates

This commit is contained in:
nmemmert
2026-06-03 13:14:08 -04:00
parent 49c9994156
commit a2c4924191
5 changed files with 389 additions and 51 deletions
+154 -3
View File
@@ -358,6 +358,114 @@ function StudyUsersPanel({ studies }: { studies: StudyProgram[] }) {
)
}
function EmailTemplatesPanel({
form,
handleChange,
renderSaveStatus,
}: {
form: SiteContent
handleChange: (key: StringField, value: string) => void
renderSaveStatus: () => React.ReactNode
}) {
const [expandedEmail, setExpandedEmail] = useState<string | null>(null)
function EmailTemplateCard({
type, icon, title, trigger, autoVars, fieldKeys, openKey,
}: {
type: 'newsletter' | 'study' | 'transactional'
icon: string
title: string
trigger: string
autoVars?: string
fieldKeys: string[]
openKey: string
}) {
const isOpen = expandedEmail === openKey
return (
<div className={`admin-et-card admin-et-card--${type}${isOpen ? ' admin-et-card--open' : ''}`}>
<button
type="button"
className="admin-et-card-header"
onClick={() => setExpandedEmail(isOpen ? null : openKey)}
>
<span className="admin-et-card-icon" aria-hidden="true">{icon}</span>
<div className="admin-et-card-meta">
<div className="admin-et-card-title-row">
<span className={`admin-et-badge admin-et-badge--${type}`}>{type}</span>
<strong className="admin-et-card-title">{title}</strong>
</div>
<p className="admin-et-card-trigger"> {trigger}</p>
</div>
<span className="admin-et-card-chevron">{isOpen ? '▲' : '▼'}</span>
</button>
{isOpen && (
<div className="admin-et-card-body">
{autoVars && (
<p className="admin-et-card-vars">
<span className="admin-et-card-vars-label">Auto-inserted:</span> {autoVars}
</p>
)}
{fieldKeys.map(key => {
const field = FIELDS.find(f => f.key === key && f.section === 'email-templates')
if (!field) return null
return (
<div className="admin-field" key={key}>
<label htmlFor={`field-et-${key}`}>{field.label}</label>
{field.multiline
? <textarea id={`field-et-${key}`} rows={3} value={form[key as StringField] as string} onChange={e => handleChange(key as StringField, e.target.value)} />
: <input id={`field-et-${key}`} type="text" value={form[key as StringField] as string} onChange={e => handleChange(key as StringField, e.target.value)} />
}
</div>
)
})}
</div>
)}
</div>
)
}
return (
<section className="admin-panel-section" aria-label="Email Templates">
<div className="admin-panel-head">
<h2>Email Templates</h2>
<p>Every automated email the site sends edit subject lines, body copy, and sign-offs. Publish to apply changes.</p>
</div>
<EmailTemplateCard type="newsletter" icon="📬" title="Newsletter Welcome"
trigger="Someone subscribes via the homepage form or contact page"
autoVars="Subscriber's first name, Spotify / Apple / Amazon links"
fieldKeys={['welcomeEmailSubject','welcomeEmailGreetingPrefix','welcomeEmailIntro','welcomeEmailCurrentSeries','welcomeEmailStartHereTitle','welcomeEmailStartHereSummary','welcomeEmailStartHereUrl','welcomeEmailStartHereLinkLabel','welcomeEmailWhatToExpect1','welcomeEmailWhatToExpect2','welcomeEmailWhatToExpect3','welcomeEmailScripture','welcomeEmailScriptureRef','welcomeEmailSignoff','welcomeEmailSpotifyUrl','welcomeEmailSpotifyBtnLabel','welcomeEmailAppleUrl','welcomeEmailAppleBtnLabel','welcomeEmailAmazonUrl']}
openKey="newsletter-welcome" />
<EmailTemplateCard type="study" icon="📖" title="Study Account — New Account"
trigger="A student creates a study account"
autoVars="Student's display name, link to study hub, link to account page"
fieldKeys={['studyWelcomeEmailSubject','studyWelcomeEmailBody','studyWelcomeEmailCtaLabel','studyWelcomeEmailCtaPath','studyWelcomeEmailSignoff']}
openKey="study-welcome" />
<EmailTemplateCard type="study" icon="🗑️" title="Study Account — Account Deleted"
trigger="A student (or admin) deletes a study account"
autoVars="Student's display name, link to create a new account"
fieldKeys={['studyDeletedEmailSubject','studyDeletedEmailBody','studyDeletedEmailCtaLabel','studyDeletedEmailCtaPath','studyDeletedEmailSignoff']}
openKey="study-deleted" />
<EmailTemplateCard type="study" icon="🔔" title="Study Account — New Lesson Unlocked"
trigger="A lesson releases for a student who has reminders turned on"
autoVars="Student's name, lesson title, scripture reference, study track name — button links directly to the lesson (auto-generated, not editable)"
fieldKeys={['studyReminderEmailSubjectPrefix','studyReminderEmailBody','studyReminderEmailCtaLabel','studyReminderEmailSignoff']}
openKey="study-reminder" />
<EmailTemplateCard type="transactional" icon="🔐" title="Account Security — Email Change Confirmation"
trigger="A student requests to change their account email address"
autoVars="Button links to a one-time verification URL (auto-generated per request, not editable)"
fieldKeys={['emailChangeSubject','emailChangeBody','emailChangeCtaLabel']}
openKey="email-change" />
{renderSaveStatus()}
</section>
)
}
interface Props {
content: SiteContent
onSave: (c: SiteContent) => void
@@ -557,7 +665,7 @@ type AdminView =
| 'podcast' | 'current-series' | 'episode-highlights' | 'podcast-checklist' | 'archived-series'
| 'downloads' | 'custom-links' | 'content-blocks'
| 'questions' | 'analytics' | 'assets' | 'colossians-study'
| 'emails' | 'subscribers' | 'contacts' | 'study-users'
| 'emails' | 'subscribers' | 'contacts' | 'study-users' | 'email-templates'
| 'seo' | 'legal' | 'security' | 'brand' | 'global'
interface AdminSectionLink {
@@ -597,6 +705,7 @@ const ADMIN_VIEW_OPTIONS: Array<{ group: string; options: Array<{ value: AdminVi
{ value: 'contacts', label: 'Contacts' },
{ value: 'subscribers', label: 'Subscribers' },
{ value: 'study-users', label: 'Study Users' },
{ value: 'email-templates', label: 'Email Templates' },
{ value: 'analytics', label: 'Analytics' },
{ value: 'assets', label: 'Asset Manager' },
],
@@ -661,7 +770,7 @@ const ADMIN_SECTION_LINKS: Partial<Record<AdminView, AdminSectionLink[]>> = {
type PodcastTab = 'current-series' | 'episode-highlights' | 'podcast-checklist' | 'archived-series'
type MainContentSection = 'hero' | 'start-here' | 'about' | 'contact' | 'series' | 'share' | 'prism' | 'global'
type MainContentSection = 'hero' | 'start-here' | 'about' | 'contact' | 'series' | 'share' | 'prism' | 'global' | 'email-templates'
const BRAND_KIT_SWATCHES = [
{ name: 'Rich Black', hex: '#0a0a08', role: 'Primary background' },
@@ -792,7 +901,44 @@ const FIELDS: Array<{ key: StringField; label: string; multiline?: boolean; sect
{ key: 'welcomeEmailWhatToExpect3', label: 'Welcome Email — What to Expect 3', multiline: true, section: 'global' },
{ key: 'welcomeEmailScripture', label: 'Welcome Email — Scripture Text', multiline: true, section: 'global' },
{ key: 'welcomeEmailScriptureRef', label: 'Welcome Email — Scripture Reference', section: 'global' },
{ key: 'welcomeEmailSignoff', label: 'Welcome Email — Signoff HTML', multiline: true, section: 'global' },
{ key: 'welcomeEmailSignoff', label: 'Signoff', multiline: true, section: 'global' },
// ── Email Templates section ──
{ key: 'welcomeEmailSubject', label: 'Subject Line', section: 'email-templates' },
{ key: 'welcomeEmailGreetingPrefix', label: 'Greeting Prefix (before subscriber name)', section: 'email-templates' },
{ key: 'welcomeEmailIntro', label: 'Intro Paragraph', multiline: true, section: 'email-templates' },
{ key: 'welcomeEmailCurrentSeries', label: 'Current Series Blurb', multiline: true, section: 'email-templates' },
{ key: 'welcomeEmailStartHereTitle', label: 'Start Here Episode Title', section: 'email-templates' },
{ key: 'welcomeEmailStartHereSummary', label: 'Start Here Episode Summary', multiline: true, section: 'email-templates' },
{ key: 'welcomeEmailStartHereUrl', label: 'Start Here Episode URL', section: 'email-templates' },
{ key: 'welcomeEmailWhatToExpect1', label: 'What to Expect — Line 1', multiline: true, section: 'email-templates' },
{ key: 'welcomeEmailWhatToExpect2', label: 'What to Expect — Line 2', multiline: true, section: 'email-templates' },
{ key: 'welcomeEmailWhatToExpect3', label: 'What to Expect — Line 3', multiline: true, section: 'email-templates' },
{ key: 'welcomeEmailScripture', label: 'Closing Scripture Text', multiline: true, section: 'email-templates' },
{ key: 'welcomeEmailScriptureRef', label: 'Closing Scripture Reference', section: 'email-templates' },
{ key: 'welcomeEmailSignoff', label: 'Signoff', multiline: true, section: 'email-templates' },
{ key: 'welcomeEmailSpotifyUrl', label: 'Spotify URL', section: 'email-templates' },
{ key: 'welcomeEmailSpotifyBtnLabel', label: '"Listen on Spotify" button label', section: 'email-templates' },
{ key: 'welcomeEmailAppleUrl', label: 'Apple Podcasts URL', section: 'email-templates' },
{ key: 'welcomeEmailAppleBtnLabel', label: '"Apple Podcasts" button label', section: 'email-templates' },
{ key: 'welcomeEmailAmazonUrl', label: 'Amazon Music URL', section: 'email-templates' },
{ key: 'welcomeEmailStartHereLinkLabel', label: '"Start Here" link label', section: 'email-templates' },
{ key: 'studyWelcomeEmailSubject', label: 'Subject Line', section: 'email-templates' },
{ key: 'studyWelcomeEmailBody', label: 'Body Paragraph', multiline: true, section: 'email-templates' },
{ key: 'studyWelcomeEmailCtaLabel', label: 'Button Label', section: 'email-templates' },
{ key: 'studyWelcomeEmailCtaPath', label: 'Button Link (path or full URL)', section: 'email-templates' },
{ key: 'studyWelcomeEmailSignoff', label: 'Signoff', multiline: true, section: 'email-templates' },
{ key: 'studyDeletedEmailSubject', label: 'Subject Line', section: 'email-templates' },
{ key: 'studyDeletedEmailBody', label: 'Body Paragraph', multiline: true, section: 'email-templates' },
{ key: 'studyDeletedEmailCtaLabel', label: 'Button Label', section: 'email-templates' },
{ key: 'studyDeletedEmailCtaPath', label: 'Button Link (path or full URL)', section: 'email-templates' },
{ key: 'studyDeletedEmailSignoff', label: 'Signoff', multiline: true, section: 'email-templates' },
{ key: 'studyReminderEmailSubjectPrefix', label: 'Subject Prefix (lesson title auto-appended)', section: 'email-templates' },
{ key: 'studyReminderEmailBody', label: 'Body Paragraph', multiline: true, section: 'email-templates' },
{ key: 'studyReminderEmailCtaLabel', label: 'Button Label', section: 'email-templates' },
{ key: 'studyReminderEmailSignoff', label: 'Signoff', multiline: true, section: 'email-templates' },
{ key: 'emailChangeSubject', label: 'Subject Line', section: 'email-templates' },
{ key: 'emailChangeBody', label: 'Body Text', multiline: true, section: 'email-templates' },
{ key: 'emailChangeCtaLabel', label: 'Button Label', section: 'email-templates' },
]
function normalizeStudies(siteContent: SiteContent): StudyProgram[] {
@@ -4480,6 +4626,11 @@ export default function AdminPage({ content, onSave, onLogout }: Props) {
</section>
)}
{/* EMAIL TEMPLATES */}
{adminView === 'email-templates' && (
<EmailTemplatesPanel form={form} handleChange={handleChange} renderSaveStatus={renderSaveStatus} />
)}
{/* QUESTIONS */}
{adminView === 'questions' && (
<section className="admin-panel-section" aria-label="Q&A Management">
+109
View File
@@ -6453,3 +6453,112 @@
background: rgba(201, 168, 76, 0.08);
border-radius: 6px;
}
/* ── Admin: Email Templates ── */
.admin-et-card {
border-radius: 10px;
margin-bottom: 0.75rem;
overflow: hidden;
border: 1px solid rgba(201, 168, 76, 0.12);
border-left-width: 4px;
background: #0b0b09;
}
.admin-et-card--newsletter { border-left-color: #c9a84c; }
.admin-et-card--study { border-left-color: #7abf7a; }
.admin-et-card--transactional { border-left-color: #7aaacf; }
.admin-et-card--open {
border-color: rgba(201, 168, 76, 0.3);
border-left-width: 4px;
}
.admin-et-card--open.admin-et-card--newsletter { border-left-color: #c9a84c; }
.admin-et-card--open.admin-et-card--study { border-left-color: #7abf7a; }
.admin-et-card--open.admin-et-card--transactional { border-left-color: #7aaacf; }
.admin-et-card-header {
width: 100%;
display: flex;
align-items: center;
gap: 1rem;
padding: 0.9rem 1.1rem;
background: none;
border: none;
color: inherit;
cursor: pointer;
text-align: left;
}
.admin-et-card-header:hover {
background: rgba(201, 168, 76, 0.04);
}
.admin-et-card-icon {
font-size: 1.4rem;
flex-shrink: 0;
line-height: 1;
}
.admin-et-card-meta {
flex: 1;
min-width: 0;
}
.admin-et-card-title-row {
display: flex;
align-items: center;
gap: 0.5rem;
margin-bottom: 0.2rem;
flex-wrap: wrap;
}
.admin-et-card-title {
font-size: 0.95rem;
font-weight: 700;
color: #f0e9cc;
}
.admin-et-card-trigger {
font-size: 0.78rem;
color: #8a7f5a;
margin: 0;
}
.admin-et-card-chevron {
font-size: 0.75rem;
color: #5a5440;
flex-shrink: 0;
}
.admin-et-badge {
font-size: 0.62rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.08em;
padding: 0.15rem 0.5rem;
border-radius: 3px;
flex-shrink: 0;
}
.admin-et-badge--newsletter { background: rgba(201,168,76,0.15); color: #c9a84c; }
.admin-et-badge--study { background: rgba(100,160,100,0.15); color: #7abf7a; }
.admin-et-badge--transactional { background: rgba(100,140,200,0.15); color: #7aaacf; }
.admin-et-card-body {
padding: 0 1.25rem 1.25rem;
border-top: 1px solid rgba(201, 168, 76, 0.08);
}
.admin-et-card-vars {
font-size: 0.78rem;
color: #6a6040;
background: rgba(201, 168, 76, 0.05);
border-radius: 5px;
padding: 0.45rem 0.75rem;
margin: 0.75rem 0 1rem;
}
.admin-et-card-vars-label {
color: #8a7f5a;
font-weight: 600;
}
+45
View File
@@ -223,6 +223,31 @@ export interface SiteContent {
welcomeEmailScripture: string
welcomeEmailScriptureRef: string
welcomeEmailSignoff: string
// ── Newsletter Welcome Email CTA labels ──
welcomeEmailSpotifyBtnLabel: string
welcomeEmailAppleBtnLabel: string
welcomeEmailStartHereLinkLabel: string
// ── Study Account Welcome Email ──
studyWelcomeEmailSubject: string
studyWelcomeEmailBody: string
studyWelcomeEmailCtaLabel: string
studyWelcomeEmailCtaPath: string
studyWelcomeEmailSignoff: string
// ── Study Account Deleted Email ──
studyDeletedEmailSubject: string
studyDeletedEmailBody: string
studyDeletedEmailCtaLabel: string
studyDeletedEmailCtaPath: string
studyDeletedEmailSignoff: string
// ── Study Lesson Reminder Email ──
studyReminderEmailSubjectPrefix: string
studyReminderEmailBody: string
studyReminderEmailCtaLabel: string
studyReminderEmailSignoff: string
// ── Email Change Confirmation ──
emailChangeSubject: string
emailChangeBody: string
emailChangeCtaLabel: string
// ── Header ──
headerFollowLabel: string
// ── Cookie banner ──
@@ -387,6 +412,26 @@ export const DEFAULTS: SiteContent = {
welcomeEmailScripture: 'For the grace of God has appeared, bringing salvation to all people.',
welcomeEmailScriptureRef: 'Titus 2:11 - BSB',
welcomeEmailSignoff: 'Grace and peace,\nNate',
welcomeEmailSpotifyBtnLabel: 'Listen on Spotify',
welcomeEmailAppleBtnLabel: 'Apple Podcasts',
welcomeEmailStartHereLinkLabel: 'Open Start Here page',
studyWelcomeEmailSubject: 'Welcome to the Study Community',
studyWelcomeEmailBody: 'Your student account is ready. Open your studies and continue learning, or manage your account details anytime.',
studyWelcomeEmailCtaLabel: 'Open Studies',
studyWelcomeEmailCtaPath: '/study',
studyWelcomeEmailSignoff: 'Grace and peace,\nVerse by Verse with Nate',
studyDeletedEmailSubject: 'Your study account was deleted',
studyDeletedEmailBody: 'This confirms your study account and saved notes were deleted. If this was not you, please contact us immediately.',
studyDeletedEmailCtaLabel: 'Create a New Account',
studyDeletedEmailCtaPath: '/study/signup',
studyDeletedEmailSignoff: 'Verse by Verse with Nate',
studyReminderEmailSubjectPrefix: 'New lesson available:',
studyReminderEmailBody: 'A new lesson has been unlocked in your study track. Open it below to continue where you left off.',
studyReminderEmailCtaLabel: 'Open the Lesson',
studyReminderEmailSignoff: 'Grace and peace,\nVerse by Verse with Nate',
emailChangeSubject: 'Confirm your new email address',
emailChangeBody: 'Click the link below to confirm your new account email. If you did not request this change, ignore this message.',
emailChangeCtaLabel: 'Confirm Email Change',
headerFollowLabel: 'Follow on Spotify',
cookieBannerText: 'We use optional analytics cookies to measure visits and location trends for site improvement.',
customLinks: [],