import React, { useEffect } from 'react'; import { Route, Switch } from 'react-router-dom'; import { Swipeable } from 'react-swipeable'; import { faBars as burgerIcon } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import classNames from 'classnames'; import * as PropTypes from 'prop-types'; import { serverType } from '../servers/prop-types'; import { withSelectedServer } from '../servers/helpers/withSelectedServer'; import { useToggle } from '../utils/helpers/hooks'; import NotFound from './NotFound'; import './MenuLayout.scss'; const propTypes = { match: PropTypes.object, location: PropTypes.object, selectedServer: serverType, }; const MenuLayout = (TagsList, ShortUrls, AsideMenu, CreateShortUrl, ShortUrlVisits, ShlinkVersions, ServerError) => { const MenuLayoutComp = ({ match, location, selectedServer }) => { const [ sidebarVisible, toggleSidebar, showSidebar, hideSidebar ] = useToggle(); const { params: { serverId } } = match; useEffect(() => hideSidebar(), [ location ]); if (selectedServer.serverNotReachable) { return ; } const burgerClasses = classNames('menu-layout__burger-icon', { 'menu-layout__burger-icon--active': sidebarVisible, }); const swipeMenuIfNoModalExists = (callback) => (e) => { const swippedOnVisitsTable = e.event.path.some( ({ classList }) => classList && classList.contains('visits-table') ); if (swippedOnVisitsTable || document.querySelector('.modal')) { return; } callback(); }; return (
hideSidebar()}>
{/* */} List short URLs} />
); }; MenuLayoutComp.propTypes = propTypes; return withSelectedServer(MenuLayoutComp, ServerError); }; export default MenuLayout;