Исправлена кнопка входа/выхода с админки

This commit is contained in:
goodmice 2021-12-02 15:49:41 +05:00
parent 58cc1dc714
commit f17d39318c
3 changed files with 18 additions and 8 deletions

View File

@ -9,9 +9,9 @@ type LayoutPortalProps = {
export const AdminLayoutPortal: React.FC<LayoutPortalProps> = ({title, ...props}) => (
<Layout.Content>
<PageHeader title={title}>
<PageHeader isAdmin title={title} style={{ backgroundColor: '#900' }}>
<Button size={'large'}>
<Link to={'/'}>Вернуться на основной сайт</Link>
<Link to={'/'}>Вернуться на сайт</Link>
</Button>
</PageHeader>
<Layout>

View File

@ -5,19 +5,21 @@ import { UserMenu } from './UserMenu'
import logo from '../images/logo_32.png'
type PageHeaderProps = {
children?: React.ReactNode
title?: string
isAdmin?: boolean
children?: React.ReactNode
[other: string]: any
}
export const PageHeader: React.FC<PageHeaderProps> = ({ children, title = 'Мониторинг' }) => (
export const PageHeader: React.FC<PageHeaderProps> = ({ title = 'Мониторинг', isAdmin, children, ...other }) => (
<Layout>
<Layout.Header className={'header'}>
<Layout.Header className={'header'} {...other}>
<Link to={'/'} style={{ height: headerHeight }}>
<img src={logo} alt={'АСБ'} className={'logo'}/>
</Link>
{children}
<h1 className={'title'}>{title}</h1>
<UserMenu />
<UserMenu isAdmin={isAdmin} />
</Layout.Header>
</Layout>
)

View File

@ -16,7 +16,11 @@ const handleLogout = () => {
const formLayout: FormProps = { labelCol: { span: 11 }, wrapperCol: { span: 16 } }
export const UserMenu: React.FC = () => {
type UserMenuProps = {
isAdmin?: boolean
}
export const UserMenu: React.FC<UserMenuProps> = ({ isAdmin }) => {
const [form] = useForm()
const [isModalVisible, setIsModalVisible] = useState<boolean>(false)
const [showLoader, setShowLoader] = useState<boolean>(false)
@ -50,7 +54,11 @@ export const UserMenu: React.FC = () => {
overlay={(
<Menu style={{ textAlign: 'right' }}>
<PrivateMenuItem roles={['admin']}>
<Link to={'/admin'} onClick={() => {}}>Панель администратора</Link>
{isAdmin ? (
<Link to={'/'}>Вернуться на сайт</Link>
) : (
<Link to={'/admin'}>Панель администратора</Link>
)}
</PrivateMenuItem>
<Menu.Item>
<Link to={'/'} onClick={onChangePasswordClick}>Сменить пароль</Link>