Add guest support for events and RSVP system
All checks were successful
Build And Push Image / docker (push) Successful in 3m52s
All checks were successful
Build And Push Image / docker (push) Successful in 3m52s
- Add guest settings to event creation with configurable max guests per person - Implement guest selection in RSVP form when guests are permitted - Update API endpoints to handle guest count in RSVP requests - Extend event and RSVP types to support guest-related fields
This commit is contained in:
@@ -85,6 +85,38 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Validate guest count if event allows guests
|
||||
const extraGuests = parseInt((body as any).extra_guests || '0');
|
||||
if (extraGuests > 0) {
|
||||
if (eventDetails.guests_permitted !== 'true') {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: 'This event does not allow guests'
|
||||
});
|
||||
}
|
||||
|
||||
const maxGuestsAllowed = parseInt(eventDetails.max_guests_permitted || '0');
|
||||
if (extraGuests > maxGuestsAllowed) {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: `Maximum ${maxGuestsAllowed} guests allowed per person`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Check event capacity including guests
|
||||
if (eventDetails.max_attendees && body.rsvp_status === 'confirmed') {
|
||||
const maxCapacity = parseInt(eventDetails.max_attendees);
|
||||
const currentAttendees = parseInt(eventDetails.current_attendees || '0');
|
||||
const totalRequested = 1 + extraGuests; // Member + guests
|
||||
|
||||
if (currentAttendees + totalRequested > maxCapacity) {
|
||||
// Auto-set to waitlist if over capacity
|
||||
body.rsvp_status = 'waitlist';
|
||||
console.log(`[RSVP] Event at capacity, placing on waitlist: ${currentAttendees} + ${totalRequested} > ${maxCapacity}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Create RSVP record
|
||||
const rsvpData = {
|
||||
record_type: 'rsvp',
|
||||
@@ -95,6 +127,7 @@ export default defineEventHandler(async (event) => {
|
||||
payment_reference: paymentReference,
|
||||
attended: 'false',
|
||||
rsvp_notes: body.rsvp_notes || '',
|
||||
extra_guests: extraGuests.toString(),
|
||||
is_member_pricing: isMemberPricing,
|
||||
created_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString()
|
||||
|
||||
Reference in New Issue
Block a user