diff --git a/src/components/common/NavBar.jsx b/src/components/common/NavBar.jsx
index 2df19d1..d6942f2 100644
--- a/src/components/common/NavBar.jsx
+++ b/src/components/common/NavBar.jsx
@@ -8,6 +8,8 @@ import Goals from "../shared/Goals";
import SnackbarAlert from "./SnackBarAlert";
import { getApiUrl } from "../../assets/getApi";
import MyAccountDialog from "../shared/MyAccount";
+import InactivityDetector from "../shared/InactivityDetector";
+
// Material-UI
import {
Box,
@@ -306,6 +308,7 @@ const Navbar = () => {
return (
<>
+
>
diff --git a/src/components/shared/InactivityDetector.jsx b/src/components/shared/InactivityDetector.jsx
new file mode 100644
index 0000000..c11ee6a
--- /dev/null
+++ b/src/components/shared/InactivityDetector.jsx
@@ -0,0 +1,39 @@
+import { useEffect } from "react";
+
+const InactivityDetector = ({ handleLogout }) => {
+ useEffect(() => {
+ let inactivityTimeout;
+
+ const resetInactivityTimeout = () => {
+ clearTimeout(inactivityTimeout);
+ inactivityTimeout = setTimeout(() => {
+ handleLogout();
+ }, 150000); // Adjust the timeout value as needed (in milliseconds)
+ };
+
+ const handleActivity = () => {
+ console.log("User activity detected");
+ resetInactivityTimeout();
+ };
+
+ // Add event listeners to detect user activity
+ window.addEventListener("mousemove", handleActivity);
+ window.addEventListener("keydown", handleActivity);
+ window.addEventListener("scroll", handleActivity);
+ window.addEventListener("click", handleActivity);
+
+ // Start the inactivity timeout on component mount
+ resetInactivityTimeout();
+
+ // Clean up event listeners on component unmount
+ return () => {
+ clearTimeout(inactivityTimeout);
+ window.removeEventListener("mousemove", handleActivity);
+ window.removeEventListener("scroll", handleActivity);
+ window.removeEventListener("click", handleActivity);
+ window.removeEventListener("keydown", handleActivity);
+ };
+ }, []);
+};
+
+export default InactivityDetector;
diff --git a/src/components/shared/InactivivyDetector.jsx b/src/components/shared/InactivivyDetector.jsx
deleted file mode 100644
index e69de29..0000000
diff --git a/src/main.jsx b/src/main.jsx
index 829d11e..09983c5 100644
--- a/src/main.jsx
+++ b/src/main.jsx
@@ -36,6 +36,7 @@ import MyPayslips from "./components/pages/MyPayslips";
import SwiperSlider from "./components/shared/SwiperSlider";
import EmploymentCertification from "./components/pages/EmploymentCertification";
import ImageMagnifier from "./components/pages/ImageMagnifier";
+import InactivityDetector from "./components/shared/InactivityDetector";
const theme = createTheme({
typography: {
@@ -85,7 +86,7 @@ const router = createBrowserRouter([
},
{
path: "test",
- element: ,
+ element: ,
},
{
path: "/logged",