mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-06-09 09:04:20 +02:00
better display of team candidates
This commit is contained in:
parent
10d7a2d6ec
commit
724706d308
@ -3,18 +3,17 @@ import ContentTitle from "../ui/Content/ContentTitle"
|
|||||||
import withUserConnected from "../../utils/withUserConnected"
|
import withUserConnected from "../../utils/withUserConnected"
|
||||||
import { fetchTeamListIfNeed } from "../../store/teamList"
|
import { fetchTeamListIfNeed } from "../../store/teamList"
|
||||||
import { fetchVolunteerListIfNeed } from "../../store/volunteerList"
|
import { fetchVolunteerListIfNeed } from "../../store/volunteerList"
|
||||||
import VolunteersWithTeamWishes from "./VolunteersWithTeamWishes"
|
|
||||||
import TeamsWithCandidates from "./TeamsWithCandidates"
|
import TeamsWithCandidates from "./TeamsWithCandidates"
|
||||||
|
import withUserRole from "../../utils/withUserRole"
|
||||||
|
import ROLES from "../../utils/roles.constants"
|
||||||
|
|
||||||
const TeamAssignment: FC = (): JSX.Element => (
|
const TeamAssignment: FC = (): JSX.Element => (
|
||||||
<>
|
<>
|
||||||
<ContentTitle title="Choix par équipes" />
|
<ContentTitle title="Gestion des équipes" />
|
||||||
<TeamsWithCandidates />
|
<TeamsWithCandidates />
|
||||||
<ContentTitle title="Choix des bénévoles" />
|
|
||||||
<VolunteersWithTeamWishes />
|
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
||||||
export default memo(withUserConnected(TeamAssignment))
|
export default withUserRole(ROLES.ASSIGNER, memo(withUserConnected(TeamAssignment)))
|
||||||
|
|
||||||
export const fetchFor = [fetchTeamListIfNeed, fetchVolunteerListIfNeed]
|
export const fetchFor = [fetchTeamListIfNeed, fetchVolunteerListIfNeed]
|
||||||
|
@ -28,7 +28,13 @@ const selectTeamsWithVolunteersCandidates = createSelector(
|
|||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
volunteers: volunteersSelection,
|
volunteersWithoutTeam: volunteersSelection.filter((volunteer) => !volunteer.team),
|
||||||
|
volunteersWithCurrentTeam: volunteersSelection.filter(
|
||||||
|
(volunteer) => volunteer.team === id
|
||||||
|
),
|
||||||
|
volunteersWithOtherTeam: volunteersSelection.filter(
|
||||||
|
(volunteer) => volunteer.team && volunteer.team !== id
|
||||||
|
),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
@ -49,37 +55,31 @@ const DaysDisplay: FC<PropsDaysDisplay> = ({ dayWishes }): JSX.Element => (
|
|||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
|
|
||||||
type Props = {
|
type TeamWithCandidatesVolunteerProps = {
|
||||||
|
volunteer: any
|
||||||
teamId: number
|
teamId: number
|
||||||
}
|
}
|
||||||
|
|
||||||
const TeamWithCandidates: FC<Props> = ({ teamId }): JSX.Element | null => {
|
const TeamWithCandidatesVolunteer: FC<TeamWithCandidatesVolunteerProps> = ({
|
||||||
const teams = useSelector(selectTeamsWithVolunteersCandidates)
|
teamId,
|
||||||
const currentTeam = teams.find((t) => t.id === teamId)
|
volunteer,
|
||||||
|
}): JSX.Element => {
|
||||||
|
const { id, lastname, firstname, teamWishes, dayWishes, team } = volunteer
|
||||||
const [, saveTeam] = useTeamAssign()
|
const [, saveTeam] = useTeamAssign()
|
||||||
|
|
||||||
const onTeamSelected = useCallback(
|
const onTeamSelected = useCallback(
|
||||||
(volunteer, selectedTeamId) => {
|
(selectedVolunteer, selectedTeamId) => {
|
||||||
saveTeam(volunteer, selectedTeamId)
|
saveTeam(selectedVolunteer, selectedTeamId)
|
||||||
},
|
},
|
||||||
[saveTeam]
|
[saveTeam]
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!currentTeam) return <div />
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
|
||||||
<div className={styles.teamHeaderName}>Equipe {currentTeam.name}</div>
|
|
||||||
<TeamMembers teamId={teamId} />
|
|
||||||
<div>Bénévoles intéressés ({currentTeam.volunteers.length}) :</div>
|
|
||||||
<ul>
|
|
||||||
{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: any) => {
|
||||||
const active = teamWish.id === team
|
const active = teamWish.id === team
|
||||||
const current = teamWish.id === teamId
|
const current = teamWish.id === teamId
|
||||||
return (
|
return (
|
||||||
@ -99,7 +99,49 @@ const TeamWithCandidates: FC<Props> = ({ teamId }): JSX.Element | null => {
|
|||||||
})}
|
})}
|
||||||
</li>
|
</li>
|
||||||
)
|
)
|
||||||
)}
|
}
|
||||||
|
|
||||||
|
type TeamWithCandidatesProps = {
|
||||||
|
teamId: number
|
||||||
|
}
|
||||||
|
|
||||||
|
const TeamWithCandidates: FC<TeamWithCandidatesProps> = ({ teamId }): JSX.Element => {
|
||||||
|
const teams = useSelector(selectTeamsWithVolunteersCandidates)
|
||||||
|
const currentTeam = teams.find((t) => t.id === teamId)
|
||||||
|
|
||||||
|
if (!currentTeam) return <div />
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className={styles.teamHeaderName}>Equipe {currentTeam.name}</div>
|
||||||
|
<TeamMembers teamId={teamId} />
|
||||||
|
<div>Bénévoles intéressés :</div>
|
||||||
|
<ul>
|
||||||
|
{currentTeam.volunteersWithoutTeam.map((volunteer) => (
|
||||||
|
<TeamWithCandidatesVolunteer
|
||||||
|
key={volunteer.id}
|
||||||
|
teamId={teamId}
|
||||||
|
volunteer={volunteer}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
{currentTeam.volunteersWithCurrentTeam.map((volunteer) => (
|
||||||
|
<TeamWithCandidatesVolunteer
|
||||||
|
key={volunteer.id}
|
||||||
|
teamId={teamId}
|
||||||
|
volunteer={volunteer}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
{currentTeam.volunteersWithOtherTeam.map((volunteer) => (
|
||||||
|
<TeamWithCandidatesVolunteer
|
||||||
|
key={volunteer.id}
|
||||||
|
teamId={teamId}
|
||||||
|
volunteer={volunteer}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -3,8 +3,6 @@ import { useSelector } from "react-redux"
|
|||||||
import { selectTeamList } from "../../store/teamList"
|
import { selectTeamList } from "../../store/teamList"
|
||||||
import TeamWithCandidates from "./TeamWithCandidates"
|
import TeamWithCandidates from "./TeamWithCandidates"
|
||||||
import styles from "./styles.module.scss"
|
import styles from "./styles.module.scss"
|
||||||
import withUserRole from "../../utils/withUserRole"
|
|
||||||
import ROLES from "../../utils/roles.constants"
|
|
||||||
|
|
||||||
const TeamsWithCandidates: FC = (): JSX.Element => {
|
const TeamsWithCandidates: FC = (): JSX.Element => {
|
||||||
const teams = useSelector(selectTeamList)
|
const teams = useSelector(selectTeamList)
|
||||||
@ -27,4 +25,4 @@ const TeamsWithCandidates: FC = (): JSX.Element => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withUserRole(ROLES.ASSIGNER, memo(TeamsWithCandidates))
|
export default memo(TeamsWithCandidates)
|
||||||
|
@ -4,6 +4,7 @@ import { createSelector } from "@reduxjs/toolkit"
|
|||||||
import { selectVolunteerListAlphaSorted } from "../../store/volunteerList"
|
import { selectVolunteerListAlphaSorted } from "../../store/volunteerList"
|
||||||
import { selectTeamList } from "../../store/teamList"
|
import { selectTeamList } from "../../store/teamList"
|
||||||
import styles from "./styles.module.scss"
|
import styles from "./styles.module.scss"
|
||||||
|
import ContentTitle from "../ui/Content/ContentTitle"
|
||||||
|
|
||||||
const selectVolunteersWithTeamWishes = createSelector(
|
const selectVolunteersWithTeamWishes = createSelector(
|
||||||
selectVolunteerListAlphaSorted,
|
selectVolunteerListAlphaSorted,
|
||||||
@ -23,14 +24,26 @@ const selectVolunteersWithTeamWishes = createSelector(
|
|||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const selectVolunteersWithTeam = createSelector(selectVolunteersWithTeamWishes, (volunteers) =>
|
||||||
|
volunteers.filter((volunteer) => volunteer.teamObject)
|
||||||
|
)
|
||||||
|
|
||||||
|
const selectVolunteersWithoutTeam = createSelector(selectVolunteersWithTeamWishes, (volunteers) =>
|
||||||
|
volunteers.filter((volunteer) => !volunteer.teamObject)
|
||||||
|
)
|
||||||
|
|
||||||
const VolunteersWithTeamWishes: FC = (): JSX.Element => {
|
const VolunteersWithTeamWishes: FC = (): JSX.Element => {
|
||||||
const volunteers = useSelector(selectVolunteersWithTeamWishes)
|
const volunteersWithTeam = useSelector(selectVolunteersWithTeam)
|
||||||
|
const volunteersWithoutTeam = useSelector(selectVolunteersWithoutTeam)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
|
<ContentTitle title="Choix des bénévoles" />
|
||||||
<div>
|
<div>
|
||||||
<div>Bénévoles ayant choisi des équipes ({volunteers.length}) :</div>
|
<div>Bénévoles en attente d'équipe ({volunteersWithoutTeam.length}) :</div>
|
||||||
<ul>
|
<ul>
|
||||||
{volunteers.map(({ id, lastname, firstname, teamWishes, teamObject }) => (
|
{volunteersWithoutTeam.map(
|
||||||
|
({ id, lastname, firstname, teamWishes, teamObject }) => (
|
||||||
<li key={id}>
|
<li key={id}>
|
||||||
<span className={styles.volunteerName}>
|
<span className={styles.volunteerName}>
|
||||||
{firstname} {lastname}{" "}
|
{firstname} {lastname}{" "}
|
||||||
@ -38,9 +51,25 @@ const VolunteersWithTeamWishes: FC = (): JSX.Element => {
|
|||||||
<span className={styles.teamActive}>{teamObject?.name} </span>
|
<span className={styles.teamActive}>{teamObject?.name} </span>
|
||||||
<span>{teamWishes.join(", ")}</span>
|
<span>{teamWishes.join(", ")}</span>
|
||||||
</li>
|
</li>
|
||||||
))}
|
)
|
||||||
|
)}
|
||||||
|
</ul>
|
||||||
|
<div>Bénévoles dans une équipe ({volunteersWithTeam.length}) :</div>
|
||||||
|
<ul>
|
||||||
|
{volunteersWithTeam.map(
|
||||||
|
({ id, lastname, firstname, teamWishes, teamObject }) => (
|
||||||
|
<li key={id}>
|
||||||
|
<span className={styles.volunteerName}>
|
||||||
|
{firstname} {lastname}{" "}
|
||||||
|
</span>
|
||||||
|
<span className={styles.teamActive}>{teamObject?.name} </span>
|
||||||
|
<span>{teamWishes.join(", ")}</span>
|
||||||
|
</li>
|
||||||
|
)
|
||||||
|
)}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,9 @@ type Props = {
|
|||||||
|
|
||||||
const Page: FC<Props> = ({ children }): JSX.Element => (
|
const Page: FC<Props> = ({ children }): JSX.Element => (
|
||||||
<div className={styles.pageWrapper}>
|
<div className={styles.pageWrapper}>
|
||||||
<div className={styles.pageContent}>{children}</div>
|
{React.Children.map(children, (child) => (
|
||||||
|
<div className={styles.pageContent}>{child}</div>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import { AppThunk } from "../../store"
|
|||||||
import { selectUserJwtToken } from "../../store/auth"
|
import { selectUserJwtToken } from "../../store/auth"
|
||||||
import Page from "../../components/ui/Page/Page"
|
import Page from "../../components/ui/Page/Page"
|
||||||
import { TeamAssignment, fetchForTeamAssignment } from "../../components"
|
import { TeamAssignment, fetchForTeamAssignment } from "../../components"
|
||||||
|
import VolunteersWithTeamWishes from "../../components/TeamAssignment/VolunteersWithTeamWishes"
|
||||||
|
|
||||||
export type Props = RouteComponentProps
|
export type Props = RouteComponentProps
|
||||||
|
|
||||||
@ -15,9 +16,14 @@ const TeamAssignmentPage: FC<Props> = (): JSX.Element => {
|
|||||||
if (jwtToken === undefined) return <p>Loading...</p>
|
if (jwtToken === undefined) return <p>Loading...</p>
|
||||||
if (jwtToken) {
|
if (jwtToken) {
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<Page>
|
<Page>
|
||||||
<TeamAssignment />
|
<TeamAssignment />
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page>
|
||||||
|
<VolunteersWithTeamWishes />
|
||||||
|
</Page>
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return <div>Besoin d'être identifié</div>
|
return <div>Besoin d'être identifié</div>
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-content: center;
|
align-content: center;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
@mixin page-wrapper-center {
|
@mixin page-wrapper-center {
|
||||||
@ -35,6 +36,10 @@
|
|||||||
padding: 20px;
|
padding: 20px;
|
||||||
width: $desktopWidth;
|
width: $desktopWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
flex-basis: 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@mixin inner-content-wrapper() {
|
@mixin inner-content-wrapper() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user