import dynamic from "next/dynamic";
import Head from "next/head";
import { NewColumn } from "~/components/area-riservata/potenziali";
import { AreaRiservataLayout } from "~/components/Layout";
import { LoadingPage } from "~/components/loading";
import type { NextPageWithLayout } from "~/pages/_app";
import { PotenzialiProvider } from "~/providers/PotenzialiProvider";

const PotenzialiBoard = dynamic(
	() =>
		import("~/components/area-riservata/potenziali").then(
			(mod) => mod.Potenziali,
		),
	{
		ssr: false,
		loading: () => <LoadingPage />,
	},
);

/**
 * Pagina di gestione potenziali per admin: /area-riservata/admin/potenziali
 */
const AdminPotenziali: NextPageWithLayout = () => {
	return (
		<PotenzialiProvider>
			<Head>
				<title>Potenziali - Infoalloggi.it</title>
			</Head>
			<div className="mx-1 w-full flex-1">
				<div className="mx-auto w-full pt-4">
					<div className="mx-3 flex flex-wrap items-start justify-between pb-5">
						<div className="flex max-w-lg items-center gap-3">
							<h3 className="font-bold text-accent-foreground text-xl sm:text-2xl">
								Potenziali
							</h3>
						</div>
						<NewColumn />
					</div>

					<PotenzialiBoard />
				</div>
			</div>
		</PotenzialiProvider>
	);
};
export default AdminPotenziali;

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