Skip to content

Commit

Permalink
fix: team members and lead order (#99)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Srish-ty and anmol5936 authored Jul 15, 2024
1 parent d5786a0 commit c1e2e3d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
11 changes: 9 additions & 2 deletions src/components/events/RegisteredEventModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Container>
<Section>
Expand All @@ -27,15 +35,14 @@ export const RegisteredEventModal = ({ closeModal, isTeamEvent, registerdEvent,
<TextHead1>Team Name:&nbsp;</TextHead1>
{registerdEvent.teamName}
</TextContainer2>
{registerdEvent.users.map((user, index) => (
{sortedUsers.map((user, index) => (
<div key={index}>
<TextContainer>
<TextHead>{index === 0 ? 'Team Lead:' : `Member ${index + 1}:`}</TextHead>
{user.name + ' - ' + user.college}
</TextContainer>
</div>
))}

{doesContainEDP && (
<TextContainer>
<TextHead>Submit your EDPs here: </TextHead>
Expand Down
5 changes: 1 addition & 4 deletions src/components/eventsqueries/GetRegisteredEvents.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/graphQL/queries/teamRegistration.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ export const GET_TEAM_REGISTRATIONS_BY_USER = gql`
teamRegistrations(orgID: $orgId, userID: $userId) {
eventID
teamName
userIDs
users {
name
college
id
}
}
}
Expand Down

0 comments on commit c1e2e3d

Please sign in to comment.