From 8d80123ad3b0bb4ea681abacced0b19616b9710b Mon Sep 17 00:00:00 2001 From: Sakindu Ransindu Date: Sat, 16 Nov 2024 08:14:55 +0530 Subject: [PATCH] fix themes --- next.config.ts | 1 + src/app/admin/admin-dashboard-layout.tsx | 20 +++--- src/app/layout.tsx | 84 ++++++++++++------------ src/components/ui/floating-navbar.tsx | 33 ++++++---- src/interfaces/IThemeContext.ts | 7 ++ 5 files changed, 83 insertions(+), 62 deletions(-) create mode 100644 src/interfaces/IThemeContext.ts diff --git a/next.config.ts b/next.config.ts index b4f1d0c..f8f0e1e 100644 --- a/next.config.ts +++ b/next.config.ts @@ -2,6 +2,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { output: process.env.NODE_ENV === 'production' ? 'export' : undefined, + trailingSlash: true, images: { unoptimized: true, remotePatterns: [ diff --git a/src/app/admin/admin-dashboard-layout.tsx b/src/app/admin/admin-dashboard-layout.tsx index d4aba40..796a9c6 100644 --- a/src/app/admin/admin-dashboard-layout.tsx +++ b/src/app/admin/admin-dashboard-layout.tsx @@ -10,6 +10,7 @@ import { MoonIcon, SunIcon } from "@heroicons/react/24/solid"; import LOGO_SMALL from "../../../public/Images/logo/RUR20_small.png"; import { useAuth } from "@/context/auth-provider"; import { useRouter } from "next/navigation"; +import { IThemeContextType } from "@/interfaces/IThemeContext"; interface AdminDashboardLayoutProps { children: ReactNode; @@ -46,12 +47,13 @@ function Navbar({ className }: { className?: string }) { const router = useRouter(); const [active, setActive] = useState(null); - const [tougleTheme, currentTheme] = useContext(ThemeContext); - - const handleLogout = async () => { - await logOut(); - router.push("/admin/"); + const themeContext = useContext(ThemeContext); + if (!themeContext) { + throw new Error("ThemeToggleButton must be used within a ThemeContext.Provider"); } + const { toggleTheme, theme } = themeContext; + + return (
@@ -64,14 +66,16 @@ function Navbar({ className }: { className?: string }) { + + - + {user && } + + {/*