diff --git a/backend/src/email.ts b/backend/src/email.ts index a48d977..1e82c1f 100644 --- a/backend/src/email.ts +++ b/backend/src/email.ts @@ -7,8 +7,9 @@ export function generateICSContent(eventData: { location: string; date: string; // ISO date string slug: string; + rsvp_cutoff_date?: string; // Optional RSVP cutoff date }): string { - const { title, description, location, date, slug } = eventData; + const { title, description, location, date, slug, rsvp_cutoff_date } = eventData; // Convert date to ICS format (YYYYMMDDTHHMMSSZ) const eventDate = new Date(date); @@ -24,8 +25,27 @@ export function generateICSContent(eventData: { // Current timestamp for DTSTAMP const now = new Date().toISOString().replace(/[-:]/g, '').replace(/\.\d{3}/, ''); + // Build description with RSVP cutoff note + let fullDescription = description || ''; + + if (rsvp_cutoff_date) { + const cutoffDate = new Date(rsvp_cutoff_date); + const formattedCutoff = cutoffDate.toLocaleDateString('en-US', { + weekday: 'long', + year: 'numeric', + month: 'long', + day: 'numeric', + hour: 'numeric', + minute: '2-digit', + timeZoneName: 'short' + }); + + const rsvpNote = `\\n\\n**Note:** The RSVP cut-off for this event is ${formattedCutoff}. Make sure you get your reservation in before then!`; + fullDescription += rsvpNote; + } + // Clean description for ICS format (remove HTML, escape special chars) - const cleanDescription = description + const cleanDescription = fullDescription .replace(/<[^>]*>/g, '') // Remove HTML tags .replace(/\n/g, '\\n') // Escape newlines .replace(/,/g, '\\,') // Escape commas diff --git a/backend/src/index.ts b/backend/src/index.ts index c0ba4d0..19ed3f7 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -1065,7 +1065,8 @@ app.get('/api/events/:slug/calendar.ics', async (req: Request, res: Response) => description: event.description || '', location: event.location || '', date: event.date, - slug: event.slug + slug: event.slug, + rsvp_cutoff_date: event.rsvp_cutoff_date }); // Set appropriate headers for ICS file download