umami/components/layout/AppLayout.js

36 lines
1001 B
JavaScript
Raw Normal View History

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';
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';
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-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
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-07-27 23:47:41 +02:00
<UpdateNotice user={user} config={config} />
2021-05-15 10:29:39 +02:00
<Head>
<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}>
<NavBar />
2023-04-02 05:03:38 +02:00
</nav>
<main className={styles.body}>
<Container>{children}</Container>
</main>
</div>
2020-07-17 10:03:38 +02:00
);
}
2023-04-21 17:00:42 +02:00
export default AppLayout;