fix: social_events API public + add availability table

- Make social_events GET endpoint public (was returning 401)
- Add WHERE active = TRUE filter to social_events query
- Create availability table for room date management
This commit is contained in:
2026-06-28 10:20:18 -05:00
parent c46dc826fb
commit b4b8cbcce1
3 changed files with 1285 additions and 2 deletions
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -4,17 +4,17 @@ import { db } from '@/lib/db';
export async function GET() {
try {
await requireRole('admin');
const { rows } = await db.query(`
SELECT se.*,
(SELECT COUNT(*) FROM social_event_reservations ser WHERE ser.social_event_id = se.id) as reservation_count
FROM social_events se
WHERE se.active = TRUE
ORDER BY se.sort_order, se.date, se.id
`);
return NextResponse.json({ data: rows });
} catch (error: any) {
console.error('GET /api/social_events error:', error);
return NextResponse.json({ error: error.message || 'Unauthorized' }, { status: 401 });
return NextResponse.json({ error: error.message || 'Failed to fetch social events' }, { status: 500 });
}
}