2021-12-20 13:29:51 +01:00
|
|
|
// @flow
|
2022-04-27 14:54:02 +02:00
|
|
|
import * as PAGES from 'constants/pages';
|
2021-12-20 13:29:51 +01:00
|
|
|
import React from 'react';
|
2022-04-27 14:54:02 +02:00
|
|
|
import { Link, useHistory } from 'react-router-dom';
|
|
|
|
import { MenuLink, MenuItem } from '@reach/menu-button';
|
2021-12-20 13:29:51 +01:00
|
|
|
import Icon from 'component/common/icon';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
icon: string,
|
|
|
|
name: string,
|
|
|
|
page: string,
|
2022-04-27 14:54:02 +02:00
|
|
|
requiresAuth?: boolean,
|
2021-12-20 13:29:51 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function HeaderMenuLink(props: Props) {
|
2022-04-27 14:54:02 +02:00
|
|
|
const { icon, name, page, requiresAuth } = props;
|
|
|
|
|
|
|
|
const { push } = useHistory();
|
|
|
|
|
|
|
|
if (requiresAuth) {
|
|
|
|
return (
|
|
|
|
<MenuItem className="menu__link" onSelect={() => push(`/$/${PAGES.AUTH}`)}>
|
|
|
|
<Icon aria-hidden icon={icon} />
|
|
|
|
{name}
|
|
|
|
</MenuItem>
|
|
|
|
);
|
|
|
|
}
|
2021-12-20 13:29:51 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<MenuLink className="menu__link" as={Link} to={`/$/${page}`}>
|
|
|
|
<Icon aria-hidden icon={icon} />
|
|
|
|
{name}
|
|
|
|
</MenuLink>
|
|
|
|
);
|
|
|
|
}
|