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
This commit is contained in:
Ryderjj89
2025-05-26 18:24:59 -04:00
parent 2ee244a354
commit a9025f8778
2 changed files with 24 additions and 3 deletions

View File

@@ -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

View File

@@ -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