Fix type safety and data consistency in events system
All checks were successful
Build And Push Image / docker (push) Successful in 3m25s
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:
@@ -58,7 +58,7 @@
|
||||
|
||||
<!-- No events message -->
|
||||
<v-alert
|
||||
v-if="!loading && events.length === 0"
|
||||
v-if="!loading && (!events || events.length === 0)"
|
||||
type="info"
|
||||
variant="tonal"
|
||||
class="mt-4"
|
||||
@@ -143,7 +143,7 @@ const calendarOptions = computed(() => ({
|
||||
right: process.client && window.innerWidth < 960 ?
|
||||
'dayGridMonth,listWeek' :
|
||||
'dayGridMonth,dayGridWeek,listWeek'
|
||||
},
|
||||
} as any,
|
||||
events: transformedEvents.value,
|
||||
eventClick: handleEventClick,
|
||||
dateClick: handleDateClick,
|
||||
@@ -153,8 +153,8 @@ const calendarOptions = computed(() => ({
|
||||
eventDisplay: 'block',
|
||||
displayEventTime: true,
|
||||
eventTimeFormat: {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hour: '2-digit' as const,
|
||||
minute: '2-digit' as const,
|
||||
hour12: false
|
||||
},
|
||||
locale: 'en',
|
||||
@@ -256,12 +256,11 @@ function transformEventForCalendar(event: Event): FullCalendarEvent {
|
||||
is_paid: event.is_paid === 'true',
|
||||
cost_members: event.cost_members,
|
||||
cost_non_members: event.cost_non_members,
|
||||
max_attendees: event.max_attendees ? parseInt(event.max_attendees) : null,
|
||||
current_attendees: event.current_attendees || 0,
|
||||
max_attendees: event.max_attendees ? parseInt(event.max_attendees) : undefined,
|
||||
current_attendees: typeof event.current_attendees === 'string' ? parseInt(event.current_attendees) : (event.current_attendees || 0),
|
||||
user_rsvp: event.user_rsvp,
|
||||
visibility: event.visibility,
|
||||
creator: event.creator,
|
||||
status: event.status
|
||||
creator: event.creator
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user