📝 Your Active Prayers
${activePrayers.map(prayer => `🎉 All Caught Up!
You have no active prayers. Great job staying on top of your prayer life!
import { NextRequest, NextResponse } from 'next/server'; import { admin } from '@/lib/firebase-admin'; import nodemailer from 'nodemailer'; function generatePrayerEmailHTML(message: string, subject: string) { // Parse the message to extract prayer details and stats const lines = message.split('\n'); const stats = { total: 0, active: 0, answered: 0, archived: 0 }; const activePrayers = []; const answeredPrayers = []; let inActiveSection = false; let inAnsweredSection = false; for (const line of lines) { if (line.includes('Total Prayers:')) { stats.total = parseInt(line.split(':')[1].trim()) || 0; } else if (line.includes('Active Prayers:')) { stats.active = parseInt(line.split(':')[1].trim()) || 0; } else if (line.includes('Answered Prayers:')) { stats.answered = parseInt(line.split(':')[1].trim()) || 0; } else if (line.includes('Archived Prayers:')) { stats.archived = parseInt(line.split(':')[1].trim()) || 0; } else if (line.includes('--- Your Active Prayers ---')) { inActiveSection = true; inAnsweredSection = false; } else if (line.includes('--- Recently Answered Prayers ---')) { inActiveSection = false; inAnsweredSection = true; } else if (inActiveSection && line.includes(' - ')) { const match = line.match(/(\d{4}-\d{2}-\d{2}) - (PRAYER|PRAISE): (.+)/); if (match) { activePrayers.push({ date: match[1], type: match[2].toLowerCase(), text: match[3] }); } } else if (inAnsweredSection && line.includes(' - ')) { const match = line.match(/(\d{4}-\d{2}-\d{2}) - (PRAYER|PRAISE): (.+)/); if (match) { answeredPrayers.push({ date: match[1], type: match[2].toLowerCase(), text: match[3] }); } } } const html = `
You have no active prayers. Great job staying on top of your prayer life!
"Pray without ceasing"— 1 Thessalonians 5:17