Skip to content

Commit 961e7ce

Browse files
committed
added links part
1 parent 8f464f7 commit 961e7ce

File tree

5 files changed

+58
-2
lines changed

5 files changed

+58
-2
lines changed

src/components/Links.jsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import "../style/Links.css";
2+
3+
4+
function Links() {
5+
6+
function handleClickInventory(){
7+
window.location.href = '/inventory';
8+
}
9+
function handleClickPortfolio(){
10+
window.location.href = '/portfolio';
11+
}
12+
13+
return (
14+
<>
15+
<div className="links-wrapper">
16+
<div className="link" onClick={handleClickInventory}>
17+
<h2>Inventaire</h2>
18+
</div>
19+
20+
<div className="link" onClick={handleClickPortfolio}>
21+
<h2>Historique des évennements</h2>
22+
</div>
23+
24+
</div>
25+
</>
26+
);
27+
}
28+
29+
export default Links;

src/components/LogoutButton.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function LogoutButton() {
2626
}
2727
// Supprimer le token du local storage
2828
localStorage.removeItem('token');
29-
localStorage.removeItem('user_id');
29+
sessionStorage.removeItem('user_id');
3030
setUserId(-1);
3131
setIsAuthenticated(false);
3232
// window.location.href = '/login';

src/context/UserContext.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ export const UserContext = createContext();
55

66
export const UserProvider = ({ children }) => {
77
const [isLoading, setIsLoading] = useState(true);
8-
const [userId, setUserId] = useState(1);
8+
const [userId, setUserId] = useState(-1);
99

1010
useEffect(() => {
1111
const token = localStorage.getItem('token');
1212
const user_id = sessionStorage.getItem('user_id');
1313
if (user_id) {
1414
setUserId(user_id);
15+
console.log(user_id)
1516
setIsLoading(false);
1617
} else if(token){
1718
getUserId(token).then((valid) => {

src/pages/Site.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ import Footer from "../components/Footer"
22
import Son from "../components/Son.jsx";
33
import Main from "../components/Main";
44
import Desc from "../components/Desc"
5+
import Links from "../components/Links"
56
import Lights from "../components/Lights";
67

78

89
function Site(){
910
return(
1011
<>
1112
<Main/>
13+
{/*<Links/>*/}
1214
<Desc/>
1315
<Son/>
1416
<Lights/>

src/style/Links.css

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.links-wrapper{
2+
width: 100vw;
3+
height: 10vh;
4+
display: flex;
5+
flex-direction: row;
6+
flex-wrap: wrap;
7+
justify-content: center;
8+
margin-bottom: 10vh;
9+
}
10+
11+
.links-wrapper > div{
12+
color: white;
13+
margin: 2%;
14+
padding: 1%;
15+
border-radius: 7px;
16+
background-color: black;
17+
border-color: white;
18+
border-width: 10px;
19+
height: auto;
20+
}
21+
22+
.link:hover{
23+
cursor: pointer;
24+
}

0 commit comments

Comments
 (0)