Skip to content

Commit

Permalink
added links part
Browse files Browse the repository at this point in the history
  • Loading branch information
leopoldch committed Mar 15, 2024
1 parent 8f464f7 commit 961e7ce
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 2 deletions.
29 changes: 29 additions & 0 deletions src/components/Links.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import "../style/Links.css";


function Links() {

function handleClickInventory(){
window.location.href = '/inventory';
}
function handleClickPortfolio(){
window.location.href = '/portfolio';
}

return (
<>
<div className="links-wrapper">
<div className="link" onClick={handleClickInventory}>
<h2>Inventaire</h2>
</div>

<div className="link" onClick={handleClickPortfolio}>
<h2>Historique des évennements</h2>
</div>

</div>
</>
);
}

export default Links;
2 changes: 1 addition & 1 deletion src/components/LogoutButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function LogoutButton() {
}
// Supprimer le token du local storage
localStorage.removeItem('token');
localStorage.removeItem('user_id');
sessionStorage.removeItem('user_id');
setUserId(-1);
setIsAuthenticated(false);
// window.location.href = '/login';
Expand Down
3 changes: 2 additions & 1 deletion src/context/UserContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ export const UserContext = createContext();

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

useEffect(() => {
const token = localStorage.getItem('token');
const user_id = sessionStorage.getItem('user_id');
if (user_id) {
setUserId(user_id);
console.log(user_id)
setIsLoading(false);
} else if(token){
getUserId(token).then((valid) => {
Expand Down
2 changes: 2 additions & 0 deletions src/pages/Site.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import Footer from "../components/Footer"
import Son from "../components/Son.jsx";
import Main from "../components/Main";
import Desc from "../components/Desc"
import Links from "../components/Links"
import Lights from "../components/Lights";


function Site(){
return(
<>
<Main/>
{/*<Links/>*/}
<Desc/>
<Son/>
<Lights/>
Expand Down
24 changes: 24 additions & 0 deletions src/style/Links.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.links-wrapper{
width: 100vw;
height: 10vh;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
margin-bottom: 10vh;
}

.links-wrapper > div{
color: white;
margin: 2%;
padding: 1%;
border-radius: 7px;
background-color: black;
border-color: white;
border-width: 10px;
height: auto;
}

.link:hover{
cursor: pointer;
}

0 comments on commit 961e7ce

Please sign in to comment.