display team name on volunteer board, in team block

This commit is contained in:
memeriau 2022-04-18 01:41:54 +02:00
parent dd73fa21b8
commit c474426fa8

View File

@ -5,11 +5,13 @@ import useAction from "../../../utils/useAction"
import styles from "./styles.module.scss" import styles from "./styles.module.scss"
import { selectUserId } from "../../../store/auth" import { selectUserId } from "../../../store/auth"
import { fetchVolunteerListIfNeed, selectVolunteerList } from "../../../store/volunteerList" import { fetchVolunteerListIfNeed, selectVolunteerList } from "../../../store/volunteerList"
import { selectTeamList } from "../../../store/teamList"
const useUserTeam = () => { const useUserTeam = () => {
const userId = useSelector(selectUserId) const userId = useSelector(selectUserId)
const fetch = useAction(fetchVolunteerListIfNeed) const fetch = useAction(fetchVolunteerListIfNeed)
const volunteers = useSelector(selectVolunteerList) const volunteers = useSelector(selectVolunteerList)
const teams = useSelector(selectTeamList)
useEffect(() => { useEffect(() => {
if (userId) fetch() if (userId) fetch()
@ -20,7 +22,7 @@ const useUserTeam = () => {
[volunteers, userId] [volunteers, userId]
) )
return user?.team return useMemo(() => teams.find((t) => t?.id === user?.team), [user, teams])
} }
const VolunteerTeam: FC = (): JSX.Element => { const VolunteerTeam: FC = (): JSX.Element => {
@ -29,8 +31,8 @@ const VolunteerTeam: FC = (): JSX.Element => {
return ( return (
<div className={styles.root}> <div className={styles.root}>
<div className={styles.title}>Mon équipe</div> <div className={styles.title}>Mon équipe : {team.name}</div>
<TeamMembers teamId={team} /> <TeamMembers teamId={team.id} />
</div> </div>
) )
} }