import { redirect } from "next/navigation";
import { prisma } from "@/lib/prisma";
import { auth } from "@/auth";
import { canAccess, PERMISSIONS } from "@/lib/utils";
import { PageHeader } from "@/components/ui/page-header";
import { ParametresForm } from "@/components/modules/parametres/ParametresForm";

export const dynamic = "force-dynamic";

export default async function ParametresPage() {
  const session = await auth();
  if (!canAccess(session?.user.role, PERMISSIONS.parametres_manage)) redirect("/403");

  const hotel = await prisma.hotel.findFirst();

  return (
    <div className="space-y-4">
      <PageHeader
        title="Paramètres"
        description="Configurez les informations de votre hôtel"
      />
      <ParametresForm hotel={hotel} />
    </div>
  );
}
