2024-01-15 15:54:33 +00:00
|
|
|
|
import { useState } from "react";
|
|
|
|
|
import { Box, Typography, Button, useTheme } from "@mui/material";
|
|
|
|
|
import { Link, useLocation } from "react-router-dom";
|
|
|
|
|
|
|
|
|
|
import { DropDownMenu } from "./DropDownMenu";
|
2023-03-27 12:45:44 +00:00
|
|
|
|
|
2024-01-15 16:01:39 +00:00
|
|
|
|
export type MenuItem = {
|
2023-07-25 22:31:04 +00:00
|
|
|
|
name: string;
|
|
|
|
|
url: string;
|
|
|
|
|
subMenu?: MenuItem[];
|
|
|
|
|
};
|
|
|
|
|
|
2023-03-27 12:45:44 +00:00
|
|
|
|
export default function Menu() {
|
2024-01-15 15:54:33 +00:00
|
|
|
|
const [activeSubMenu, setActiveSubMenu] = useState<MenuItem[]>([]);
|
|
|
|
|
const [anchorElement, setAnchorElement] = useState<HTMLElement | null>(null);
|
|
|
|
|
const [dropDownItems, setDropDownItems] = useState<MenuItem[]>([]);
|
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const location = useLocation();
|
2023-03-27 12:45:44 +00:00
|
|
|
|
|
2024-01-15 15:54:33 +00:00
|
|
|
|
const color = location.pathname === "/" ? "white" : "black";
|
2023-03-27 12:45:44 +00:00
|
|
|
|
|
2024-01-15 15:54:33 +00:00
|
|
|
|
const arrayMenu: MenuItem[] =
|
|
|
|
|
location.pathname === "/"
|
|
|
|
|
? [
|
|
|
|
|
{
|
|
|
|
|
name: "Наши продукты",
|
|
|
|
|
url: "/faq",
|
2024-01-17 19:22:15 +00:00
|
|
|
|
subMenu: [{ name: "PenaQuiz", url: "https://quiz.pena.digital" }],
|
2024-01-15 15:54:33 +00:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Наши услуги",
|
|
|
|
|
url: "/cart",
|
|
|
|
|
subMenu: [
|
|
|
|
|
{ name: "Все услуги", url: "https://pena.digital" },
|
|
|
|
|
{
|
|
|
|
|
name: "Разработка Landing Page",
|
2024-01-16 16:23:21 +00:00
|
|
|
|
url: "https://pena.digital/landings",
|
2024-01-15 15:54:33 +00:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Разработка мобильных приложений",
|
2024-01-16 16:23:21 +00:00
|
|
|
|
url: "https://pena.digital/mobileapps",
|
2024-01-15 15:54:33 +00:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Разработка корпоративных сайтов",
|
2024-01-16 16:23:21 +00:00
|
|
|
|
url: "https://pena.digital/corporatesites",
|
2024-01-15 15:54:33 +00:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "DevOps & CloudOps",
|
2024-01-16 16:23:21 +00:00
|
|
|
|
url: "https://pena.digital/devops",
|
2024-01-15 15:54:33 +00:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Разработка Cloud-Native приложений",
|
2024-01-16 16:23:21 +00:00
|
|
|
|
url: "https://pena.digital/cloudnative",
|
2024-01-15 15:54:33 +00:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "UX/UI дизайн",
|
2024-01-16 16:23:21 +00:00
|
|
|
|
url: "https://pena.digital/design",
|
2024-01-15 15:54:33 +00:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Разработка CRM-систем",
|
2024-01-16 16:23:21 +00:00
|
|
|
|
url: "https://pena.digital/crmsystems",
|
2024-01-15 15:54:33 +00:00
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
: [
|
|
|
|
|
{
|
|
|
|
|
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" },
|
|
|
|
|
];
|
2023-10-27 23:13:54 +00:00
|
|
|
|
|
2024-01-15 15:54:33 +00:00
|
|
|
|
return (
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
height: "100%",
|
|
|
|
|
gap: "30px",
|
2024-01-16 19:37:49 +00:00
|
|
|
|
ml: "51px",
|
2024-01-15 15:54:33 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{location.pathname !== "/"
|
|
|
|
|
? arrayMenu.map(({ name, url, subMenu = [] }) => (
|
|
|
|
|
<Link
|
|
|
|
|
key={name}
|
|
|
|
|
style={{
|
|
|
|
|
textDecoration: "none",
|
|
|
|
|
height: "100%",
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
}}
|
|
|
|
|
to={url}
|
2024-01-17 19:22:15 +00:00
|
|
|
|
target="_blank"
|
2024-01-15 15:54:33 +00:00
|
|
|
|
onMouseEnter={() => setActiveSubMenu(subMenu)}
|
|
|
|
|
state={{ previousUrl: location.pathname }}
|
|
|
|
|
>
|
|
|
|
|
<Typography
|
2024-01-16 19:24:09 +00:00
|
|
|
|
color={location.pathname === url ? theme.palette.purple.main : color}
|
2024-01-15 15:54:33 +00:00
|
|
|
|
variant="body2"
|
|
|
|
|
sx={{
|
|
|
|
|
whiteSpace: "nowrap",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{name}
|
|
|
|
|
</Typography>
|
|
|
|
|
</Link>
|
|
|
|
|
))
|
|
|
|
|
: arrayMenu.map(({ name, url, subMenu = [] }, index) => (
|
|
|
|
|
<Button
|
|
|
|
|
sx={{
|
|
|
|
|
whiteSpace: "nowrap",
|
2024-01-16 19:24:09 +00:00
|
|
|
|
color: location.pathname === url ? theme.palette.purple.main : color,
|
2024-01-15 15:54:33 +00:00
|
|
|
|
}}
|
|
|
|
|
onClick={({ currentTarget }) => {
|
|
|
|
|
setAnchorElement(currentTarget);
|
|
|
|
|
setDropDownItems(subMenu);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{name}
|
|
|
|
|
</Button>
|
|
|
|
|
))}
|
2024-01-16 19:24:09 +00:00
|
|
|
|
<DropDownMenu anchorElement={anchorElement} setAnchorElement={setAnchorElement} items={dropDownItems} />
|
2024-01-15 15:54:33 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
zIndex: "10",
|
|
|
|
|
position: "absolute",
|
|
|
|
|
top: "80px",
|
|
|
|
|
left: 0,
|
|
|
|
|
backgroundColor: theme.palette.background.paper,
|
|
|
|
|
width: "100%",
|
|
|
|
|
}}
|
|
|
|
|
onMouseLeave={() => setActiveSubMenu([])}
|
|
|
|
|
>
|
|
|
|
|
{location.pathname !== "/" &&
|
2023-08-08 15:47:02 +00:00
|
|
|
|
activeSubMenu.map(({ name, url }) => (
|
2024-01-15 15:54:33 +00:00
|
|
|
|
<Link key={name} style={{ textDecoration: "none" }} to={url}>
|
|
|
|
|
<Typography
|
2024-01-16 19:24:09 +00:00
|
|
|
|
color={location.pathname === url ? theme.palette.purple.main : color}
|
2024-01-15 15:54:33 +00:00
|
|
|
|
variant="body2"
|
|
|
|
|
sx={{
|
|
|
|
|
padding: "15px",
|
|
|
|
|
whiteSpace: "nowrap",
|
|
|
|
|
paddingLeft: "185px",
|
|
|
|
|
"&:hover": {
|
|
|
|
|
color: theme.palette.purple.main,
|
|
|
|
|
background: theme.palette.background.default,
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{name}
|
|
|
|
|
</Typography>
|
|
|
|
|
</Link>
|
2023-08-08 15:47:02 +00:00
|
|
|
|
))}
|
2024-01-15 15:54:33 +00:00
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
);
|
2023-03-27 12:45:44 +00:00
|
|
|
|
}
|