import { useState } from "react"; import { Box, Typography, Button, useTheme } from "@mui/material"; import { Link, useLocation } from "react-router-dom"; import { DropDownMenu } from "./DropDownMenu"; export type MenuItem = { name: string; url: string; subMenu?: MenuItem[]; }; export default function Menu() { const [activeSubMenu, setActiveSubMenu] = useState([]); const [anchorElement, setAnchorElement] = useState(null); const [dropDownItems, setDropDownItems] = useState([]); const theme = useTheme(); const location = useLocation(); const color = location.pathname === "/" ? "white" : "black"; const arrayMenu: MenuItem[] = location.pathname === "/" ? [ { name: "Наши продукты", url: "/faq", subMenu: [{ name: "PenaQuiz", url: "https://squiz.pena.digital" }], }, { name: "Наши услуги", url: "/cart", subMenu: [ { name: "Все услуги", url: "https://pena.digital" }, { name: "Разработка Landing Page", url: "https://pena.digital/landings", }, { name: "Разработка мобильных приложений", url: "https://pena.digital/mobileapps", }, { name: "Разработка корпоративных сайтов", url: "https://pena.digital/corporatesites", }, { name: "DevOps & CloudOps", url: "https://pena.digital/devops", }, { name: "Разработка Cloud-Native приложений", url: "https://pena.digital/cloudnative", }, { name: "UX/UI дизайн", url: "https://pena.digital/design", }, { name: "Разработка CRM-систем", url: "https://pena.digital/crmsystems", }, ], }, ] : [ { name: "Тарифы", url: "/tariffs", subMenu: [ { name: "Тарифы на время", url: "/tariffs/time" }, { name: "Тарифы на объём", url: "/tariffs/volume" }, { name: "Мой тариф", url: "/tariffconstructor" }, ], }, { name: "FAQ", url: "/faq" }, { name: "Корзина", url: "/cart" }, { name: "Поддержка", url: "/support" }, { name: "История", url: "/history" }, ]; return ( {location.pathname !== "/" ? arrayMenu.map(({ name, url, subMenu = [] }) => ( setActiveSubMenu(subMenu)} state={{ previousUrl: location.pathname }} > {name} )) : arrayMenu.map(({ name, url, subMenu = [] }, index) => ( ))} setActiveSubMenu([])} > {location.pathname !== "/" && activeSubMenu.map(({ name, url }) => ( {name} ))} ); }