2022-12-13 04:45:38 +01:00
|
|
|
import { Container } from 'react-basics';
|
2020-07-17 10:03:38 +02:00
|
|
|
import Head from 'next/head';
|
2023-03-02 08:59:01 +01:00
|
|
|
import { useRouter } from 'next/router';
|
2023-01-19 00:05:39 +01:00
|
|
|
import NavBar from 'components/layout/NavBar';
|
2023-03-02 08:59:01 +01:00
|
|
|
import UpdateNotice from 'components/common/UpdateNotice';
|
2023-01-11 23:47:38 +01:00
|
|
|
import useRequireLogin from 'hooks/useRequireLogin';
|
2023-02-28 05:03:04 +01:00
|
|
|
import useConfig from 'hooks/useConfig';
|
2023-04-20 04:33:24 +02:00
|
|
|
import { CURRENT_VERSION } from 'lib/constants';
|
2023-01-19 00:05:39 +01:00
|
|
|
import styles from './AppLayout.module.css';
|
2020-07-17 10:03:38 +02:00
|
|
|
|
2023-04-21 17:00:42 +02:00
|
|
|
export function AppLayout({ title, children }) {
|
2023-01-31 06:44:07 +01:00
|
|
|
const { user } = useRequireLogin();
|
2023-02-28 05:03:04 +01:00
|
|
|
const config = useConfig();
|
2023-03-02 08:59:01 +01:00
|
|
|
const { pathname } = useRouter();
|
2023-01-31 06:44:07 +01:00
|
|
|
|
2023-02-28 05:03:04 +01:00
|
|
|
if (!user || !config) {
|
2023-01-31 06:44:07 +01:00
|
|
|
return null;
|
|
|
|
}
|
2021-05-13 08:15:37 +02:00
|
|
|
|
2023-03-02 08:59:01 +01:00
|
|
|
const allowUpdate = user?.isAdmin && !config?.updatesDisabled && !pathname.includes('/share/');
|
|
|
|
|
2020-07-17 10:03:38 +02:00
|
|
|
return (
|
2023-04-20 04:33:24 +02:00
|
|
|
<div className={styles.layout} data-app-version={CURRENT_VERSION}>
|
2023-03-02 08:59:01 +01:00
|
|
|
{allowUpdate && <UpdateNotice />}
|
2021-05-15 10:29:39 +02:00
|
|
|
<Head>
|
2022-12-13 04:45:38 +01:00
|
|
|
<title>{title ? `${title} | umami` : 'umami'}</title>
|
2020-07-17 10:03:38 +02:00
|
|
|
</Head>
|
2023-04-02 05:03:38 +02:00
|
|
|
<nav className={styles.nav}>
|
2023-01-19 00:05:39 +01:00
|
|
|
<NavBar />
|
2023-04-02 05:03:38 +02:00
|
|
|
</nav>
|
|
|
|
<main className={styles.body}>
|
|
|
|
<Container>{children}</Container>
|
|
|
|
</main>
|
2023-01-19 00:05:39 +01:00
|
|
|
</div>
|
2020-07-17 10:03:38 +02:00
|
|
|
);
|
|
|
|
}
|
2023-04-21 17:00:42 +02:00
|
|
|
|
|
|
|
export default AppLayout;
|