import { faBars as burgerIcon } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import classNames from 'classnames'; import type { FC, ReactNode } from 'react'; import { useEffect } from 'react'; import { Navigate, Route, Routes, useLocation } from 'react-router-dom'; import { useToggle } from '../shlink-frontend-kit/src'; import { AsideMenu } from './common/AsideMenu'; import { useFeature } from './utils/features'; import { useSwipeable } from './utils/helpers/hooks'; import { useRoutesPrefix } from './utils/routesPrefix'; type MainProps = { createNotFound?: (nonPrefixedHomePath: string) => ReactNode; }; export const Main = ( TagsList: FC, ShortUrlsList: FC, CreateShortUrl: FC, ShortUrlVisits: FC, TagVisits: FC, DomainVisits: FC, OrphanVisits: FC, NonOrphanVisits: FC, Overview: FC, EditShortUrl: FC, ManageDomains: FC, ): FC => ({ createNotFound }) => { const location = useLocation(); const routesPrefix = useRoutesPrefix(); const [sidebarVisible, toggleSidebar, showSidebar, hideSidebar] = useToggle(); useEffect(() => hideSidebar(), [location]); const addDomainVisitsRoute = useFeature('domainVisits'); const burgerClasses = classNames('menu-layout__burger-icon', { 'menu-layout__burger-icon--active': sidebarVisible }); const swipeableProps = useSwipeable(showSidebar, hideSidebar); // FIXME Check if this is already wrapped by a router, and wrap otherwise return ( <>
hideSidebar()}>
} /> } /> } /> } /> } /> } /> } /> {addDomainVisitsRoute && } />} } /> } /> } /> } /> {createNotFound && }
); };