From c1e2e3d37ad8001efb6d5ce815835dec3e919272 Mon Sep 17 00:00:00 2001 From: Srishty Mangutte <68679980+Srish-ty@users.noreply.github.com> Date: Mon, 15 Jul 2024 22:31:21 +0530 Subject: [PATCH] fix: team members and lead order (#99) * feat: showing correct teamLead * fix: sorting users based on useriDS * fix: sorting users based on useriDS --------- Co-authored-by: anmol5936 <127973342+anmol5936@users.noreply.github.com> --- src/components/events/RegisteredEventModal.jsx | 11 +++++++++-- src/components/eventsqueries/GetRegisteredEvents.jsx | 5 +---- src/graphQL/queries/teamRegistration.js | 2 ++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/events/RegisteredEventModal.jsx b/src/components/events/RegisteredEventModal.jsx index d1be4cc..9b82b44 100644 --- a/src/components/events/RegisteredEventModal.jsx +++ b/src/components/events/RegisteredEventModal.jsx @@ -15,6 +15,14 @@ import PropTypes from 'prop-types' export const RegisteredEventModal = ({ closeModal, isTeamEvent, registerdEvent, eventName }) => { const doesContainEDP = edpEvents.includes(eventName) + const teamLeadId = registerdEvent.userIDs[0] + + const sortedUsers = [...registerdEvent.users].sort((a, b) => { + if (a.id === teamLeadId) return -1 + if (b.id === teamLeadId) return 1 + return 0 + }) + return (
@@ -27,7 +35,7 @@ export const RegisteredEventModal = ({ closeModal, isTeamEvent, registerdEvent, Team Name:  {registerdEvent.teamName} - {registerdEvent.users.map((user, index) => ( + {sortedUsers.map((user, index) => (
{index === 0 ? 'Team Lead:' : `Member ${index + 1}:`} @@ -35,7 +43,6 @@ export const RegisteredEventModal = ({ closeModal, isTeamEvent, registerdEvent,
))} - {doesContainEDP && ( Submit your EDPs here: diff --git a/src/components/eventsqueries/GetRegisteredEvents.jsx b/src/components/eventsqueries/GetRegisteredEvents.jsx index 44663ba..0552e1a 100644 --- a/src/components/eventsqueries/GetRegisteredEvents.jsx +++ b/src/components/eventsqueries/GetRegisteredEvents.jsx @@ -7,20 +7,17 @@ const useGetRegisteredEvents = (orgId, uid) => { variables: { orgID: orgId, userId: uid } }) - console.log(orgId, uid) + //console.log(orgId, uid) const [registeredEvents, setRegisteredEvents] = useState([]) useEffect(() => { const fetchData = async () => { try { - console.log('112', data) const allRegisteredEvents = await data.eventRegistration - console.log('filteredEvents', allRegisteredEvents) if (allRegisteredEvents > 0) { setRegisteredEvents(allRegisteredEvents) - console.log(allRegisteredEvents) } else setRegisteredEvents([]) } catch (error) { console.error('Error fetching events:', error) diff --git a/src/graphQL/queries/teamRegistration.js b/src/graphQL/queries/teamRegistration.js index 1c00c27..c6df55a 100644 --- a/src/graphQL/queries/teamRegistration.js +++ b/src/graphQL/queries/teamRegistration.js @@ -5,9 +5,11 @@ export const GET_TEAM_REGISTRATIONS_BY_USER = gql` teamRegistrations(orgID: $orgId, userID: $userId) { eventID teamName + userIDs users { name college + id } } }