Fix login not updating redux store by reloading whole page

This commit is contained in:
pikiou
2022-02-16 02:44:23 +01:00
parent 4b2a68174b
commit 140891c4c0
5 changed files with 33 additions and 38 deletions

View File

@@ -1,21 +1,18 @@
import React, { FC, memo, useCallback } from "react"
import { useDispatch, useSelector } from "react-redux"
import { useSelector } from "react-redux"
import { unsetJWT } from "../../services/auth"
import { isUserConnected, logoutUser } from "../../store/auth"
import { isUserConnected } from "../../store/auth"
import styles from "./styles.module.scss"
const LogoutButton: FC = (): JSX.Element | null => {
const dispatch = useDispatch()
const connected = useSelector(isUserConnected)
const onClick = useCallback(
(event: React.SyntheticEvent): void => {
event.preventDefault()
unsetJWT()
dispatch(logoutUser())
},
[dispatch]
)
const onClick = useCallback((event: React.SyntheticEvent): void => {
event.preventDefault()
unsetJWT()
// eslint-disable-next-line no-restricted-globals
location?.reload()
}, [])
if (!connected) return null

View File

@@ -7,7 +7,7 @@ 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 { TeamWishesForm } from ".."
import { fetchFor as fetchForTeamWishesForm } from "../VolunteerBoard/TeamWishesForm/TeamWishesForm"
interface Props {
@@ -144,25 +144,25 @@ const Notifications = ({ volunteerNotifs }: Props): JSX.Element | null => {
)
}
const onSubmit3 = useCallback((): void => {
dispatch(
fetchVolunteerNotifsSet(jwtToken, 0, {
hiddenNotifs: [...(volunteerNotifs?.hiddenNotifs || []), 3],
})
)
}, [dispatch, jwtToken, volunteerNotifs])
// 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>
)
}
// 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 nous donne à tous la parole via nos téléphone ou navigateurs, pour organiser le meilleur des festivals !