import type { Metadata } from "next";
import { SettingsForm } from "@/components/admin/SettingsForm";
import { getSettings } from "@/lib/cms";

export const metadata: Metadata = {
  title: "Site settings",
  robots: { index: false, follow: false },
};

export default async function AdminSettingsPage({
  searchParams,
}: {
  searchParams: Promise<{ saved?: string }>;
}) {
  const [{ saved }, settings] = await Promise.all([searchParams, getSettings()]);

  return (
    <div className="space-y-8">
      <header>
        <p className="text-sm font-semibold uppercase tracking-[0.14em] text-coral">
          Configuration
        </p>
        <h1 className="display-2 mt-2">Site settings</h1>
        <p className="mt-2 text-ink-soft">
          Edit the website content visitors see — brand, contact details,
          homepage copy and site-wide SEO.
        </p>
      </header>

      {saved ? (
        <p className="rounded-2xl border border-teal/30 bg-teal-soft px-5 py-3 text-sm font-medium text-teal-dark">
          Settings saved and the website has been refreshed.
        </p>
      ) : null}

      <SettingsForm settings={settings} />
    </div>
  );
}
