2022-08-09 16:18:42 +03:00

63 lines
1.4 KiB
JavaScript

import React from "react";
import Link from "next/link";
export default class InnerMenu extends React.Component
{
constructor(props)
{
super(props);
this.menuRef = React.createRef();
}
componentDidMount()
{
let l = 0;
let m = 0;
const menu = ["events","faq"];
for(let i in menu)
{
if(this.props.router.asPath.indexOf(menu[i]) > -1)
{
m = i;
}
}
for(let i = 0; i < m; i++)
{
l = l + this.menuRef.current.children[i].getBoundingClientRect().width;
}
this.menuRef.current.scrollLeft = l - 50;
}
_handle_onNewAppeal = () =>
{
this.props.router.push('/support/new/');
}
render()
{
const { number } = this.props;
return (
<aside className="flex">
<button className="nav_toggle">
Меню
</button>
<ul className="aside_nav" ref={ this.menuRef }>
<li>
<Link href={`/support/faq`} shallow>
<a className={ this.props.router && this.props.router.asPath.indexOf("faq") > -1 ? "active" : "" }>FAQ</a></Link>
</li>
<li>
<Link href={`/support/messages`} shallow>
<a className={ this.props.router && this.props.router.asPath.indexOf("messages") > -1 ? "active" : "" }>Мои обращения <span>3</span></a>
</Link>
</li>
</ul>
<button className="button button-blue new-appeal" onClick={ this._handle_onNewAppeal }>Новое обращение</button>
</aside>
)
}
}