Refactor email templates to use plain text format and update sender addresses
- Simplified the magic link email format to plain text for better compatibility. - Updated the welcome email to use plain text and changed the sender address to match the domain. - Enhanced event registration email format to plain text, removing HTML styling for a cleaner approach.
This commit is contained in:
parent
8143631364
commit
c3c8b6bcd4
5 changed files with 132 additions and 626 deletions
35
server/api/admin/members/[id]/role.patch.js
Normal file
35
server/api/admin/members/[id]/role.patch.js
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
import Member from '../../../../models/member.js'
|
||||||
|
import { connectDB } from '../../../../utils/mongoose.js'
|
||||||
|
import { validateBody } from '../../../../utils/validateBody.js'
|
||||||
|
import { adminRoleUpdateSchema } from '../../../../utils/schemas.js'
|
||||||
|
|
||||||
|
export default defineEventHandler(async (event) => {
|
||||||
|
const admin = await requireAdmin(event)
|
||||||
|
await connectDB()
|
||||||
|
|
||||||
|
const { role } = await validateBody(event, adminRoleUpdateSchema)
|
||||||
|
const memberId = getRouterParam(event, 'id')
|
||||||
|
|
||||||
|
// Prevent self-demotion
|
||||||
|
if (admin._id.toString() === memberId && role !== 'admin') {
|
||||||
|
throw createError({
|
||||||
|
statusCode: 400,
|
||||||
|
statusMessage: 'You cannot remove your own admin role.'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const member = await Member.findByIdAndUpdate(
|
||||||
|
memberId,
|
||||||
|
{ role },
|
||||||
|
{ new: true }
|
||||||
|
)
|
||||||
|
|
||||||
|
if (!member) {
|
||||||
|
throw createError({
|
||||||
|
statusCode: 404,
|
||||||
|
statusMessage: 'Member not found.'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return { success: true, member }
|
||||||
|
})
|
||||||
|
|
@ -9,7 +9,6 @@ import { emailSchema } from "../../utils/schemas.js";
|
||||||
const resend = new Resend(process.env.RESEND_API_KEY);
|
const resend = new Resend(process.env.RESEND_API_KEY);
|
||||||
|
|
||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
// Connect to database
|
|
||||||
await connectDB();
|
await connectDB();
|
||||||
|
|
||||||
const { email } = await validateBody(event, emailSchema);
|
const { email } = await validateBody(event, emailSchema);
|
||||||
|
|
@ -19,14 +18,12 @@ export default defineEventHandler(async (event) => {
|
||||||
const member = await Member.findOne({ email });
|
const member = await Member.findOne({ email });
|
||||||
|
|
||||||
if (!member) {
|
if (!member) {
|
||||||
// Return same response shape to prevent enumeration
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: GENERIC_MESSAGE,
|
message: GENERIC_MESSAGE,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate magic link token (use runtime config for consistency with verify/requireAuth)
|
|
||||||
const config = useRuntimeConfig(event);
|
const config = useRuntimeConfig(event);
|
||||||
const token = jwt.sign(
|
const token = jwt.sign(
|
||||||
{ memberId: member._id },
|
{ memberId: member._id },
|
||||||
|
|
@ -34,33 +31,22 @@ export default defineEventHandler(async (event) => {
|
||||||
{ expiresIn: "15m" },
|
{ expiresIn: "15m" },
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get the base URL for the magic link
|
|
||||||
const headers = getHeaders(event);
|
const headers = getHeaders(event);
|
||||||
const baseUrl =
|
const baseUrl =
|
||||||
process.env.BASE_URL ||
|
process.env.BASE_URL ||
|
||||||
`${headers.host?.includes("localhost") ? "http" : "https"}://${headers.host}`;
|
`${headers.host?.includes("localhost") ? "http" : "https"}://${headers.host}`;
|
||||||
|
|
||||||
// Send magic link via Resend
|
|
||||||
try {
|
try {
|
||||||
await resend.emails.send({
|
await resend.emails.send({
|
||||||
from: "Ghost Guild <ghostguild@babyghosts.org>",
|
from: "Ghost Guild <ghostguild@babyghosts.org>",
|
||||||
to: email,
|
to: email,
|
||||||
subject: "Your Ghost Guild login link",
|
subject: "Your Ghost Guild login link",
|
||||||
html: `
|
text: `Hi,
|
||||||
<div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto;">
|
|
||||||
<h2 style="color: #2563eb;">Welcome back to Ghost Guild!</h2>
|
Sign in to Ghost Guild:
|
||||||
<p>Click the button below to sign in to your account:</p>
|
${baseUrl}/api/auth/verify?token=${token}
|
||||||
<div style="text-align: center; margin: 30px 0;">
|
|
||||||
<a href="${baseUrl}/api/auth/verify?token=${token}"
|
This link expires in 15 minutes. If you didn't request it, ignore this email.`,
|
||||||
style="background-color: #2563eb; color: white; padding: 12px 24px; text-decoration: none; border-radius: 6px; display: inline-block;">
|
|
||||||
Sign In to Ghost Guild
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<p style="color: #666; font-size: 14px;">
|
|
||||||
This link will expire in 15 minutes for security. If you didn't request this login link, you can safely ignore this email.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
`,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,14 @@
|
||||||
// server/emails/welcome.js
|
// server/emails/welcome.js
|
||||||
export const welcomeEmail = (member) => ({
|
export const welcomeEmail = (member) => ({
|
||||||
from: 'Ghost Guild <welcome@ghostguild.org>',
|
from: 'Ghost Guild <welcome@babyghosts.org>',
|
||||||
to: member.email,
|
to: member.email,
|
||||||
subject: 'Welcome to Ghost Guild! 👻',
|
subject: 'Welcome to Ghost Guild',
|
||||||
html: `
|
text: `Hi ${member.name},
|
||||||
<div style="font-family: sans-serif; max-width: 600px; margin: 0 auto;">
|
|
||||||
<h1>Welcome to the community, ${member.name}!</h1>
|
Welcome to the ${member.circle} circle.
|
||||||
|
|
||||||
<p>You've joined the <strong>${member.circle} circle</strong>
|
Next steps:
|
||||||
with a ${member.contributionTier}/month contribution.</p>
|
1. Watch for your Slack invite (within 24 hours)
|
||||||
|
2. Explore the resource library: https://ghostguild.org/members/resources
|
||||||
<h2>Your next steps:</h2>
|
3. Introduce yourself in #introductions`
|
||||||
<ol>
|
})
|
||||||
<li>Watch for your Slack invite (within 24 hours)</li>
|
|
||||||
<li>Explore the <a href="https://ghostguild.org/members/resources">resource library</a></li>
|
|
||||||
<li>Introduce yourself in #introductions</li>
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
<p>Thank you for being part of our solidarity economy!</p>
|
|
||||||
|
|
||||||
<hr style="margin: 30px 0; border: 1px solid #eee;">
|
|
||||||
|
|
||||||
<p style="color: #666; font-size: 14px;">
|
|
||||||
Questions? Reply to this email or reach out in Slack.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
`
|
|
||||||
})
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { Resend } from "resend";
|
import { Resend } from "resend";
|
||||||
import { escapeHtml } from "./escapeHtml.js";
|
|
||||||
|
|
||||||
const resend = new Resend(process.env.RESEND_API_KEY);
|
const resend = new Resend(process.env.RESEND_API_KEY);
|
||||||
|
|
||||||
|
|
@ -30,166 +29,44 @@ export async function sendEventRegistrationEmail(registration, eventData) {
|
||||||
return `${timeFormat.format(start)} - ${timeFormat.format(end)}`;
|
return `${timeFormat.format(start)} - ${timeFormat.format(end)}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const baseUrl = process.env.BASE_URL || "https://ghostguild.org";
|
||||||
|
const eventUrl = `${baseUrl}/events/${eventData.slug || eventData._id}`;
|
||||||
|
|
||||||
|
let ticketSection = "";
|
||||||
|
if (
|
||||||
|
registration.ticketType &&
|
||||||
|
registration.ticketType !== "guest" &&
|
||||||
|
registration.amountPaid > 0
|
||||||
|
) {
|
||||||
|
ticketSection = `\nTicket: ${registration.ticketType === "member" ? "Member Ticket" : "Public Ticket"}
|
||||||
|
Paid: $${registration.amountPaid.toFixed(2)} CAD`;
|
||||||
|
if (registration.paymentId) {
|
||||||
|
ticketSection += `\nTransaction: ${registration.paymentId}`;
|
||||||
|
}
|
||||||
|
ticketSection += "\n";
|
||||||
|
} else if (
|
||||||
|
registration.ticketType === "member" &&
|
||||||
|
registration.amountPaid === 0
|
||||||
|
) {
|
||||||
|
ticketSection = "\nThis event is free for Ghost Guild members.\n";
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data, error } = await resend.emails.send({
|
const { data, error } = await resend.emails.send({
|
||||||
from: "Ghost Guild <events@babyghosts.org>",
|
from: "Ghost Guild <events@babyghosts.org>",
|
||||||
to: [registration.email],
|
to: [registration.email],
|
||||||
subject: `You're registered for ${escapeHtml(eventData.title)}`,
|
subject: `You're registered for ${eventData.title}`,
|
||||||
html: `
|
text: `Hi ${registration.name},
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
||||||
line-height: 1.6;
|
|
||||||
color: #333;
|
|
||||||
max-width: 600px;
|
|
||||||
margin: 0 auto;
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
.header {
|
|
||||||
background-color: #1a1a2e;
|
|
||||||
color: #fff;
|
|
||||||
padding: 30px;
|
|
||||||
text-align: center;
|
|
||||||
border-radius: 8px 8px 0 0;
|
|
||||||
}
|
|
||||||
.content {
|
|
||||||
background-color: #f9f9f9;
|
|
||||||
padding: 30px;
|
|
||||||
border-radius: 0 0 8px 8px;
|
|
||||||
}
|
|
||||||
.event-details {
|
|
||||||
background-color: #fff;
|
|
||||||
padding: 20px;
|
|
||||||
border-radius: 8px;
|
|
||||||
margin: 20px 0;
|
|
||||||
border-left: 4px solid #3b82f6;
|
|
||||||
}
|
|
||||||
.detail-row {
|
|
||||||
margin: 10px 0;
|
|
||||||
}
|
|
||||||
.label {
|
|
||||||
font-weight: 600;
|
|
||||||
color: #666;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
.value {
|
|
||||||
color: #1a1a2e;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
.button {
|
|
||||||
display: inline-block;
|
|
||||||
background-color: #3b82f6;
|
|
||||||
color: #fff;
|
|
||||||
padding: 12px 30px;
|
|
||||||
text-decoration: none;
|
|
||||||
border-radius: 6px;
|
|
||||||
margin: 20px 0;
|
|
||||||
}
|
|
||||||
.footer {
|
|
||||||
text-align: center;
|
|
||||||
margin-top: 30px;
|
|
||||||
padding-top: 20px;
|
|
||||||
border-top: 1px solid #ddd;
|
|
||||||
color: #666;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="header">
|
|
||||||
<h1 style="margin: 0;">You're Registered! 🎉</h1>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="content">
|
You're registered for ${eventData.title}.
|
||||||
<p>Hi ${escapeHtml(registration.name)},</p>
|
|
||||||
|
|
||||||
<p>Thank you for registering for <strong>${escapeHtml(eventData.title)}</strong>!</p>
|
Date: ${formatDate(eventData.startDate)}
|
||||||
|
Time: ${formatTime(eventData.startDate, eventData.endDate)}
|
||||||
|
Location: ${eventData.location}
|
||||||
|
${eventData.description ? `\n${eventData.description}\n` : ""}${ticketSection}
|
||||||
|
View event: ${eventUrl}
|
||||||
|
|
||||||
<div class="event-details">
|
To cancel, visit the event page and click "Cancel Registration."`,
|
||||||
<div class="detail-row">
|
|
||||||
<div class="label">Date</div>
|
|
||||||
<div class="value">${formatDate(eventData.startDate)}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="detail-row">
|
|
||||||
<div class="label">Time</div>
|
|
||||||
<div class="value">${formatTime(eventData.startDate, eventData.endDate)}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="detail-row">
|
|
||||||
<div class="label">Location</div>
|
|
||||||
<div class="value">${escapeHtml(eventData.location)}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
${eventData.description ? `<p>${escapeHtml(eventData.description)}</p>` : ""}
|
|
||||||
|
|
||||||
${
|
|
||||||
registration.ticketType &&
|
|
||||||
registration.ticketType !== "guest" &&
|
|
||||||
registration.amountPaid > 0
|
|
||||||
? `
|
|
||||||
<div class="event-details" style="margin-top: 20px;">
|
|
||||||
<h3 style="margin-top: 0; color: #1a1a2e;">Ticket Information</h3>
|
|
||||||
<div class="detail-row">
|
|
||||||
<div class="label">Ticket Type</div>
|
|
||||||
<div class="value">${registration.ticketType === "member" ? "Member Ticket" : "Public Ticket"}</div>
|
|
||||||
</div>
|
|
||||||
<div class="detail-row">
|
|
||||||
<div class="label">Amount Paid</div>
|
|
||||||
<div class="value">$${registration.amountPaid.toFixed(2)} CAD</div>
|
|
||||||
</div>
|
|
||||||
${
|
|
||||||
registration.paymentId
|
|
||||||
? `
|
|
||||||
<div class="detail-row">
|
|
||||||
<div class="label">Transaction ID</div>
|
|
||||||
<div class="value" style="font-size: 12px; font-family: monospace;">${escapeHtml(registration.paymentId)}</div>
|
|
||||||
</div>
|
|
||||||
`
|
|
||||||
: ""
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
`
|
|
||||||
: registration.ticketType === "member" &&
|
|
||||||
registration.amountPaid === 0
|
|
||||||
? `
|
|
||||||
<div style="background-color: #e0e7ff; border-left: 4px solid #6366f1; padding: 15px; border-radius: 4px; margin: 20px 0;">
|
|
||||||
<p style="margin: 0; color: #4338ca;">
|
|
||||||
<strong>✨ Member Benefit:</strong> This event is free for Ghost Guild members!
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
`
|
|
||||||
: ""
|
|
||||||
}
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<a href="${process.env.BASE_URL || "https://ghostguild.org"}/events/${eventData.slug || eventData._id}" class="button">
|
|
||||||
View Event Details
|
|
||||||
</a>
|
|
||||||
</center>
|
|
||||||
|
|
||||||
<p style="margin-top: 30px; font-size: 14px; color: #666;">
|
|
||||||
<strong>Need to cancel?</strong><br>
|
|
||||||
Visit the event page and click "Cancel Registration" to remove yourself from the attendee list.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="footer">
|
|
||||||
<p>Ghost Guild</p>
|
|
||||||
<p>
|
|
||||||
Questions? Email us at
|
|
||||||
<a href="mailto:events@babyghosts.org">events@babyghosts.org</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
`,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|
@ -208,86 +85,19 @@ export async function sendEventRegistrationEmail(registration, eventData) {
|
||||||
* Send event cancellation confirmation email
|
* Send event cancellation confirmation email
|
||||||
*/
|
*/
|
||||||
export async function sendEventCancellationEmail(registration, eventData) {
|
export async function sendEventCancellationEmail(registration, eventData) {
|
||||||
|
const baseUrl = process.env.BASE_URL || "https://ghostguild.org";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data, error } = await resend.emails.send({
|
const { data, error } = await resend.emails.send({
|
||||||
from: "Ghost Guild <events@ghostguild.org>",
|
from: "Ghost Guild <events@babyghosts.org>",
|
||||||
to: [registration.email],
|
to: [registration.email],
|
||||||
subject: `Registration cancelled: ${escapeHtml(eventData.title)}`,
|
subject: `Registration cancelled: ${eventData.title}`,
|
||||||
html: `
|
text: `Hi ${registration.name},
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
||||||
line-height: 1.6;
|
|
||||||
color: #333;
|
|
||||||
max-width: 600px;
|
|
||||||
margin: 0 auto;
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
.header {
|
|
||||||
background-color: #1a1a2e;
|
|
||||||
color: #fff;
|
|
||||||
padding: 30px;
|
|
||||||
text-align: center;
|
|
||||||
border-radius: 8px 8px 0 0;
|
|
||||||
}
|
|
||||||
.content {
|
|
||||||
background-color: #f9f9f9;
|
|
||||||
padding: 30px;
|
|
||||||
border-radius: 0 0 8px 8px;
|
|
||||||
}
|
|
||||||
.button {
|
|
||||||
display: inline-block;
|
|
||||||
background-color: #3b82f6;
|
|
||||||
color: #fff;
|
|
||||||
padding: 12px 30px;
|
|
||||||
text-decoration: none;
|
|
||||||
border-radius: 6px;
|
|
||||||
margin: 20px 0;
|
|
||||||
}
|
|
||||||
.footer {
|
|
||||||
text-align: center;
|
|
||||||
margin-top: 30px;
|
|
||||||
padding-top: 20px;
|
|
||||||
border-top: 1px solid #ddd;
|
|
||||||
color: #666;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="header">
|
|
||||||
<h1 style="margin: 0;">Registration Cancelled</h1>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="content">
|
Your registration for ${eventData.title} has been cancelled.
|
||||||
<p>Hi ${escapeHtml(registration.name)},</p>
|
|
||||||
|
|
||||||
<p>Your registration for <strong>${escapeHtml(eventData.title)}</strong> has been cancelled.</p>
|
You can register again if your plans change:
|
||||||
|
${baseUrl}/events`,
|
||||||
<p>We're sorry you can't make it. You can always register again if your plans change.</p>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<a href="${process.env.BASE_URL || "https://ghostguild.org"}/events" class="button">
|
|
||||||
Browse Other Events
|
|
||||||
</a>
|
|
||||||
</center>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="footer">
|
|
||||||
<p>Ghost Guild</p>
|
|
||||||
<p>
|
|
||||||
Questions? Email us at
|
|
||||||
<a href="mailto:events@babyghosts.org">events@babyghosts.org</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
`,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|
@ -329,144 +139,25 @@ export async function sendWaitlistNotificationEmail(waitlistEntry, eventData) {
|
||||||
return `${timeFormat.format(start)} - ${timeFormat.format(end)}`;
|
return `${timeFormat.format(start)} - ${timeFormat.format(end)}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const baseUrl = process.env.BASE_URL || "https://ghostguild.org";
|
||||||
|
const eventUrl = `${baseUrl}/events/${eventData.slug || eventData._id}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data, error } = await resend.emails.send({
|
const { data, error } = await resend.emails.send({
|
||||||
from: "Ghost Guild <events@ghostguild.org>",
|
from: "Ghost Guild <events@babyghosts.org>",
|
||||||
to: [waitlistEntry.email],
|
to: [waitlistEntry.email],
|
||||||
subject: `A spot opened up for ${escapeHtml(eventData.title)}!`,
|
subject: `A spot opened up for ${eventData.title}`,
|
||||||
html: `
|
text: `Hi ${waitlistEntry.name},
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
||||||
line-height: 1.6;
|
|
||||||
color: #333;
|
|
||||||
max-width: 600px;
|
|
||||||
margin: 0 auto;
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
.header {
|
|
||||||
background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
|
|
||||||
color: #fff;
|
|
||||||
padding: 30px;
|
|
||||||
text-align: center;
|
|
||||||
border-radius: 8px 8px 0 0;
|
|
||||||
}
|
|
||||||
.content {
|
|
||||||
background-color: #f9f9f9;
|
|
||||||
padding: 30px;
|
|
||||||
border-radius: 0 0 8px 8px;
|
|
||||||
}
|
|
||||||
.event-details {
|
|
||||||
background-color: #fff;
|
|
||||||
padding: 20px;
|
|
||||||
border-radius: 8px;
|
|
||||||
margin: 20px 0;
|
|
||||||
border-left: 4px solid #f59e0b;
|
|
||||||
}
|
|
||||||
.detail-row {
|
|
||||||
margin: 10px 0;
|
|
||||||
}
|
|
||||||
.label {
|
|
||||||
font-weight: 600;
|
|
||||||
color: #666;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
.value {
|
|
||||||
color: #1a1a2e;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
.button {
|
|
||||||
display: inline-block;
|
|
||||||
background-color: #f59e0b;
|
|
||||||
color: #fff;
|
|
||||||
padding: 14px 32px;
|
|
||||||
text-decoration: none;
|
|
||||||
border-radius: 6px;
|
|
||||||
margin: 20px 0;
|
|
||||||
font-weight: 600;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
.urgent {
|
|
||||||
background-color: #fef3c7;
|
|
||||||
border: 2px solid #f59e0b;
|
|
||||||
padding: 15px;
|
|
||||||
border-radius: 8px;
|
|
||||||
margin: 20px 0;
|
|
||||||
}
|
|
||||||
.footer {
|
|
||||||
text-align: center;
|
|
||||||
margin-top: 30px;
|
|
||||||
padding-top: 20px;
|
|
||||||
border-top: 1px solid #ddd;
|
|
||||||
color: #666;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="header">
|
|
||||||
<h1 style="margin: 0;">A Spot Just Opened Up! 🎉</h1>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="content">
|
A spot opened up for ${eventData.title}.
|
||||||
<p>Hi ${escapeHtml(waitlistEntry.name)},</p>
|
|
||||||
|
|
||||||
<p>Great news! A spot has become available for <strong>${escapeHtml(eventData.title)}</strong>, and you're on the waitlist.</p>
|
Date: ${formatDate(eventData.startDate)}
|
||||||
|
Time: ${formatTime(eventData.startDate, eventData.endDate)}
|
||||||
|
Location: ${eventData.location}
|
||||||
|
|
||||||
<div class="urgent">
|
Register now: ${eventUrl}
|
||||||
<p style="margin: 0; font-weight: 600; color: #92400e;">
|
|
||||||
⏰ Act fast! Spots are filled on a first-come, first-served basis.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="event-details">
|
If you can no longer attend, ignore this email and the spot goes to the next person.`,
|
||||||
<div class="detail-row">
|
|
||||||
<div class="label">Event</div>
|
|
||||||
<div class="value">${escapeHtml(eventData.title)}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="detail-row">
|
|
||||||
<div class="label">Date</div>
|
|
||||||
<div class="value">${formatDate(eventData.startDate)}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="detail-row">
|
|
||||||
<div class="label">Time</div>
|
|
||||||
<div class="value">${formatTime(eventData.startDate, eventData.endDate)}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="detail-row">
|
|
||||||
<div class="label">Location</div>
|
|
||||||
<div class="value">${escapeHtml(eventData.location)}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<a href="${process.env.BASE_URL || "https://ghostguild.org"}/events/${eventData.slug || eventData._id}" class="button">
|
|
||||||
Register Now →
|
|
||||||
</a>
|
|
||||||
</center>
|
|
||||||
|
|
||||||
<p style="margin-top: 30px; font-size: 14px; color: #666;">
|
|
||||||
If you can no longer attend, no worries! Just ignore this email and the spot will go to the next person on the waitlist.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="footer">
|
|
||||||
<p>Ghost Guild</p>
|
|
||||||
<p>
|
|
||||||
Questions? Email us at
|
|
||||||
<a href="mailto:events@ghostguild.org">events@ghostguild.org</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
`,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|
@ -518,234 +209,39 @@ export async function sendSeriesPassConfirmation(options) {
|
||||||
}).format(price);
|
}).format(price);
|
||||||
};
|
};
|
||||||
|
|
||||||
const seriesTypeLabels = {
|
const freeMemberLine =
|
||||||
workshop_series: "Workshop Series",
|
ticket.isFree && ticket.type === "member"
|
||||||
recurring_meetup: "Recurring Meetup",
|
? "\nThis series pass is free for Ghost Guild members.\n"
|
||||||
multi_day: "Multi-Day Event",
|
: "";
|
||||||
course: "Course",
|
|
||||||
tournament: "Tournament",
|
const eventList = events
|
||||||
};
|
.map(
|
||||||
|
(evt, index) =>
|
||||||
|
` ${index + 1}. ${evt.title}
|
||||||
|
${formatDate(evt.startDate)}
|
||||||
|
${formatTime(evt.startDate, evt.endDate)}
|
||||||
|
${evt.location}`,
|
||||||
|
)
|
||||||
|
.join("\n\n");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data, error } = await resend.emails.send({
|
const { data, error } = await resend.emails.send({
|
||||||
from: "Ghost Guild <events@babyghosts.org>",
|
from: "Ghost Guild <events@babyghosts.org>",
|
||||||
to: [to],
|
to: [to],
|
||||||
subject: `Your Series Pass for ${escapeHtml(series.title)}`,
|
subject: `Your series pass for ${series.title}`,
|
||||||
html: `
|
text: `Hi ${name},
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
||||||
line-height: 1.6;
|
|
||||||
color: #333;
|
|
||||||
max-width: 600px;
|
|
||||||
margin: 0 auto;
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
.header {
|
|
||||||
background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
|
|
||||||
color: #fff;
|
|
||||||
padding: 30px;
|
|
||||||
text-align: center;
|
|
||||||
border-radius: 8px 8px 0 0;
|
|
||||||
}
|
|
||||||
.content {
|
|
||||||
background-color: #f9f9f9;
|
|
||||||
padding: 30px;
|
|
||||||
border-radius: 0 0 8px 8px;
|
|
||||||
}
|
|
||||||
.pass-details {
|
|
||||||
background-color: #fff;
|
|
||||||
padding: 20px;
|
|
||||||
border-radius: 8px;
|
|
||||||
margin: 20px 0;
|
|
||||||
border-left: 4px solid #7c3aed;
|
|
||||||
}
|
|
||||||
.event-list {
|
|
||||||
background-color: #fff;
|
|
||||||
padding: 20px;
|
|
||||||
border-radius: 8px;
|
|
||||||
margin: 20px 0;
|
|
||||||
}
|
|
||||||
.event-item {
|
|
||||||
padding: 15px;
|
|
||||||
margin: 10px 0;
|
|
||||||
background-color: #f9f9f9;
|
|
||||||
border-radius: 6px;
|
|
||||||
border-left: 3px solid #7c3aed;
|
|
||||||
}
|
|
||||||
.detail-row {
|
|
||||||
margin: 10px 0;
|
|
||||||
}
|
|
||||||
.label {
|
|
||||||
font-weight: 600;
|
|
||||||
color: #666;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
.value {
|
|
||||||
color: #1a1a2e;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
.member-benefit {
|
|
||||||
background-color: #dcfce7;
|
|
||||||
border: 2px solid #86efac;
|
|
||||||
padding: 15px;
|
|
||||||
border-radius: 8px;
|
|
||||||
margin: 20px 0;
|
|
||||||
}
|
|
||||||
.footer {
|
|
||||||
text-align: center;
|
|
||||||
padding: 20px;
|
|
||||||
color: #666;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
.button {
|
|
||||||
display: inline-block;
|
|
||||||
background-color: #7c3aed;
|
|
||||||
color: #fff;
|
|
||||||
padding: 12px 24px;
|
|
||||||
text-decoration: none;
|
|
||||||
border-radius: 6px;
|
|
||||||
margin: 10px 0;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="header">
|
|
||||||
<h1 style="margin: 0; font-size: 28px;">🎫 Your Series Pass is Ready!</h1>
|
|
||||||
<p style="margin: 10px 0 0 0; opacity: 0.9;">You're registered for all events</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="content">
|
Your series pass for ${series.title} is confirmed. You're registered for all ${events.length} events.
|
||||||
<p style="font-size: 18px; margin-bottom: 10px;">Hi ${escapeHtml(name)},</p>
|
${freeMemberLine}
|
||||||
|
Pass details:
|
||||||
|
Series: ${series.title}
|
||||||
|
Type: ${ticket.type === "member" ? "Member Pass" : "Public Pass"}
|
||||||
|
Paid: ${formatPrice(ticket.price, ticket.currency)}${paymentId ? `\n Transaction: ${paymentId}` : ""}
|
||||||
|
Events: ${events.length}
|
||||||
|
|
||||||
<p>
|
Your events:
|
||||||
Great news! Your series pass for <strong>${escapeHtml(series.title)}</strong> is confirmed.
|
|
||||||
You're now registered for all ${events.length} events in this ${seriesTypeLabels[series.type] || "series"}.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
${
|
${eventList}`,
|
||||||
ticket.isFree && ticket.type === "member"
|
|
||||||
? `
|
|
||||||
<div class="member-benefit">
|
|
||||||
<p style="margin: 0; font-weight: 600; color: #166534;">
|
|
||||||
✨ Member Benefit
|
|
||||||
</p>
|
|
||||||
<p style="margin: 5px 0 0 0; color: #166534;">
|
|
||||||
This series pass is free for Ghost Guild members. Thank you for being part of our community!
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
`
|
|
||||||
: ""
|
|
||||||
}
|
|
||||||
|
|
||||||
<div class="pass-details">
|
|
||||||
<h2 style="margin: 0 0 15px 0; color: #7c3aed; font-size: 20px;">Series Pass Details</h2>
|
|
||||||
|
|
||||||
<div class="detail-row">
|
|
||||||
<div class="label">Series</div>
|
|
||||||
<div class="value">${escapeHtml(series.title)}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
${
|
|
||||||
series.description
|
|
||||||
? `
|
|
||||||
<div class="detail-row">
|
|
||||||
<div class="label">About</div>
|
|
||||||
<div class="value">${escapeHtml(series.description)}</div>
|
|
||||||
</div>
|
|
||||||
`
|
|
||||||
: ""
|
|
||||||
}
|
|
||||||
|
|
||||||
<div class="detail-row">
|
|
||||||
<div class="label">Pass Type</div>
|
|
||||||
<div class="value">${ticket.type === "member" ? "Member Pass" : "Public Pass"}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="detail-row">
|
|
||||||
<div class="label">Amount Paid</div>
|
|
||||||
<div class="value">${formatPrice(ticket.price, ticket.currency)}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
${
|
|
||||||
paymentId
|
|
||||||
? `
|
|
||||||
<div class="detail-row">
|
|
||||||
<div class="label">Transaction ID</div>
|
|
||||||
<div class="value" style="font-family: monospace; font-size: 14px;">${escapeHtml(paymentId)}</div>
|
|
||||||
</div>
|
|
||||||
`
|
|
||||||
: ""
|
|
||||||
}
|
|
||||||
|
|
||||||
<div class="detail-row">
|
|
||||||
<div class="label">Total Events</div>
|
|
||||||
<div class="value">${events.length} events included</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="event-list">
|
|
||||||
<h3 style="margin: 0 0 15px 0; color: #1a1a2e; font-size: 18px;">Your Event Schedule</h3>
|
|
||||||
<p style="color: #666; font-size: 14px; margin-bottom: 15px;">
|
|
||||||
You're automatically registered for all of these events:
|
|
||||||
</p>
|
|
||||||
|
|
||||||
${events
|
|
||||||
.map(
|
|
||||||
(event, index) => `
|
|
||||||
<div class="event-item">
|
|
||||||
<div style="font-weight: 600; color: #7c3aed; margin-bottom: 5px;">
|
|
||||||
Event ${index + 1}: ${escapeHtml(event.title)}
|
|
||||||
</div>
|
|
||||||
<div style="font-size: 14px; color: #666; margin: 5px 0;">
|
|
||||||
📅 ${formatDate(event.startDate)}
|
|
||||||
</div>
|
|
||||||
<div style="font-size: 14px; color: #666; margin: 5px 0;">
|
|
||||||
🕐 ${formatTime(event.startDate, event.endDate)}
|
|
||||||
</div>
|
|
||||||
<div style="font-size: 14px; color: #666; margin: 5px 0;">
|
|
||||||
📍 ${escapeHtml(event.location)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`,
|
|
||||||
)
|
|
||||||
.join("")}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="text-align: center; margin: 30px 0;">
|
|
||||||
<a href="https://ghostguild.org/dashboard" class="button">
|
|
||||||
View in Dashboard
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="background-color: #fff; padding: 20px; border-radius: 8px; border: 1px solid #e5e7eb;">
|
|
||||||
<h3 style="margin: 0 0 10px 0; font-size: 16px;">What's Next?</h3>
|
|
||||||
<ul style="margin: 10px 0; padding-left: 20px;">
|
|
||||||
<li>Mark these dates in your calendar</li>
|
|
||||||
<li>You'll receive individual reminders before each event</li>
|
|
||||||
<li>Event links and materials will be shared closer to each date</li>
|
|
||||||
<li>Join the conversation in our Slack community</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="footer">
|
|
||||||
<p style="margin: 10px 0;">
|
|
||||||
Questions? Email us at
|
|
||||||
<a href="mailto:events@babyghosts.org">events@babyghosts.org</a>
|
|
||||||
</p>
|
|
||||||
<p style="margin: 10px 0; color: #999; font-size: 12px;">
|
|
||||||
Ghost Guild • Building solidarity economies in gaming
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
`,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|
|
||||||
|
|
@ -326,3 +326,7 @@ export const adminMemberCreateSchema = z.object({
|
||||||
circle: z.enum(['community', 'founder', 'practitioner']),
|
circle: z.enum(['community', 'founder', 'practitioner']),
|
||||||
contributionTier: z.enum(['0', '5', '15', '30', '50'])
|
contributionTier: z.enum(['0', '5', '15', '30', '50'])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const adminRoleUpdateSchema = z.object({
|
||||||
|
role: z.enum(['admin', 'member'])
|
||||||
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue