2022-10-28 19:34:50 +02:00
|
|
|
import { useRouter } from 'next/router';
|
2020-08-07 11:27:12 +02:00
|
|
|
import Layout from 'components/layout/Layout';
|
2023-01-10 08:59:26 +01:00
|
|
|
import Dashboard from 'components/pages/dashboard/Dashboard';
|
2022-10-28 19:34:50 +02:00
|
|
|
import useConfig from 'hooks/useConfig';
|
2023-01-05 06:20:24 +01:00
|
|
|
import useRequireLogin from 'hooks/useRequireLogin';
|
2020-08-06 08:03:07 +02:00
|
|
|
|
2022-10-28 01:42:57 +02:00
|
|
|
export default function DashboardPage() {
|
2022-10-26 00:48:49 +02:00
|
|
|
const {
|
|
|
|
query: { id },
|
|
|
|
isReady,
|
|
|
|
asPath,
|
|
|
|
} = useRouter();
|
2023-01-05 06:20:24 +01:00
|
|
|
const { user } = useRequireLogin();
|
2022-10-28 19:34:50 +02:00
|
|
|
const { adminDisabled } = useConfig();
|
2020-08-06 08:03:07 +02:00
|
|
|
|
2022-12-29 00:43:22 +01:00
|
|
|
if (adminDisabled || !user || !isReady) {
|
2020-08-06 08:03:07 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-10-26 00:48:49 +02:00
|
|
|
const userId = id?.[0];
|
|
|
|
|
2020-08-06 08:03:07 +02:00
|
|
|
return (
|
|
|
|
<Layout>
|
2022-10-26 00:48:49 +02:00
|
|
|
<Dashboard key={asPath} userId={user.id || userId} />
|
2020-08-06 08:03:07 +02:00
|
|
|
</Layout>
|
|
|
|
);
|
|
|
|
}
|