From c5d238c134d9eaccfeb8cf2077eff0004dc42d0f Mon Sep 17 00:00:00 2001 From: memeriau Date: Mon, 28 Feb 2022 22:45:52 +0100 Subject: [PATCH] Team choice is now sorted --- .../DayWishes/styles.module.scss | 1 + .../ParticipationDetails/styles.module.scss | 1 + .../TeamWishes/styles.module.scss | 2 +- .../TeamWishesForm/TeamWishesForm.tsx | 74 +++++++++++-------- .../TeamWishesForm/styles.module.scss | 37 ++++++---- src/components/VolunteerBoard/useSelection.ts | 52 +++++-------- src/theme/mixins.scss | 1 + 7 files changed, 86 insertions(+), 82 deletions(-) diff --git a/src/components/VolunteerBoard/DayWishes/styles.module.scss b/src/components/VolunteerBoard/DayWishes/styles.module.scss index 2e5f96f..5af7a36 100755 --- a/src/components/VolunteerBoard/DayWishes/styles.module.scss +++ b/src/components/VolunteerBoard/DayWishes/styles.module.scss @@ -5,6 +5,7 @@ @include inner-content-wrapper(); position: relative; + padding-right: 90px; } .daysLine, diff --git a/src/components/VolunteerBoard/ParticipationDetails/styles.module.scss b/src/components/VolunteerBoard/ParticipationDetails/styles.module.scss index 33a700a..26a8ff7 100755 --- a/src/components/VolunteerBoard/ParticipationDetails/styles.module.scss +++ b/src/components/VolunteerBoard/ParticipationDetails/styles.module.scss @@ -5,6 +5,7 @@ @include inner-content-wrapper(); position: relative; + padding-right: 90px; } .title { diff --git a/src/components/VolunteerBoard/TeamWishes/styles.module.scss b/src/components/VolunteerBoard/TeamWishes/styles.module.scss index 5fe7878..4888b2d 100755 --- a/src/components/VolunteerBoard/TeamWishes/styles.module.scss +++ b/src/components/VolunteerBoard/TeamWishes/styles.module.scss @@ -5,7 +5,7 @@ @include inner-content-wrapper(); position: relative; - padding-right: 130px; + padding-right: 90px; } .title { diff --git a/src/components/VolunteerBoard/TeamWishesForm/TeamWishesForm.tsx b/src/components/VolunteerBoard/TeamWishesForm/TeamWishesForm.tsx index 3c4e39a..7517559 100644 --- a/src/components/VolunteerBoard/TeamWishesForm/TeamWishesForm.tsx +++ b/src/components/VolunteerBoard/TeamWishesForm/TeamWishesForm.tsx @@ -16,27 +16,23 @@ type Props = { const TeamWishesForm: FC = ({ afterSubmit }): JSX.Element | null => { const teams = useSelector(selectTeamList) - const { addToSelection, toggleToSelection, isInSelection } = useSelection() + const { selection, setSelection, toggleToSelection, isInSelection } = useSelection() const commentRef = useRef(null) const [userWishes, saveWishes] = useUserTeamWishes() useEffect(() => { if (!userWishes) return - addToSelection(...get(userWishes, "teamWishes", [])) + setSelection(...get(userWishes, "teamWishes", [])) set(commentRef, "current.value", get(userWishes, "teamWishesComment", "")) - }, [userWishes, addToSelection]) + }, [userWishes, setSelection]) const onTeamClick = useCallback((id) => toggleToSelection(id), [toggleToSelection]) const onSubmit = useCallback(() => { const teamWishesComment = get(commentRef, "current.value", "") - const teamWishes = teams - .map((team) => team && team.id) - .filter((id) => id && isInSelection(id)) - console.log("saveWishes") - saveWishes({ teamWishes, teamWishesComment }) + saveWishes({ teamWishes: selection, teamWishesComment }) if (afterSubmit) afterSubmit() - }, [teams, isInSelection, saveWishes, afterSubmit]) + }, [selection, saveWishes, afterSubmit]) return (
@@ -45,34 +41,48 @@ const TeamWishesForm: FC = ({ afterSubmit }): JSX.Element | null => {

Sélectionne la ou les équipes que tu aimerais rejoindre.

Pour plus d'informations sur les équipes,{" "} - + clique ici .

-
    - {teams.map((team: any) => ( -
  • - -
  • - ))} -
-
- -