show selected team for each candidates

This commit is contained in:
memeriau 2022-04-16 18:47:43 +02:00
parent 7c96636477
commit 49248a4bfa

View File

@ -54,7 +54,7 @@ type Props = {
const TeamWithCandidates: FC<Props> = ({ teamId }): JSX.Element | null => { const TeamWithCandidates: FC<Props> = ({ teamId }): JSX.Element | null => {
const teams = useSelector(selectTeamsWithVolunteersCandidates) const teams = useSelector(selectTeamsWithVolunteersCandidates)
const team = teams.find((t) => t.id === teamId) const currentTeam = teams.find((t) => t.id === teamId)
const [, saveTeam] = useTeamAssign() const [, saveTeam] = useTeamAssign()
const onTeamSelected = useCallback( const onTeamSelected = useCallback(
@ -64,21 +64,22 @@ const TeamWithCandidates: FC<Props> = ({ teamId }): JSX.Element | null => {
[saveTeam] [saveTeam]
) )
if (!team) return null if (!currentTeam) return null
return ( return (
<div> <div>
<div> <div>
Equipe {team.name} ({team.volunteers.length}) : Equipe {currentTeam.name} ({currentTeam.volunteers.length}) :
</div> </div>
<ul> <ul>
{team.volunteers.map(({ id, lastname, firstname, teamWishes, dayWishes }) => ( {currentTeam.volunteers.map(
({ id, lastname, firstname, teamWishes, dayWishes, team }) => (
<li key={id}> <li key={id}>
<span className={styles.volunteerName}> <span className={styles.volunteerName}>
{firstname} {lastname} (<DaysDisplay dayWishes={dayWishes} />) {firstname} {lastname} (<DaysDisplay dayWishes={dayWishes} />)
</span> </span>
{teamWishes.map((teamWish) => { {teamWishes.map((teamWish) => {
const active = false const active = teamWish.id === team
return ( return (
<button <button
key={teamWish.id} key={teamWish.id}
@ -94,7 +95,8 @@ const TeamWithCandidates: FC<Props> = ({ teamId }): JSX.Element | null => {
) )
})} })}
</li> </li>
))} )
)}
</ul> </ul>
</div> </div>
) )