diff --git a/src/components/layout/app-shell.tsx b/src/components/layout/app-shell.tsx index 9fba4dd..a6d432f 100644 --- a/src/components/layout/app-shell.tsx +++ b/src/components/layout/app-shell.tsx @@ -1,13 +1,25 @@ 'use client' import { usePathname } from 'next/navigation' +import { useEffect, useState } from 'react' import { Sidebar } from '@/components/dashboard/sidebar' +import { useAuth } from '@/hooks/useAuth' export function AppShell({ children }: { children: React.ReactNode }) { const pathname = usePathname() + const { isAuthenticated, isLoading } = useAuth() + const [mounted, setMounted] = useState(false) - const hideSidebar = pathname === '/login' || pathname === '/register' + useEffect(() => { + setMounted(true) + }, []) + + const hideByRoute = + pathname === '/' || pathname?.startsWith('/login') || pathname?.startsWith('/register') + + // До маунта всегда скрываем сайдбар, чтобы избежать гидратационного рассинхрона + const hideSidebar = !mounted || hideByRoute || isLoading || !isAuthenticated return ( <>