diff --git a/src/components/LoginForm/index.tsx b/src/components/LoginForm/index.tsx index 806de2c..772a071 100644 --- a/src/components/LoginForm/index.tsx +++ b/src/components/LoginForm/index.tsx @@ -1,15 +1,14 @@ import React, { memo, useCallback } from "react" import { Link } from "react-router-dom" -import { AppDispatch } from "../../store" +import { shallowEqual, useDispatch, useSelector } from "react-redux" +import { AppState } from "../../store" import { fetchVolunteerLogin } from "../../store/volunteerLogin" import styles from "./styles.module.scss" -interface Props { - dispatch: AppDispatch - error: string -} +const LoginForm = (): JSX.Element => { + const dispatch = useDispatch() + const loginError = useSelector((state: AppState) => state.volunteerLogin.error, shallowEqual) -const LoginForm = ({ dispatch, error }: Props): JSX.Element => { const onSubmit = useCallback( (event: React.SyntheticEvent): void => { event.preventDefault() @@ -41,7 +40,7 @@ const LoginForm = ({ dispatch, error }: Props): JSX.Element => {
-
{error}
+ {loginError &&
{loginError}
}
Demander un nouveau mot de passe
diff --git a/src/pages/Home/Home.tsx b/src/pages/Home/Home.tsx index f356ebe..9badac8 100644 --- a/src/pages/Home/Home.tsx +++ b/src/pages/Home/Home.tsx @@ -25,7 +25,6 @@ const HomePage: FC = (): JSX.Element => { return prevNotifs }, shallowEqual) - const loginError = useSelector((state: AppState) => state.volunteerLogin.error, shallowEqual) const jwt = useSelector((state: AppState) => state.auth.jwt, shallowEqual) if (jwt === undefined) return

Loading...

@@ -38,7 +37,7 @@ const HomePage: FC = (): JSX.Element => {
- +
diff --git a/src/pages/Login/LoginPage.tsx b/src/pages/Login/LoginPage.tsx index 9f0dac0..295ebfc 100644 --- a/src/pages/Login/LoginPage.tsx +++ b/src/pages/Login/LoginPage.tsx @@ -1,26 +1,19 @@ import { RouteComponentProps } from "react-router-dom" -import { useDispatch, useSelector, shallowEqual } from "react-redux" import React, { memo } from "react" import { Helmet } from "react-helmet" -import { AppState } from "../../store" import { LoginForm } from "../../components" import styles from "./styles.module.scss" export type Props = RouteComponentProps -const LoginPage: React.FC = (): JSX.Element => { - const dispatch = useDispatch() - const loginError = useSelector((state: AppState) => state.volunteerLogin.error, shallowEqual) - - return ( -
-
- - -
+const LoginPage: React.FC = (): JSX.Element => ( +
+
+ +
- ) -} +
+) export default memo(LoginPage)