import { Link } from "react-router-dom";
import PropTypes from "prop-types";
import { useTranslation } from "react-i18next";
import clsx from "clsx";
import { useState } from "react";
function SubMenu({ items, isVisible, onLinkClick }) {
const { t } = useTranslation();
return (
{items.map((subItem, index) => (
{t(subItem.name)}
))}
);
}
function MenuBar({ menuItems }) {
const { t } = useTranslation();
const [activeMenu, setActiveMenu] = useState(null);
return (
{menuItems.map((item, index) => (
setActiveMenu(index)}
onMouseLeave={() => setActiveMenu(null)}
>
{t(item.name)}
{item.submenu.length > 0 && setActiveMenu(null)}/>}
))}
);
}
MenuBar.propTypes = {
menuItems: PropTypes.arrayOf(
PropTypes.shape({
name: PropTypes.string.isRequired,
submenu: PropTypes.arrayOf(
PropTypes.shape({
name: PropTypes.string.isRequired,
path: PropTypes.string.isRequired,
})
),
path: PropTypes.string,
})
).isRequired,
};
SubMenu.propTypes = {
items: PropTypes.arrayOf(
PropTypes.shape({
name: PropTypes.string.isRequired,
path: PropTypes.string.isRequired,
})
).isRequired,
isVisible: PropTypes.bool.isRequired,
onLinkClick: PropTypes.func.isRequired,
};
export default MenuBar;