Guest Creation & Editing
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The Guest Creation & Editing system is a core administrative module of the Boda-Cris application, designed to manage the wedding attendee lifecycle. It provides administrators with the tools to manually add new guests, update existing guest information, and track attendance status in real-time. This system ensures that the wedding couple has an accurate count of attendees, including adults and children, as well as specific dietary requirements or personal messages from their guests.
The module is primarily accessible via the Admin Dashboard and integrates closely with the GuestContext for state management and local storage persistence. It supports individual entry via modal forms, bulk management through import/export utilities, and detailed viewing of specific guest profiles.
Sources: src/components/admin/GuestList.jsx, src/context/GuestContext.jsx:1-10, src/pages/AdminPage.jsx
Core Guest Data Model
The system utilizes a consistent JSON structure for guest objects throughout the creation and editing workflows. Every guest is assigned a unique identifier and a creation timestamp upon entry.
| Field | Type | Description |
|---|---|---|
id | String | Unique identifier (generated using Date.now().toString()) |
name | String | Full name of the guest (Required) |
email | String | Contact email address |
phone | String | Contact phone number |
attendance | String | Status: confirmed, pending, or declined |
adults | Number | Count of adult attendees |
children | Number | Count of child attendees |
dietaryRestrictions | String | Specific food allergies or preferences |
message | String | Personal note or additional comments |
createdAt | ISO Date | Timestamp of when the guest was added |
Sources: src/context/GuestContext.jsx:16-20, src/components/admin/GuestFormModal.jsx:10-19, src/data/defaultContent.js:84-114
Component Architecture and Data Flow
The guest management architecture follows a centralized state pattern. The GuestContext acts as the single source of truth, while UI components like GuestFormModal and GuestList interact with it through custom hooks.
State Management Flow
The following diagram illustrates how a guest record is updated through the system components.
The GuestList component manages the visibility of modals and determines whether a "Save" action constitutes a new creation or an update to an existing record.
Sources: src/components/admin/GuestList.jsx:13-35, src/context/GuestContext.jsx:15-32
Manual Entry and Modification
GuestFormModal
The GuestFormModal is the primary interface for manual data entry. It supports two modes:
- Creation Mode: Initializes with empty values (defaulting to 1 adult and 'pending' status).
- Edit Mode: Pre-populates fields with existing guest data passed via the
guestprop.
The component includes internal validation logic to ensure that a name is provided and that email formats are correct before calling the onSave callback.
// Validation logic in GuestFormModal.jsx
const validate = () => {
const newErrors = {}
if (!formData.name.trim()) {
newErrors.name = 'El nombre es requerido'
}
if (formData.email && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(formData.email)) {
newErrors.email = 'Email inválido'
}
// ... check for negative numbers
setErrors(newErrors)
return Object.keys(newErrors).length === 0
}
Sources: src/components/admin/GuestFormModal.jsx:45-66
Detailed Viewing
The GuestDetailModal provides a read-only view of a guest's full profile, including their contact details, registration date, and specific notes. It also serves as a secondary entry point for editing or deleting the guest record.
Sources: src/components/admin/GuestDetailModal.jsx:11-30
Bulk Operations: Import & Export
The GuestImportExport component enables large-scale guest list modifications by processing CSV and JSON files.
Import Logic
When importing, the system performs "normalization" to map external data formats to the internal attendance states.
- CSV Parsing: Splitting lines and handling quoted strings.
- Normalization: Converting various affirmative strings (e.g., "Si", "Yes", "Confirmado") into the standard
confirmedvalue.
Conclusion
Guest Creation & Editing in Boda-Cris is a robust system that balances granular control with bulk efficiency. By leveraging a centralized context and specialized modal components, the application ensures data consistency across the administrative dashboard while providing a flexible interface for managing complex attendee data, from simple name entries to detailed dietary and contact information.
Sources: src/components/admin/GuestList.jsx, src/context/GuestContext.jsx