import { createPortal } from 'react-dom'; import { useLocation } from 'react-router-dom'; import { NavLink } from 'react-router-dom'; import styled from '@emotion/styled'; import { TasksSvg, AdminPanelSvg, DictSvg } from '../common/icons/icons'; import { useAuth } from '../../app/context/AuthProvider'; import { ROLES_NAME_ID } from '../../constants'; const Switch = styled.div` margin-left: 1rem; display: flex; align-items: center; justify-content: flex-start; height: 2rem; `; const Buttons = styled.div` width: max-content; height: 1rem; display: flex; flex-direction: row; justify-content: center; align-items: center; gap: 1rem; `; const StyledNavLink = styled(NavLink)` display: flex; gap: 0.625rem; align-items: center; border-radius: 0.5rem; padding: 0rem 0.75rem; cursor: pointer; height: 2rem; .img { svg { width: 1rem; height: 1rem; } } &.active { background-color: #f9fafb; span { color: #258141; } } `; export function HeaderSwitch() { const { user } = useAuth(); const location = useLocation(); const formsTasksPaths = ['/tasks', '/forms']; const adminPathsPrefix = '/admin_panel'; const dictPaths = '/dicts-navigator'; if (!user) return; const portalContent = (
Задачи
{user.role_id === ROLES_NAME_ID.admin && (
Администрирование
)}
Справочники
); const targetElement = document.getElementById('TableInfo'); if (targetElement) { return createPortal(portalContent, targetElement); } }