diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 8f718150..cd092d98 100755 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from "react"; +import React, { useState, useEffect, useContext } from "react"; import { Link, Route, Routes, BrowserRouter, useNavigate } from "react-router-dom"; import { CookiesProvider } from "react-cookie"; @@ -12,7 +12,7 @@ import Header from "./components/NewHeader.jsx"; import HealthPage from "./components/HealthPage.jsx"; //import Header from "./components/Header.jsx"; -import theme from "./theme.jsx"; +import theme, { getTheme } from "./theme.jsx"; import Apps from "./views/Apps.jsx"; import Apps2 from "./views/Apps2.jsx"; import AppCreator from "./views/AppCreator.jsx"; @@ -63,7 +63,7 @@ import 'react-toastify/dist/ReactToastify.css'; import Drift from "react-driftjs"; -import { AppContext } from './context/ContextApi.jsx'; +import { Context } from './context/ContextApi.jsx'; import Navbar from "./components/Navbar.jsx"; import Workflows2 from "./views/Workflows2.jsx"; import AppExplorer from "./views/AppExplorer.jsx"; @@ -92,7 +92,10 @@ const App = (message, props) => { const [dataset, setDataset] = useState(false) const [isLoaded, setIsLoaded] = useState(false) const [curpath, setCurpath] = useState(typeof window === "undefined" || window.location === undefined ? "" : window.location.pathname) - + const { themeMode, handleThemeChange } = useContext(Context); + const currentTheme = getTheme(themeMode); + const mainColor = currentTheme?.palette?.backgroundColor + const [isPreviousThemeLight, setIsPreviousThemeLight] = useState(false) useEffect(() => { if (dataset === false) { @@ -102,6 +105,20 @@ const App = (message, props) => { } }, []); + useEffect(() => { + const isDarkPath = curpath === "/" || curpath === "/pricing" || curpath === "/partners" || curpath === "/faq" || curpath === "/professional-services" || curpath === "/contact" || curpath === "/training"; + if (curpath && isDarkPath) { + if (themeMode === "light") { + setIsPreviousThemeLight(true) + } + handleThemeChange("dark") + }else if ( !isDarkPath && isPreviousThemeLight && userdata?.active_org?.branding?.theme === "light") { + handleThemeChange("light") + setIsPreviousThemeLight(false) + } + +}, [themeMode, curpath, userdata]) + if ( isLoaded && !isLoggedIn && @@ -189,7 +206,7 @@ const App = (message, props) => { const includedData =