umami/pages/dashboard/[[...id]].js

37 lines
795 B
JavaScript
Raw Normal View History

2020-08-06 08:03:07 +02:00
import React from 'react';
2020-08-07 11:27:12 +02:00
import Layout from 'components/layout/Layout';
2022-03-04 04:45:49 +01:00
import Dashboard from 'components/pages/Dashboard';
2020-08-06 08:03:07 +02:00
import useRequireLogin from 'hooks/useRequireLogin';
import { useRouter } from 'next/router';
import useUser from 'hooks/useUser';
2020-08-06 08:03:07 +02:00
2022-10-27 21:14:34 +02:00
export default function DashboardPage({ pageDisabled }) {
const {
query: { id },
isReady,
asPath,
} = useRouter();
2020-08-06 08:03:07 +02:00
const { loading } = useRequireLogin();
const user = useUser();
2020-08-06 08:03:07 +02:00
2022-10-27 21:14:34 +02:00
if (pageDisabled || !user || !isReady || loading) {
2020-08-06 08:03:07 +02:00
return null;
}
const userId = id?.[0];
2020-08-06 08:03:07 +02:00
return (
<Layout>
<Dashboard key={asPath} userId={user.id || userId} />
2020-08-06 08:03:07 +02:00
</Layout>
);
}
2022-10-27 21:14:34 +02:00
export async function getServerSideProps() {
return {
props: {
pageDisabled: !!process.env.DISABLE_UI,
},
};
}