From b67cb0afb1b85a08bcf07b5ec3ce306444fb9641 Mon Sep 17 00:00:00 2001 From: memeriau Date: Tue, 12 Apr 2022 00:01:11 +0200 Subject: [PATCH] can select team for volunteer - first step --- .../TeamAssignment/TeamWithCandidates.tsx | 32 +++++++++++++++++-- .../TeamAssignment/styles.module.scss | 14 ++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/components/TeamAssignment/TeamWithCandidates.tsx b/src/components/TeamAssignment/TeamWithCandidates.tsx index 48fe8a6..d5d7ce6 100644 --- a/src/components/TeamAssignment/TeamWithCandidates.tsx +++ b/src/components/TeamAssignment/TeamWithCandidates.tsx @@ -1,8 +1,10 @@ -import { FC, memo } from "react" +import { FC, memo, useCallback } from "react" import { useSelector } from "react-redux" import { createSelector } from "@reduxjs/toolkit" +import classnames from "classnames" import { selectVolunteerList } from "../../store/volunteerList" import { selectTeamList } from "../../store/teamList" +import styles from "./styles.module.scss" const selectTeamsWithVolunteersCandidates = createSelector( selectVolunteerList, @@ -15,7 +17,10 @@ const selectTeamsWithVolunteersCandidates = createSelector( ...volunteer, teamWishes: volunteer.teamWishes.map((wishId) => { const matchingTeam = teams.find((team: any) => wishId === team?.id) - return matchingTeam?.name + return { + id: matchingTeam?.id, + name: matchingTeam?.name, + } }), })) return { @@ -33,6 +38,11 @@ type Props = { const TeamWithCandidates: FC = ({ teamId }): JSX.Element | null => { const teams = useSelector(selectTeamsWithVolunteersCandidates) const team = teams.find((t) => t.id === teamId) + + const onTeamSelected = useCallback((volunteerId, selectedTeamId) => { + console.log("select ", volunteerId, selectedTeamId) + }, []) + if (!team) return null return ( @@ -46,7 +56,23 @@ const TeamWithCandidates: FC = ({ teamId }): JSX.Element | null => { {firstname} {lastname} {" "} - : {teamWishes.join(", ")} + : + {teamWishes.map((teamWish) => { + const active = false + return ( + + ) + })} ))} diff --git a/src/components/TeamAssignment/styles.module.scss b/src/components/TeamAssignment/styles.module.scss index fbbedaa..9f4cf6c 100755 --- a/src/components/TeamAssignment/styles.module.scss +++ b/src/components/TeamAssignment/styles.module.scss @@ -21,3 +21,17 @@ padding: 4px 10px; } } + +.teamWishButton { + margin: 0 2px; + padding: 2px; + + &.teamActive { + font-weight: bold; + color: $color-orange; + } + + &:hover { + background-color: #fb0; + } +}