mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-02-27 20:26:40 +00:00
35 lines
962 B
TypeScript
35 lines
962 B
TypeScript
import type { FC } from 'react';
|
|
import { useEffect } from 'react';
|
|
import { isReachableServer } from '../servers/data';
|
|
import { withSelectedServer } from '../servers/helpers/withSelectedServer';
|
|
import type { ShlinkWebComponentType } from '../shlink-web-component';
|
|
import './MenuLayout.scss';
|
|
|
|
interface MenuLayoutProps {
|
|
sidebarPresent: Function;
|
|
sidebarNotPresent: Function;
|
|
}
|
|
|
|
export const MenuLayout = (
|
|
ServerError: FC,
|
|
ShlinkWebComponent: ShlinkWebComponentType,
|
|
) => withSelectedServer<MenuLayoutProps>(({ selectedServer, sidebarNotPresent, sidebarPresent }) => {
|
|
const showContent = isReachableServer(selectedServer);
|
|
|
|
useEffect(() => {
|
|
showContent && sidebarPresent();
|
|
return () => sidebarNotPresent();
|
|
}, []);
|
|
|
|
if (!showContent) {
|
|
return <ServerError />;
|
|
}
|
|
|
|
return (
|
|
<ShlinkWebComponent
|
|
serverVersion={selectedServer.version}
|
|
routesPrefix={`/server/${selectedServer.id}`}
|
|
/>
|
|
);
|
|
}, ServerError);
|