import { faBars as burgerIcon } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import classNames from 'classnames'; import type { FC } from 'react'; import { useEffect } from 'react'; import { Navigate, Route, Routes, useLocation } from 'react-router-dom'; import { AsideMenu } from '../common/AsideMenu'; import { NotFound } from '../common/NotFound'; import { useSwipeable, useToggle } from '../utils/helpers/hooks'; import type { SemVer } from '../utils/helpers/version'; import { FeaturesProvider, useFeatures } from './utils/features'; type ShlinkWebComponentProps = { routesPrefix?: string; serverVersion: SemVer; }; export const ShlinkWebComponent = ( TagsList: FC, ShortUrlsList: FC, CreateShortUrl: FC, ShortUrlVisits: FC, TagVisits: FC, DomainVisits: FC, OrphanVisits: FC, NonOrphanVisits: FC, Overview: FC, EditShortUrl: FC, ManageDomains: FC, ): FC => ({ routesPrefix = '', serverVersion }) => { const location = useLocation(); const [sidebarVisible, toggleSidebar, showSidebar, hideSidebar] = useToggle(); useEffect(() => hideSidebar(), [location]); const features = useFeatures(serverVersion); const addNonOrphanVisitsRoute = features.nonOrphanVisits; const addDomainVisitsRoute = features.domainVisits; const burgerClasses = classNames('menu-layout__burger-icon', { 'menu-layout__burger-icon--active': sidebarVisible }); const swipeableProps = useSwipeable(showSidebar, hideSidebar); // TODO Check if this is already wrapped by a router, and wrap otherwise return (
hideSidebar()}>
} /> } /> } /> } /> } /> } /> } /> {addDomainVisitsRoute && } />} } /> {addNonOrphanVisitsRoute && } />} } /> } /> List short URLs} />
); }; export type ShlinkWebComponentType = ReturnType;