diff --git a/Frontend/src/App.css b/Frontend/src/App.css
index f5dfa4f..2389c8f 100644
--- a/Frontend/src/App.css
+++ b/Frontend/src/App.css
@@ -8,6 +8,24 @@ body {
height: 100vh;
}
+body.light-mode {
+ --background-color: #ffffff;
+ --text-color: #000000;
+ font-family: Arial, sans-serif;
+}
+
+body.dark-mode {
+ --background-color: #121212;
+ --text-color: #ffffff;
+ font-family: Arial, sans-serif;
+
+}
+
+body {
+ background-color: var(--background-color);
+ color: var(--text-color);
+}
+
.app-container {
text-align: center;
width: 100%;
diff --git a/Frontend/src/App.js b/Frontend/src/App.js
index af4674a..a36b7be 100644
--- a/Frontend/src/App.js
+++ b/Frontend/src/App.js
@@ -10,6 +10,7 @@ import UserDashboard from "./UserDashboard";
import Payments from "./Payment";
import ApprovePayment from "./ApprovePayments";
import "./App.css";
+import { ThemeProvider } from "./ThemeContext";
function NavBar() {
const location = useLocation();
@@ -24,6 +25,7 @@ function NavBar() {
};
return (
+
+
);
}
@@ -116,6 +119,7 @@ ProtectedRoute.propTypes = {
function App() {
return (
+
@@ -134,6 +138,7 @@ function App() {
} />
+
);
}
diff --git a/Frontend/src/EmployeeDashboard.js b/Frontend/src/EmployeeDashboard.js
index f2eff6b..05c90e0 100644
--- a/Frontend/src/EmployeeDashboard.js
+++ b/Frontend/src/EmployeeDashboard.js
@@ -1,9 +1,10 @@
-import React, { useState, useEffect } from "react";
+import React, { useContext, useState, useEffect } from "react";
import { useNavigate } from "react-router-dom";
-
+import { ThemeContext } from './ThemeContext';
function EmployeeDashboard() {
const [setMessage] = useState("");
+ const { isDarkMode, toggleTheme } = useContext(ThemeContext);
const navigate = useNavigate();
useEffect(() => {
const accountNumber = localStorage.getItem("accNo");
@@ -18,6 +19,9 @@ function EmployeeDashboard() {
return (
Welcome to the Employee Dashboard
+
);
}
diff --git a/Frontend/src/ThemeContext.js b/Frontend/src/ThemeContext.js
new file mode 100644
index 0000000..faa5548
--- /dev/null
+++ b/Frontend/src/ThemeContext.js
@@ -0,0 +1,31 @@
+import React, { createContext, useState, useEffect } from 'react';
+
+export const ThemeContext = createContext();
+
+export function ThemeProvider({ children }) {
+ const [isDarkMode, setIsDarkMode] = useState(() => {
+ return localStorage.getItem('theme') === 'dark';
+ });
+
+ useEffect(() => {
+ const themeClass = isDarkMode ? 'dark-mode' : 'light-mode';
+ document.body.classList.add(themeClass);
+
+ // Remove the opposite theme class to prevent conflicts
+ document.body.classList.remove(isDarkMode ? 'light-mode' : 'dark-mode');
+
+ // Update localStorage
+ localStorage.setItem('theme', isDarkMode ? 'dark' : 'light');
+ }, [isDarkMode]);
+
+ const toggleTheme = () => {
+ setIsDarkMode((prevMode) => !prevMode);
+ };
+
+ return (
+
+ {children}
+
+ );
+}
+
diff --git a/Frontend/src/UserDashboard.js b/Frontend/src/UserDashboard.js
index 80e90cd..6bd68c9 100644
--- a/Frontend/src/UserDashboard.js
+++ b/Frontend/src/UserDashboard.js
@@ -1,9 +1,11 @@
-import React, { useState, useEffect } from "react";
+import React, { useState, useEffect, useContext } from "react";
import { useNavigate } from "react-router-dom";
+import { ThemeContext } from './ThemeContext';
function UserDashboard() {
const [setMessage] = useState("");
+ const { isDarkMode, toggleTheme } = useContext(ThemeContext);
const navigate = useNavigate();
useEffect(() => {
const accountNumber = localStorage.getItem("accNo");
@@ -18,6 +20,9 @@ function UserDashboard() {
return (
Welcome to the Dashboard
+
);
}