From a9025f87789d51ceec59174d41779f9f0c3696a2 Mon Sep 17 00:00:00 2001 From: Ryderjj89 Date: Mon, 26 May 2025 18:24:59 -0400 Subject: [PATCH] Add RSVP cutoff note to ICS calendar files - Updated generateICSContent function to accept optional rsvp_cutoff_date parameter - Added formatted RSVP cutoff note to calendar event descriptions with bold 'Note:' text - Backend now passes rsvp_cutoff_date to ICS generation when creating calendar files - Calendar events now include helpful reminder about RSVP deadlines for attendees - Note displays formatted cutoff date with full weekday, date, time and timezone info --- backend/src/email.ts | 24 ++++++++++++++++++++++-- backend/src/index.ts | 3 ++- 2 files changed, 24 insertions(+), 3 deletions(-) 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