Fix type safety and data consistency in events system
All checks were successful
Build And Push Image / docker (push) Successful in 3m25s

- Add proper TypeScript type annotations and assertions
- Handle string/number conversion for attendee counts consistently
- Improve null/undefined checks for events array
- Make event handlers async for better error handling
- Fix data type inconsistencies between components and API
This commit is contained in:
2025-08-12 17:23:42 +02:00
parent 70b77fbe9f
commit 072acf95eb
4 changed files with 45 additions and 22 deletions

View File

@@ -113,7 +113,7 @@ export const useEvents = () => {
error.value = null;
try {
const response = await $fetch(`/api/events/${eventId}/rsvp`, {
const response = await $fetch<{ success: boolean; data: any; message: string }>(`/api/events/${eventId}/rsvp`, {
method: 'POST',
body: {
...rsvpData,
@@ -130,8 +130,10 @@ export const useEvents = () => {
// Update attendee count if confirmed
if (rsvpData.rsvp_status === 'confirmed') {
const currentCount = events.value[eventIndex].current_attendees || 0;
events.value[eventIndex].current_attendees = currentCount + 1;
const currentCount = typeof events.value[eventIndex].current_attendees === 'string'
? parseInt(events.value[eventIndex].current_attendees) || 0
: events.value[eventIndex].current_attendees || 0;
events.value[eventIndex].current_attendees = (currentCount + 1).toString();
}
}