import Link from "next/link";
import { RESOURCES } from "@/lib/permissions";

export default async function AccessDeniedPage({
  searchParams,
}: {
  searchParams: Promise<{ resource?: string }>;
}) {
  const { resource } = await searchParams;
  const label = RESOURCES.find((r) => r.value === resource)?.label ?? "This section";

  return (
    <div className="mx-auto max-w-md py-16 text-center">
      <div className="mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-amber-100 text-2xl">🔒</div>
      <h1 className="font-[family-name:var(--font-heading)] text-xl font-bold text-stone-800">Access restricted</h1>
      <p className="mt-2 text-sm text-stone-500">
        {label} isn&apos;t part of your role&apos;s permissions. Ask an admin if you need access.
      </p>
      <Link href="/iv-manage-84x2" className="mt-6 inline-block rounded-md bg-rose-700 px-4 py-2 text-sm font-semibold text-white hover:bg-rose-800">
        Back to Dashboard
      </Link>
    </div>
  );
}
