diff --git a/src/layouts/AdminLayout.tsx b/src/layouts/AdminLayout.tsx index 9b84e5b..f313cc5 100644 --- a/src/layouts/AdminLayout.tsx +++ b/src/layouts/AdminLayout.tsx @@ -4,15 +4,13 @@ import { BarChartOutlined, CameraOutlined, LogoutOutlined, - MenuOutlined, OrderedListOutlined, UserOutlined, } from '@ant-design/icons' -import { Avatar, Button, Drawer, Layout, Menu, Result, Space, Tag, Typography } from 'antd' +import { Avatar, Button, Grid, Layout, Menu, Result, Space, Tag, Typography } from 'antd' import { Outlet, useLocation, useNavigate } from 'react-router-dom' import { ROLE_MANAGE_AREA, ROLE_MANAGE_ATTRACTION } from '@/auth/roles' import { useAuth } from '@/auth/AuthContext' -import { useIsMobile } from '@/hooks/useIsMobile' const { Header, Sider, Content } = Layout @@ -25,20 +23,15 @@ export function AdminLayout() { const { email, roles, logout } = useAuth() const location = useLocation() const navigate = useNavigate() - const isMobile = useIsMobile() - const [menuOpen, setMenuOpen] = useState(false) + const screens = Grid.useBreakpoint() + // Узкие экраны/панели: без текста в шапке, контент с меньшими отступами. + const isNarrow = !screens.md // < 768 + const isCompactHeader = !screens.lg // < 992 + const [collapsed, setCollapsed] = useState(false) const hasManageArea = roles.includes(ROLE_MANAGE_AREA) const hasManageAttraction = roles.includes(ROLE_MANAGE_ATTRACTION) - // При переходе десктоп↔мобильный открытый Drawer теряет смысл — сбрасываем - // во время рендера (паттерн «adjust state when props change» из доков React). - const [wasMobile, setWasMobile] = useState(isMobile) - if (wasMobile !== isMobile) { - setWasMobile(isMobile) - setMenuOpen(false) - } - if (!hasManageArea && !hasManageAttraction) { return ( { - navigate(key) - setMenuOpen(false) - }} - style={{ borderRight: 0, paddingTop: 8 }} - /> - ) - - const roleTags = ( - - {roles - .filter((role) => ROLE_LABELS[role]) - .map((role) => ( - - {ROLE_LABELS[role]} - - ))} - - ) - return (
- {isMobile ? ( - <> - - - - - - )} + > + {isNarrow ? null : 'Выйти'} + + +
- {isMobile ? ( - setMenuOpen(false)} - styles={{ body: { padding: 0 } }} - > -
- - } /> - - {email} - - -
{roleTags}
-
- {menu} -
- ) : ( - - {menu} - - )} - + {/* Сайдбар сворачивается до иконок автоматически ниже md и вручную тумблером снизу. */} + + navigate(key)} + style={{ height: '100%', borderRight: 0, paddingTop: 8 }} + /> + + diff --git a/src/pages/attractions/PhotoGallery.tsx b/src/pages/attractions/PhotoGallery.tsx index 0eadf5c..25ae5eb 100644 --- a/src/pages/attractions/PhotoGallery.tsx +++ b/src/pages/attractions/PhotoGallery.tsx @@ -196,9 +196,9 @@ export function PhotoGallery({ cover={ } > diff --git a/src/pages/visits/VisitListPage.tsx b/src/pages/visits/VisitListPage.tsx index c6e45e9..06757ed 100644 --- a/src/pages/visits/VisitListPage.tsx +++ b/src/pages/visits/VisitListPage.tsx @@ -115,7 +115,7 @@ export function VisitListPage() {