From 6823851b6395c1c5be3f51ab847147dcc57b7f53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Gierwia=C5=82o?= Date: Fri, 14 Nov 2025 14:20:20 +0100 Subject: [PATCH] fix: improve event check-in UX and participant counting Backend: - Use _count.participants for accurate real-time participant count - Remove reliance on stale participantsCount column Frontend: - Show check-in requirement message for non-joined events - Display "Open chat" button only for joined events - Add dev-only "View details" button for QR code access during testing - Improve visual feedback with amber-colored check-in notice This ensures the participant count reflects actual checked-in users and prevents unauthorized access to QR codes in production while maintaining developer convenience in development mode. --- backend/src/routes/events.js | 8 +++++-- frontend/src/pages/EventsPage.jsx | 38 +++++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/backend/src/routes/events.js b/backend/src/routes/events.js index 9ad4dfe..d315896 100644 --- a/backend/src/routes/events.js +++ b/backend/src/routes/events.js @@ -19,7 +19,6 @@ router.get('/', authenticate, async (req, res, next) => { startDate: true, endDate: true, worldsdcId: true, - participantsCount: true, description: true, createdAt: true, participants: { @@ -30,6 +29,11 @@ router.get('/', authenticate, async (req, res, next) => { joinedAt: true, }, }, + _count: { + select: { + participants: true, + }, + }, }, }); @@ -42,7 +46,7 @@ router.get('/', authenticate, async (req, res, next) => { startDate: event.startDate, endDate: event.endDate, worldsdcId: event.worldsdcId, - participantsCount: event.participantsCount, + participantsCount: event._count.participants, description: event.description, createdAt: event.createdAt, isJoined: event.participants.length > 0, diff --git a/frontend/src/pages/EventsPage.jsx b/frontend/src/pages/EventsPage.jsx index 3b10d11..6d94a04 100644 --- a/frontend/src/pages/EventsPage.jsx +++ b/frontend/src/pages/EventsPage.jsx @@ -2,7 +2,7 @@ import { useState, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; import Layout from '../components/layout/Layout'; import { eventsAPI } from '../services/api'; -import { Calendar, MapPin, Users, Loader2, CheckCircle } from 'lucide-react'; +import { Calendar, MapPin, Users, Loader2, CheckCircle, QrCode } from 'lucide-react'; const EventsPage = () => { const navigate = useNavigate(); @@ -101,12 +101,36 @@ const EventsPage = () => {

{event.description}

)} - +
+ {event.isJoined ? ( + + ) : ( +
+
+ + Check-in required +
+

+ Scan the QR code at the event venue to join the chat +

+
+ )} + + {/* Development mode: Show details link */} + {import.meta.env.DEV && ( + + )} +
))}