import Head from "next/head";
import {
	AdminDashboard,
	UserDashboard,
} from "~/components/area-riservata/dashboard";
import { AreaRiservataLayout } from "~/components/Layout";
import type { NextPageWithLayout } from "~/pages/_app";
import { useTranslation } from "~/providers/I18nProvider";
import { useEnforcedSession } from "~/providers/SessionProvider";

const Dashboard: NextPageWithLayout = () => {
	const { t } = useTranslation();
	const session = useEnforcedSession();

	return (
		<>
			<Head>
				<title>{t.heads.area_riservata_titolo}</title>
				<meta content={t.heads.area_riservata_description} name="description" />
			</Head>

			{session.user.isAdmin ? (
				<AdminDashboard />
			) : (
				<UserDashboard userId={session.user.id} />
			)}
		</>
	);
};

export default Dashboard;

Dashboard.getLayout = function getLayout(page) {
	return <AreaRiservataLayout>{page}</AreaRiservataLayout>;
};
