import Link from "next/link";
import type { Metadata } from "next";
import { getGedContent } from "@/app/lib/content";
import { updateGedSettings } from "@/app/actions/homepage";
import { PageHeader } from "@/app/admin/_components/ui";
import {
  SettingsSaveForm,
  TextInput,
} from "@/app/admin/_components/HomepageForms";

export const metadata: Metadata = { title: "GED settings" };

export default async function GedSettingsPage() {
  const ged = await getGedContent();

  return (
    <div>
      <PageHeader
        title="GED feature"
        description="Edit the GED partnership section copy and seal labels."
        action={
          <Link href="/admin/homepage" className="text-sm font-semibold text-[#1f3fb8]">
            ← Back
          </Link>
        }
      />
      <SettingsSaveForm action={updateGedSettings}>
        <TextInput label="Heading" name="ged_heading" defaultValue={ged.heading} />
        <TextInput label="Body" name="ged_body" defaultValue={ged.body} rows={4} />
        <TextInput label="Seal top label" name="ged_seal_top" defaultValue={ged.sealTop} />
        <TextInput label="Seal main label" name="ged_seal_main" defaultValue={ged.sealMain} />
        <TextInput
          label="Seal bottom label"
          name="ged_seal_bottom"
          defaultValue={ged.sealBottom}
        />
      </SettingsSaveForm>
    </div>
  );
}
