Browse Source

correction d'une typo dans la liste des reducers, les déconnexions sont maintenant effectives

Lou 3 years ago
parent
commit
7c6160c757

+ 19
- 9
src/components/Navbar/index.jsx View File

@@ -1,12 +1,14 @@
1 1
 import React from "react";
2 2
 import { Link } from "react-router-dom";
3
-import Cookies from "js-cookie";
3
+import { useSelector } from "react-redux";
4 4
 
5 5
 import "./index.scss";
6 6
 import Star from "../../assets/img/star.ico";
7 7
 import LogoutButton from "../buttons/LogoutButton";
8 8
 
9 9
 const Navbar = () => {
10
+	const currentUser = useSelector((state) => state.currentUser);
11
+
10 12
 	return (
11 13
 		<div className="navbar">
12 14
 			<div className="navbar__LeftSide">
@@ -22,14 +24,22 @@ const Navbar = () => {
22 24
 				</Link>
23 25
 			</div>
24 26
 			<div className="navbar__RightSide">
25
-				<Link to="/signup">
26
-					<button>S'inscrire</button>
27
-				</Link>
28
-				<Link to="/login">
29
-					<button>Se connecter</button>
30
-				</Link>
31
-				<button>Profil</button>
32
-				<LogoutButton />
27
+				{!currentUser && (
28
+					<>
29
+						<Link to="/signup">
30
+							<button>S'inscrire</button>
31
+						</Link>
32
+						<Link to="/login">
33
+							<button>Se connecter</button>
34
+						</Link>
35
+					</>
36
+				)}
37
+				{currentUser && (
38
+					<>
39
+						<button>Profil</button>
40
+						<LogoutButton />
41
+					</>
42
+				)}
33 43
 			</div>
34 44
 		</div>
35 45
 	);

+ 1
- 1
src/components/buttons/LogoutButton/index.jsx View File

@@ -2,7 +2,7 @@ import React from "react";
2 2
 import { useDispatch } from "react-redux";
3 3
 import { useHistory } from "react-router-dom";
4 4
 import Cookies from "js-cookie";
5
-import { removeCurrentUser } from "../../../redux/action";
5
+import { removeCurrentUser } from "../../../redux/action/index";
6 6
 
7 7
 const LogoutButton = () => {
8 8
 	const dispatch = useDispatch();

+ 1
- 1
src/redux/reducer/index.js View File

@@ -4,7 +4,7 @@ const reducer = ( state = initialState, action ) => {
4 4
   switch (action.type){
5 5
     case "SET_CURRENT_USER":
6 6
       return { currentUser: action.payload };
7
-    case "REMOVE_CURRENT_SUER":
7
+    case "REMOVE_CURRENT_USER":
8 8
       return initialState;
9 9
     default:
10 10
       return { ...state }

Loading…
Cancel
Save