mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-09-11 05:46:28 +02:00
can select team for volunteer - first step
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
import { FC, memo } from "react"
|
import { FC, memo, useCallback } from "react"
|
||||||
import { useSelector } from "react-redux"
|
import { useSelector } from "react-redux"
|
||||||
import { createSelector } from "@reduxjs/toolkit"
|
import { createSelector } from "@reduxjs/toolkit"
|
||||||
|
import classnames from "classnames"
|
||||||
import { selectVolunteerList } from "../../store/volunteerList"
|
import { selectVolunteerList } from "../../store/volunteerList"
|
||||||
import { selectTeamList } from "../../store/teamList"
|
import { selectTeamList } from "../../store/teamList"
|
||||||
|
import styles from "./styles.module.scss"
|
||||||
|
|
||||||
const selectTeamsWithVolunteersCandidates = createSelector(
|
const selectTeamsWithVolunteersCandidates = createSelector(
|
||||||
selectVolunteerList,
|
selectVolunteerList,
|
||||||
@@ -15,7 +17,10 @@ const selectTeamsWithVolunteersCandidates = createSelector(
|
|||||||
...volunteer,
|
...volunteer,
|
||||||
teamWishes: volunteer.teamWishes.map((wishId) => {
|
teamWishes: volunteer.teamWishes.map((wishId) => {
|
||||||
const matchingTeam = teams.find((team: any) => wishId === team?.id)
|
const matchingTeam = teams.find((team: any) => wishId === team?.id)
|
||||||
return matchingTeam?.name
|
return {
|
||||||
|
id: matchingTeam?.id,
|
||||||
|
name: matchingTeam?.name,
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
}))
|
}))
|
||||||
return {
|
return {
|
||||||
@@ -33,6 +38,11 @@ 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 team = teams.find((t) => t.id === teamId)
|
||||||
|
|
||||||
|
const onTeamSelected = useCallback((volunteerId, selectedTeamId) => {
|
||||||
|
console.log("select ", volunteerId, selectedTeamId)
|
||||||
|
}, [])
|
||||||
|
|
||||||
if (!team) return null
|
if (!team) return null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -46,7 +56,23 @@ const TeamWithCandidates: FC<Props> = ({ teamId }): JSX.Element | null => {
|
|||||||
<b>
|
<b>
|
||||||
{firstname} {lastname}
|
{firstname} {lastname}
|
||||||
</b>{" "}
|
</b>{" "}
|
||||||
: {teamWishes.join(", ")}
|
:
|
||||||
|
{teamWishes.map((teamWish) => {
|
||||||
|
const active = false
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
key={teamWish.id}
|
||||||
|
type="button"
|
||||||
|
onClick={() => onTeamSelected(id, teamWish.id)}
|
||||||
|
className={classnames(
|
||||||
|
styles.teamWishButton,
|
||||||
|
active && styles.teamActive
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{teamWish.name}
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
})}
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
@@ -21,3 +21,17 @@
|
|||||||
padding: 4px 10px;
|
padding: 4px 10px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.teamWishButton {
|
||||||
|
margin: 0 2px;
|
||||||
|
padding: 2px;
|
||||||
|
|
||||||
|
&.teamActive {
|
||||||
|
font-weight: bold;
|
||||||
|
color: $color-orange;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: #fb0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user