2020-09-17 06:55:32 +02:00
|
|
|
import { useRouter } from 'next/router';
|
2020-08-09 08:48:43 +02:00
|
|
|
import classNames from 'classnames';
|
2020-09-17 06:55:32 +02:00
|
|
|
import NavMenu from 'components/common/NavMenu';
|
2020-08-09 08:48:43 +02:00
|
|
|
import styles from './MenuLayout.module.css';
|
|
|
|
|
2020-08-09 12:04:48 +02:00
|
|
|
export default function MenuLayout({
|
|
|
|
menu,
|
|
|
|
selectedOption,
|
|
|
|
className,
|
|
|
|
menuClassName,
|
|
|
|
contentClassName,
|
|
|
|
children,
|
2020-09-17 06:55:32 +02:00
|
|
|
replace = false,
|
2020-08-09 12:04:48 +02:00
|
|
|
}) {
|
2020-09-17 06:55:32 +02:00
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
function handleSelect(url) {
|
|
|
|
if (replace) {
|
2022-11-02 16:57:52 +01:00
|
|
|
router.replace(url, undefined, { shallow: true });
|
2020-09-17 06:55:32 +02:00
|
|
|
} else {
|
2022-11-02 16:57:52 +01:00
|
|
|
router.push(url, undefined, { shallow: true });
|
2020-09-17 06:55:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-09 08:48:43 +02:00
|
|
|
return (
|
2020-08-18 01:46:13 +02:00
|
|
|
<div className={classNames(styles.container, className, 'row')}>
|
2020-09-17 06:55:32 +02:00
|
|
|
<NavMenu
|
2020-08-10 00:13:38 +02:00
|
|
|
options={menu}
|
|
|
|
selectedOption={selectedOption}
|
2020-09-17 06:55:32 +02:00
|
|
|
className={classNames(styles.menu, menuClassName, 'col-12 col-lg-2')}
|
|
|
|
onSelect={handleSelect}
|
2020-08-10 00:13:38 +02:00
|
|
|
/>
|
2020-09-17 06:55:32 +02:00
|
|
|
<div className={classNames(styles.content, contentClassName, 'col-12 col-lg-10')}>
|
2020-08-18 01:46:13 +02:00
|
|
|
{children}
|
|
|
|
</div>
|
2020-08-09 08:48:43 +02:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|