From 49248a4bfad580e89b2c4b8bad9e6fd9341d736b Mon Sep 17 00:00:00 2001 From: memeriau Date: Sat, 16 Apr 2022 18:47:43 +0200 Subject: [PATCH] show selected team for each candidates --- .../TeamAssignment/TeamWithCandidates.tsx | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/components/TeamAssignment/TeamWithCandidates.tsx b/src/components/TeamAssignment/TeamWithCandidates.tsx index 1820125..daed180 100644 --- a/src/components/TeamAssignment/TeamWithCandidates.tsx +++ b/src/components/TeamAssignment/TeamWithCandidates.tsx @@ -54,7 +54,7 @@ type Props = { const TeamWithCandidates: FC = ({ teamId }): JSX.Element | null => { const teams = useSelector(selectTeamsWithVolunteersCandidates) - const team = teams.find((t) => t.id === teamId) + const currentTeam = teams.find((t) => t.id === teamId) const [, saveTeam] = useTeamAssign() const onTeamSelected = useCallback( @@ -64,37 +64,39 @@ const TeamWithCandidates: FC = ({ teamId }): JSX.Element | null => { [saveTeam] ) - if (!team) return null + if (!currentTeam) return null return (
- Equipe {team.name} ({team.volunteers.length}) : + Equipe {currentTeam.name} ({currentTeam.volunteers.length}) :
    - {team.volunteers.map(({ id, lastname, firstname, teamWishes, dayWishes }) => ( -
  • - - {firstname} {lastname} () - - {teamWishes.map((teamWish) => { - const active = false - return ( - - ) - })} -
  • - ))} + {currentTeam.volunteers.map( + ({ id, lastname, firstname, teamWishes, dayWishes, team }) => ( +
  • + + {firstname} {lastname} () + + {teamWishes.map((teamWish) => { + const active = teamWish.id === team + return ( + + ) + })} +
  • + ) + )}
)