Add notification for TeamWishesForm

This commit is contained in:
pikiou 2022-02-11 02:57:04 +01:00
parent ddd99ff4bb
commit 52cd216b0f
5 changed files with 60 additions and 21 deletions

View File

@ -7,6 +7,8 @@ import styles from "./styles.module.scss"
import { selectUserJwtToken } from "../../store/auth" import { selectUserJwtToken } from "../../store/auth"
import { VolunteerNotifs } from "../../services/volunteers" import { VolunteerNotifs } from "../../services/volunteers"
import LogoutButton from "../LogoutButton/LogoutButton" import LogoutButton from "../LogoutButton/LogoutButton"
import { TeamWishesForm } from ".."
import { fetchFor as fetchForTeamWishesForm } from "../VolunteerBoard/TeamWishesForm/TeamWishesForm"
interface Props { interface Props {
// eslint-disable-next-line react/require-default-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(
<div key="1">
<div className={styles.notificationsPage}>
<div className={styles.notificationsContent}>
<TeamWishesForm afterSubmit={onSubmit3} />
</div>
</div>
</div>
)
}
/* DISCORD /* DISCORD
Discord nous donne à tous la parole via nos téléphone ou navigateurs, pour organiser le meilleur des festivals ! 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. 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) export default memo(Notifications)
// Fetch server-side data here
export const fetchFor = [...fetchForTeamWishesForm]

View File

@ -5,8 +5,9 @@ import set from "lodash/set"
import classnames from "classnames" import classnames from "classnames"
import styles from "./styles.module.scss" import styles from "./styles.module.scss"
import { useUserTeamWishes } from "../teamWishes.utils" import { useUserTeamWishes } from "../teamWishes.utils"
import { selectTeamList } from "../../../store/teamList" import { fetchTeamListIfNeed, selectTeamList } from "../../../store/teamList"
import useSelection from "../useSelection" import useSelection from "../useSelection"
import { fetchVolunteerTeamWishesSetIfNeed } from "../../../store/volunteerTeamWishesSet"
type Props = { type Props = {
afterSubmit?: () => void | undefined afterSubmit?: () => void | undefined
@ -39,13 +40,16 @@ const TeamWishesForm: FC<Props> = ({ afterSubmit }): JSX.Element | null => {
const teamWishes = teams const teamWishes = teams
.map((team) => team && team.id) .map((team) => team && team.id)
.filter((id) => id && isInSelection(id)) .filter((id) => id && isInSelection(id))
console.log("saveWishes")
saveWishes({ teamWishes, teamWishesComment }) saveWishes({ teamWishes, teamWishesComment })
if (afterSubmit) afterSubmit() if (afterSubmit) afterSubmit()
}, [teams, isInSelection, saveWishes, afterSubmit]) }, [teams, isInSelection, saveWishes, afterSubmit])
return ( return (
<div className={styles.root}> <div className={styles.root}>
<div className={styles.title}>Mes choix d&apos;équipes</div> <div className={styles.title}>
Sélectionne la ou les équipes que tu aimerais rejoindre :
</div>
<ul className={styles.teamList}> <ul className={styles.teamList}>
{teams.map((team: any) => ( {teams.map((team: any) => (
<li <li
@ -92,3 +96,6 @@ TeamWishesForm.defaultProps = {
} }
export default memo(TeamWishesForm) export default memo(TeamWishesForm)
// Fetch server-side data here
export const fetchFor = [fetchTeamListIfNeed, fetchVolunteerTeamWishesSetIfNeed]

View File

@ -1,25 +1,31 @@
import AnnouncementLink from "./AnnouncementLink" import AnnouncementLink from "./AnnouncementLink"
import LoginForm from "./LoginForm" import ErrorBoundary from "./ErrorBoundary"
import Notifications from "./Notifications"
import VolunteerList from "./VolunteerList"
import JavGameList from "./JavGameList" import JavGameList from "./JavGameList"
import Loading from "./Loading"
import LoginForm from "./LoginForm"
import Notifications, { fetchFor as fetchForNotifications } from "./Notifications"
import PreRegisterForm from "./PreRegisterForm"
import TeamWishesForm, {
fetchFor as fetchForTeamWishesForm,
} from "./VolunteerBoard/TeamWishesForm/TeamWishesForm"
import VolunteerList from "./VolunteerList"
import VolunteerInfo from "./VolunteerInfo" import VolunteerInfo from "./VolunteerInfo"
import VolunteerSet from "./VolunteerSet" import VolunteerSet from "./VolunteerSet"
import ErrorBoundary from "./ErrorBoundary"
import Loading from "./Loading"
import WishAdd from "./WishAdd" import WishAdd from "./WishAdd"
import PreRegisterForm from "./PreRegisterForm"
export { export {
AnnouncementLink, AnnouncementLink,
ErrorBoundary,
JavGameList,
Loading,
LoginForm, LoginForm,
Notifications, Notifications,
VolunteerList, fetchForNotifications,
JavGameList,
VolunteerInfo,
VolunteerSet,
ErrorBoundary,
Loading,
WishAdd,
PreRegisterForm, PreRegisterForm,
TeamWishesForm,
fetchForTeamWishesForm,
VolunteerInfo,
VolunteerList,
VolunteerSet,
WishAdd,
} }

View File

@ -8,8 +8,7 @@ import Page from "../../components/Page/Page"
import Board from "../../components/VolunteerBoard/Board" import Board from "../../components/VolunteerBoard/Board"
import { fetchVolunteerDayWishesSetIfNeed } from "../../store/volunteerDayWishesSet" import { fetchVolunteerDayWishesSetIfNeed } from "../../store/volunteerDayWishesSet"
import { fetchVolunteerParticipationDetailsSetIfNeed } from "../../store/volunteerParticipationDetailsSet" import { fetchVolunteerParticipationDetailsSetIfNeed } from "../../store/volunteerParticipationDetailsSet"
import { fetchVolunteerTeamWishesSetIfNeed } from "../../store/volunteerTeamWishesSet" import { fetchForTeamWishesForm } from "../../components"
import { fetchTeamListIfNeed } from "../../store/teamList"
export type Props = RouteComponentProps export type Props = RouteComponentProps
@ -31,8 +30,7 @@ const BoardPage: FC<Props> = (): JSX.Element => {
export const loadData = (): AppThunk[] => [ export const loadData = (): AppThunk[] => [
fetchVolunteerDayWishesSetIfNeed(), fetchVolunteerDayWishesSetIfNeed(),
fetchVolunteerParticipationDetailsSetIfNeed(), fetchVolunteerParticipationDetailsSetIfNeed(),
fetchVolunteerTeamWishesSetIfNeed(), ...fetchForTeamWishesForm.map((f) => f()),
fetchTeamListIfNeed(),
] ]
export default memo(BoardPage) export default memo(BoardPage)

View File

@ -4,7 +4,7 @@ import { useSelector, shallowEqual } from "react-redux"
import { Helmet } from "react-helmet" import { Helmet } from "react-helmet"
import { AppState, AppThunk } from "../../store" import { AppState, AppThunk } from "../../store"
import { LoginForm, Notifications } from "../../components" import { LoginForm, Notifications, fetchForTeamWishesForm } from "../../components"
import styles from "./styles.module.scss" import styles from "./styles.module.scss"
import { fetchVolunteerNotifsSetIfNeed } from "../../store/volunteerNotifsSet" import { fetchVolunteerNotifsSetIfNeed } from "../../store/volunteerNotifsSet"
import { VolunteerNotifs } from "../../services/volunteers" import { VolunteerNotifs } from "../../services/volunteers"
@ -49,6 +49,9 @@ const HomePage: FC<Props> = (): JSX.Element => {
} }
// Fetch server-side data here // Fetch server-side data here
export const loadData = (): AppThunk[] => [fetchVolunteerNotifsSetIfNeed()] export const loadData = (): AppThunk[] => [
fetchVolunteerNotifsSetIfNeed(),
...fetchForTeamWishesForm.map((f) => f()),
]
export default memo(HomePage) export default memo(HomePage)