RSVP System Logic
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The RSVP (Répondez S'il Vous Plaît) system is a core functional module of the Boda-Cris wedding invitation application. It provides a bi-directional interface for guest management: allowing invitees to confirm or decline attendance via a public-facing form, and enabling administrators to manage the guest list, view statistics, and communicate through automated messaging.
The system is built on a centralized state management architecture using React Context, which handles data persistence through localStorage. It encompasses the complete lifecycle of a guest entry, from initial registration and validation to administrative auditing and bulk communication via WhatsApp integration.
Sources: src/components/invitation/RSVPForm.jsx, src/context/GuestContext.jsx, src/components/admin/GuestList.jsx
System Architecture and Data Flow
The RSVP system follows a provider-consumer pattern. The GuestProvider acts as the single source of truth, managing the guests array and providing methods for CRUD operations.
The diagram shows the flow of guest data from submission through the central context to persistent storage and administrative views.
Sources: src/context/GuestContext.jsx:6-60, src/components/invitation/RSVPForm.jsx:8-15
Data Models
Guest Entity
The guest object is the primary data structure, containing identification, attendance status, and preference data.
| Field | Type | Description |
|---|---|---|
id | String | Unique identifier (generated via Date.now().toString()) |
name | String | Full name of the guest |
email | String | Contact email address (optional) |
phone | String | Contact phone number (used for WhatsApp integration) |
attendance | String | Status: 'confirmed', 'pending', or 'declined' |
adults | Number | Count of adult attendees (minimum 1 if confirmed) |
children | Number | Count of child attendees |
dietaryRestrictions | String | Food allergies or preferences |
message | String | Personal note to the couple |
createdAt | String | ISO timestamp of registration |
Sources: src/context/GuestContext.jsx:21-25, src/components/invitation/RSVPForm.jsx:13-22, src/data/defaultContent.js:84-95
Core Logic Modules
1. Guest Registration and Validation
The RSVPForm component handles user input and ensures data integrity before updating the global state.
- Validation Rules: A guest must provide a name. If the status is 'confirmed', the number of adults must be at least 1.
- State Transition: Upon successful submission,
isSubmittedtriggers a success UI state, and the form resets.
2. Administrative Management
Administrators interact with the system via the GuestList and GuestFormModal components. This module supports:
- Filtering: Viewing guests by status (all, confirmed, pending, declined).
- Search: Real-time filtering by name, email, or phone number.
- Import/Export: Bulk handling of guest data via CSV or JSON files.
Sources: src/components/admin/GuestList.jsx:28-32, src/components/admin/GuestImportExport.jsx:42-75
3. Analytics and Statistics
The getStats function in GuestContext calculates real-time metrics used for the admin dashboard.
const getStats = () => {
const confirmed = guests.filter(g => g.attendance === 'confirmed')
const totalAdults = confirmed.reduce((sum, g) => sum + (g.adults || 0), 0)
const totalChildren = confirmed.reduce((sum, g) => sum + (g.children || 0), 0)
return {
total: guests.length,
confirmed: confirmed.length,
totalAttendees: totalAdults + totalChildren
}
}
Sources: src/context/GuestContext.jsx:38-52
Communication Logic (WhatsApp Integration)
The system includes a specialized WhatsAppBroadcast module that leverages guest data to generate personalized messages.
Message Template Variable Replacement
The system replaces double-brace placeholders (e.g., {{nombre}}) with dynamic data from the guest record or event content.
| Variable | Source Data |
|---|---|
{{nombre}} | guest.name |
{{adultos}} | guest.adults |
{{estado}} | guest.attendance |
{{link}} | window.location.origin |
Conditional Logic in Messages
Templates support conditional blocks (e.g., {{#if adultos}}...{{/if}}) to modify message content based on guest attributes. For example, children-related text is only included if guest.children > 0.
Sources: src/components/admin/WhatsAppBroadcast.jsx:153-188
Conclusion
The RSVP System Logic provides a robust framework for managing wedding invitations. By centralizing guest data in GuestContext and persisting it to localStorage, the application ensures that confirmation data is immediately available for administrative review, statistical analysis, and coordinated communication efforts. This integrated approach minimizes manual tracking and provides a seamless experience for both the hosts and their guests.