}/>}/>*/}
} />
diff --git a/src/components/LoginButton.jsx b/src/components/LoginButton.jsx
new file mode 100644
index 0000000..ee05ca0
--- /dev/null
+++ b/src/components/LoginButton.jsx
@@ -0,0 +1,17 @@
+import { useHref } from 'react-router-dom';
+import { Button } from 'semantic-ui-react';
+
+function LoginButton() {
+
+ function handleClick(){
+ window.location.href = '/login';
+ }
+
+ return (
+
+ );
+}
+
+export default LoginButton;
diff --git a/src/components/LogoutButton.jsx b/src/components/LogoutButton.jsx
index e2c0976..8c79dca 100644
--- a/src/components/LogoutButton.jsx
+++ b/src/components/LogoutButton.jsx
@@ -1,9 +1,12 @@
import { Button } from 'semantic-ui-react';
import { useContext } from "react";
import { AuthContext } from "../context/AuthContext";
+import { UserContext } from "../context/UserContext";
+
function LogoutButton() {
const { setIsAuthenticated } = useContext(AuthContext);
+ const {setUserId} = useContext(UserContext);
const handleLogout = async () => {
try {
@@ -23,8 +26,10 @@ function LogoutButton() {
}
// Supprimer le token du local storage
localStorage.removeItem('token');
+ localStorage.removeItem('user_id');
+ setUserId(-1);
setIsAuthenticated(false);
- window.location.href = '/login';
+ // window.location.href = '/login';
} catch (error) {
console.error('Erreur lors de la déconnexion:', error);
}
diff --git a/src/components/Matos.jsx b/src/components/Matos.jsx
index 3bd7319..5d20757 100644
--- a/src/components/Matos.jsx
+++ b/src/components/Matos.jsx
@@ -2,13 +2,19 @@ import { motion } from "framer-motion"
import TableData from "./TableData";
import '../style/Matos.css'
import LogoutButton from "./LogoutButton";
+import LoginButton from "./LoginButton";
import {MenuItem, Menu, MenuMenu} from "semantic-ui-react";
-import {useEffect, useState} from "react";
+import {useEffect, useState, useContext} from "react";
import HistoryTable from "./History";
+import {AuthContext} from "../context/AuthContext";
function Matos(){
+
+ const {isAuthenticated} = useContext(AuthContext);
+
+
const [activeItem, setActiveItem] = useState(() => {
const savedActiveItem = localStorage.getItem('activeItem');
return savedActiveItem || 'inventaire';
@@ -28,6 +34,9 @@ function Matos(){
Gestion du matériel
{/* menu*/}
-
+ {isAuthenticated?:
+ }
diff --git a/src/components/ModalAdd.jsx b/src/components/ModalAdd.jsx
index 84934fb..eb83749 100644
--- a/src/components/ModalAdd.jsx
+++ b/src/components/ModalAdd.jsx
@@ -53,7 +53,6 @@ function ModalAdd(props) {
/>
-
>
);
diff --git a/src/components/Stats.jsx b/src/components/Stats.jsx
index d3d71cf..510411e 100644
--- a/src/components/Stats.jsx
+++ b/src/components/Stats.jsx
@@ -1,12 +1,16 @@
-import React from 'react';
+import {React,useContext} from 'react';
import {
StatisticValue,
StatisticLabel,
StatisticGroup,
Statistic,
} from 'semantic-ui-react';
+import {AuthContext} from "../context/AuthContext";
function Stats(props) {
+ const {isAuthenticated} = useContext(AuthContext);
+
+
return (
@@ -18,7 +22,9 @@ function Stats(props) {
{props.qte === null ? 0 : props.qte}
Quantité totale
-
+ {isAuthenticated?
+ <>
+
{props.total_price === null ? 0 : props.total_price}
Prix total
@@ -26,6 +32,9 @@ function Stats(props) {
{props.power === null ? 0 : props.total_power}
Puissance totale
+ >
+ : null}
+
);
diff --git a/src/components/TableData.jsx b/src/components/TableData.jsx
index b3b5329..31c6520 100644
--- a/src/components/TableData.jsx
+++ b/src/components/TableData.jsx
@@ -1,5 +1,6 @@
import React, {useCallback, useEffect, useRef, useState, useContext} from 'react';
import {UserContext} from "../context/UserContext";
+import {AuthContext} from "../context/AuthContext";
import * as XLSX from 'xlsx';
import {
Search,
@@ -21,8 +22,11 @@ import ModalSuccess from "./ModalSuccess";
import ModalFailed from "./ModalFailed";
import TableSelectedItems from "./TableSelectedItems";
+
+
function TableData() {
const {userId} = useContext(UserContext);
+ const {isAuthenticated} = useContext(AuthContext);
const [state, setState] = useState({ isLoading: false, results: [], value: '' });
const [tableData, setTableData] = useState([]);
const [filteredData, setFilteredData] = useState([]);
@@ -49,6 +53,10 @@ function TableData() {
const [supp, setSuppr] = useState('Date de suppression');
+ console.log(isAuthenticated)
+ console.log(userId)
+
+
useEffect(() => {
if (isLargeScreen) {
@@ -560,10 +568,10 @@ const handleDeselectButton = () => {
/>