This commit is contained in:
@@ -412,28 +412,61 @@ export function createNocoDBEventsClient() {
|
||||
},
|
||||
|
||||
/**
|
||||
* Get events for a specific user (simplified version)
|
||||
* Get events for a specific user with RSVP status loaded
|
||||
*/
|
||||
async findUserEvents(memberId: string, filters?: EventFilters) {
|
||||
console.log('[nocodb-events] Finding events for member:', memberId);
|
||||
|
||||
try {
|
||||
// For now, just get all visible events using the working findAll method
|
||||
// Remove complex filtering temporarily to fix the 422 errors
|
||||
// First get all events using the working findAll method
|
||||
const simpleFilters = {
|
||||
status: filters?.status,
|
||||
limit: (filters as any)?.limit,
|
||||
offset: (filters as any)?.offset
|
||||
};
|
||||
|
||||
console.log('[nocodb-events] Using simplified filters to avoid 422 errors:', simpleFilters);
|
||||
const events = await this.findAll(simpleFilters);
|
||||
console.log('[nocodb-events] Using simplified filters:', simpleFilters);
|
||||
const eventsResponse = await this.findAll(simpleFilters);
|
||||
|
||||
if (!eventsResponse.list || eventsResponse.list.length === 0) {
|
||||
console.log('[nocodb-events] No events found');
|
||||
return eventsResponse;
|
||||
}
|
||||
|
||||
console.log('[nocodb-events] Found', eventsResponse.list.length, 'events, now loading RSVPs for member:', memberId);
|
||||
|
||||
// Load RSVPs for each event for this user
|
||||
const eventsWithRSVPs = await Promise.all(
|
||||
eventsResponse.list.map(async (event) => {
|
||||
try {
|
||||
// Use event_id if available, otherwise fall back to database Id
|
||||
const eventIdentifier = event.event_id || event.id || (event as any).Id;
|
||||
console.log('[nocodb-events] Loading RSVP for event:', event.title, 'identifier:', eventIdentifier);
|
||||
|
||||
const userRSVP = await this.findUserRSVP(eventIdentifier, memberId);
|
||||
|
||||
if (userRSVP) {
|
||||
console.log('[nocodb-events] ✅ Found RSVP for event', event.title, ':', userRSVP.rsvp_status);
|
||||
return {
|
||||
...event,
|
||||
user_rsvp: userRSVP
|
||||
};
|
||||
} else {
|
||||
console.log('[nocodb-events] ℹ️ No RSVP found for event:', event.title);
|
||||
return event;
|
||||
}
|
||||
} catch (rsvpError) {
|
||||
console.log('[nocodb-events] ⚠️ Error loading RSVP for event', event.title, ':', rsvpError);
|
||||
return event; // Return event without RSVP if lookup fails
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
console.log('[nocodb-events] ✅ Loaded RSVPs for all events');
|
||||
|
||||
// TODO: Add RSVP lookup from separate table
|
||||
// For now, return events without RSVP status
|
||||
return {
|
||||
list: events.list || [],
|
||||
PageInfo: events.PageInfo
|
||||
list: eventsWithRSVPs,
|
||||
PageInfo: eventsResponse.PageInfo
|
||||
};
|
||||
} catch (error: any) {
|
||||
console.error('[nocodb-events] Error finding user events:', error);
|
||||
|
||||
Reference in New Issue
Block a user