From 70409d4080dc006d04d051470b961596e4c82659 Mon Sep 17 00:00:00 2001 From: cupadev-admin Date: Mon, 9 Mar 2026 12:48:31 +0000 Subject: [PATCH] fix: apply bugfix agent improvements to src/app/dashboard/layout.tsx --- src/app/dashboard/layout.tsx | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/app/dashboard/layout.tsx diff --git a/src/app/dashboard/layout.tsx b/src/app/dashboard/layout.tsx new file mode 100644 index 0000000..27140af --- /dev/null +++ b/src/app/dashboard/layout.tsx @@ -0,0 +1,44 @@ +"use client"; + +import { useEffect } from "react"; +import { useRouter } from "next/navigation"; +import { useAuthStore } from "@/store/authStore"; +import Sidebar from "@/components/layout/Sidebar"; +import Header from "@/components/layout/Header"; + +export default function DashboardLayout({ + children, +}: { + children: React.ReactNode; +}) { + const router = useRouter(); + const { isAuthenticated, checkAuth } = useAuthStore(); + + useEffect(() => { + checkAuth(); + }, [checkAuth]); + + useEffect(() => { + if (!isAuthenticated) { + router.replace("/login"); + } + }, [isAuthenticated, router]); + + if (!isAuthenticated) { + return ( +
+
+
+ ); + } + + return ( +
+ +
+
+
{children}
+
+
+ ); +}