Compare commits

..

1 Commits

Author SHA1 Message Date
Levente Orban
e5be4b5589 hotfix: prpevent to use arrows in datepicker 2025-11-02 20:44:58 +01:00
4 changed files with 18 additions and 10 deletions

View File

@@ -139,6 +139,11 @@
bind:value={eventData.date}
min={today}
class="border-dark-300 w-full rounded-sm border-2 bg-white px-4 py-3 text-slate-900 shadow-sm transition-all duration-200"
on:keydown={(e) => {
if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(e.key)) {
e.preventDefault();
}
}}
required
/>
{#if errors.date}

View File

@@ -104,15 +104,14 @@ export const actions: Actions = {
// Get current RSVPs
const currentRSVPs = await database.select().from(rsvps).where(eq(rsvps.eventId, eventId));
// Calculate remaining spots and ensure main attendee + guests fit
const newAttendeesCount = 1 + numberOfGuests;
const remainingSpots = (eventData.attendeeLimit ?? 0) - currentRSVPs.length;
// Calculate total attendees (including guests)
const totalAttendees = currentRSVPs.length + numberOfGuests;
// Check if event is full (for limited type events)
if (eventData.type === 'limited' && eventData.attendeeLimit) {
if (newAttendeesCount > remainingSpots) {
if (totalAttendees > eventData.attendeeLimit) {
return fail(400, {
error: `Event capacity exceeded. You're trying to add ${newAttendeesCount} attendee${newAttendeesCount === 1 ? '' : 's'} (including yourself), but only ${remainingSpots} spot${remainingSpots === 1 ? '' : 's'} remain.`
error: `Event capacity exceeded. You're trying to add ${numberOfGuests + 1} attendees (including yourself), but only ${eventData.attendeeLimit - currentRSVPs.length} spots remain.`
});
}
}

View File

@@ -162,6 +162,11 @@
bind:value={eventData.date}
min={today}
class="border-dark-300 w-full rounded-sm border-2 bg-white px-4 py-3 text-slate-900 shadow-sm transition-all duration-200"
on:keydown={(e) => {
if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(e.key)) {
e.preventDefault();
}
}}
required
/>
{#if errors.date}

View File

@@ -129,15 +129,14 @@ export const actions: Actions = {
// Get current RSVPs
const currentRSVPs = await database.select().from(rsvps).where(eq(rsvps.eventId, eventId));
// Calculate remaining spots and ensure main attendee + guests fit
const newAttendeesCount = 1 + numberOfGuests;
const remainingSpots = (eventData.attendeeLimit ?? 0) - currentRSVPs.length;
// Calculate total attendees (including guests)
const totalAttendees = currentRSVPs.length + numberOfGuests;
// Check if event is full (for limited type events)
if (eventData.type === 'limited' && eventData.attendeeLimit) {
if (newAttendeesCount > remainingSpots) {
if (totalAttendees > eventData.attendeeLimit) {
return fail(400, {
error: `Event capacity exceeded. You're trying to add ${newAttendeesCount} attendee${newAttendeesCount === 1 ? '' : 's'} (including yourself), but only ${remainingSpots} spot${remainingSpots === 1 ? '' : 's'} remain.`
error: `Event capacity exceeded. You're trying to add ${numberOfGuests + 1} attendees (including yourself), but only ${eventData.attendeeLimit - currentRSVPs.length} spots remain.`
});
}
}