From 52cd216b0f3cce10e7f93639a10ae0aff5fc7e7f Mon Sep 17 00:00:00 2001 From: pikiou Date: Fri, 11 Feb 2022 02:57:04 +0100 Subject: [PATCH] Add notification for TeamWishesForm --- src/components/Notifications/index.tsx | 25 +++++++++++++++ .../TeamWishesForm/TeamWishesForm.tsx | 11 +++++-- src/components/index.ts | 32 +++++++++++-------- src/pages/Board/Board.tsx | 6 ++-- src/pages/Home/Home.tsx | 7 ++-- 5 files changed, 60 insertions(+), 21 deletions(-) diff --git a/src/components/Notifications/index.tsx b/src/components/Notifications/index.tsx index 1c08df9..35fee67 100644 --- a/src/components/Notifications/index.tsx +++ b/src/components/Notifications/index.tsx @@ -7,6 +7,8 @@ import styles from "./styles.module.scss" import { selectUserJwtToken } from "../../store/auth" import { VolunteerNotifs } from "../../services/volunteers" import LogoutButton from "../LogoutButton/LogoutButton" +import { TeamWishesForm } from ".." +import { fetchFor as fetchForTeamWishesForm } from "../VolunteerBoard/TeamWishesForm/TeamWishesForm" interface Props { // eslint-disable-next-line react/require-default-props @@ -142,6 +144,26 @@ const Notifications = ({ volunteerNotifs }: Props): JSX.Element | null => { ) } + const onSubmit3 = useCallback((): void => { + dispatch( + fetchVolunteerNotifsSet(jwtToken, 0, { + hiddenNotifs: [...(volunteerNotifs?.hiddenNotifs || []), 3], + }) + ) + }, [dispatch, jwtToken, volunteerNotifs]) + + if (!_.includes(hidden, 3)) { + notifs.push( +
+
+
+ +
+
+
+ ) + } + /* DISCORD Discord nous donne à tous la parole via nos téléphone ou navigateurs, pour organiser le meilleur des festivals ! Il permet de discuter sujet par sujet entre tous les bénévoles, entre les membres d'une même équipe, ou avec ton référent. @@ -382,3 +404,6 @@ Tu n'y es absolument pas obligé(e) ! C'est juste plus pratique. } export default memo(Notifications) + +// Fetch server-side data here +export const fetchFor = [...fetchForTeamWishesForm] diff --git a/src/components/VolunteerBoard/TeamWishesForm/TeamWishesForm.tsx b/src/components/VolunteerBoard/TeamWishesForm/TeamWishesForm.tsx index 577ea80..c028891 100644 --- a/src/components/VolunteerBoard/TeamWishesForm/TeamWishesForm.tsx +++ b/src/components/VolunteerBoard/TeamWishesForm/TeamWishesForm.tsx @@ -5,8 +5,9 @@ import set from "lodash/set" import classnames from "classnames" import styles from "./styles.module.scss" import { useUserTeamWishes } from "../teamWishes.utils" -import { selectTeamList } from "../../../store/teamList" +import { fetchTeamListIfNeed, selectTeamList } from "../../../store/teamList" import useSelection from "../useSelection" +import { fetchVolunteerTeamWishesSetIfNeed } from "../../../store/volunteerTeamWishesSet" type Props = { afterSubmit?: () => void | undefined @@ -39,13 +40,16 @@ const TeamWishesForm: FC = ({ afterSubmit }): JSX.Element | null => { const teamWishes = teams .map((team) => team && team.id) .filter((id) => id && isInSelection(id)) + console.log("saveWishes") saveWishes({ teamWishes, teamWishesComment }) if (afterSubmit) afterSubmit() }, [teams, isInSelection, saveWishes, afterSubmit]) return (
-
Mes choix d'équipes
+
+ Sélectionne la ou les équipes que tu aimerais rejoindre : +
    {teams.map((team: any) => (
  • = (): JSX.Element => { export const loadData = (): AppThunk[] => [ fetchVolunteerDayWishesSetIfNeed(), fetchVolunteerParticipationDetailsSetIfNeed(), - fetchVolunteerTeamWishesSetIfNeed(), - fetchTeamListIfNeed(), + ...fetchForTeamWishesForm.map((f) => f()), ] export default memo(BoardPage) diff --git a/src/pages/Home/Home.tsx b/src/pages/Home/Home.tsx index 5e98968..72465ac 100644 --- a/src/pages/Home/Home.tsx +++ b/src/pages/Home/Home.tsx @@ -4,7 +4,7 @@ import { useSelector, shallowEqual } from "react-redux" import { Helmet } from "react-helmet" import { AppState, AppThunk } from "../../store" -import { LoginForm, Notifications } from "../../components" +import { LoginForm, Notifications, fetchForTeamWishesForm } from "../../components" import styles from "./styles.module.scss" import { fetchVolunteerNotifsSetIfNeed } from "../../store/volunteerNotifsSet" import { VolunteerNotifs } from "../../services/volunteers" @@ -49,6 +49,9 @@ const HomePage: FC = (): JSX.Element => { } // Fetch server-side data here -export const loadData = (): AppThunk[] => [fetchVolunteerNotifsSetIfNeed()] +export const loadData = (): AppThunk[] => [ + fetchVolunteerNotifsSetIfNeed(), + ...fetchForTeamWishesForm.map((f) => f()), +] export default memo(HomePage)