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-02-10 12:26:57 +01:00
|
|
|
import { UI_LAYOUT_BODY } 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-01-11 23:47:38 +01:00
|
|
|
export default 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-01-19 00:05:39 +01:00
|
|
|
<div className={styles.layout}>
|
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-01-19 00:05:39 +01:00
|
|
|
<div className={styles.nav}>
|
|
|
|
<NavBar />
|
|
|
|
</div>
|
2023-02-10 12:26:57 +01:00
|
|
|
<div className={styles.body} id={UI_LAYOUT_BODY}>
|
2023-01-19 00:05:39 +01:00
|
|
|
<Container>
|
|
|
|
<main>{children}</main>
|
|
|
|
</Container>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-07-17 10:03:38 +02:00
|
|
|
);
|
|
|
|
}
|