update layout

This commit is contained in:
2026-04-28 14:20:29 +07:00
parent 9006adbb70
commit e0608eb05b
5 changed files with 63 additions and 143 deletions
+11 -6
View File
@@ -8,6 +8,7 @@ import { apiGetCurrentUser } from "@/service/auth";
import { setUserData } from "@/store/features/userSlice";
import React, { useEffect } from "react";
import { useDispatch } from "react-redux";
import { usePathname } from "next/navigation";
export default function AdminLayout({
children,
@@ -16,6 +17,8 @@ export default function AdminLayout({
}) {
const { isExpanded, isHovered, isMobileOpen } = useSidebar();
const dispatch = useDispatch()
const pathname = usePathname();
const isHomePage = pathname === "/";
useEffect(() => {
const fetchUser = async () => {
@@ -31,17 +34,19 @@ export default function AdminLayout({
// Dynamic class for main content margin based on sidebar state
const mainContentMargin = isMobileOpen
const mainContentMargin = isHomePage
? "ml-0"
: isExpanded || isHovered
? "lg:ml-[290px]"
: "lg:ml-[90px]";
: isMobileOpen
? "ml-0"
: isExpanded || isHovered
? "lg:ml-[290px]"
: "lg:ml-[90px]";
return (
<div className="min-h-screen xl:flex">
{/* Sidebar and Backdrop */}
<AppSidebar />
<Backdrop />
{!isHomePage && <AppSidebar />}
{!isHomePage && <Backdrop />}
{/* Main Content Area */}
<div
className={`flex-1 transition-all duration-300 ease-in-out ${mainContentMargin}`}