# Add the "Class Registration" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/class-registration) to this Pantheon Content Publisher (P1) Next.js project. Course summary card beside section radio cards with days, room and seats left, student details, guardian consent and access needs.

## Steps

1. Create `components/puck/class-registration-block.tsx` with the exact file contents below. If `components/puck/` doesn't exist, find the folder where this project keeps its Puck components (look at the imports in `puck.config.tsx`) and put it there.
2. In `puck.config.tsx`, import it: `import { classRegistrationBlock } from "./components/puck/class-registration-block";`
3. Register it under `components` as `ClassRegistrationBlock: classRegistrationBlock`.
4. Add `"ClassRegistrationBlock"` to the best-fitting entry in `categories` (this block's library category is "Enrollment"). Create a category only if none fits.
5. Run the project's type check (usually `pnpm typecheck`) and resolve anything project-specific.
6. If `package.json` has a `sync:registry` script, tell the user it must run (or that CI will run it) before the new component appears in the P1 editor.

## Rules

- Do not add dependencies. The block is self-contained by design: one type-only import from `@puckeditor/core`, Tailwind v4 classes, no client JavaScript.
- Keep the files as-is unless the user asks for changes. The accent color is `indigo-*`; if the project has brand colors, offer to swap them with a find-and-replace on `indigo-`.
- Images are plain `imageUrl` + `imageAlt` text fields. If this project defines a P1 media-library field (search for `"p1-media"`), offer to switch to it.
- Don't change prop names in `defaultProps`. Content editors' saved pages depend on them.

## File: `components/puck/class-registration-block.tsx`

```tsx
import type { ComponentConfig } from "@puckeditor/core";

/**
 * Class Registration — one course, its sections as radio cards (days, time, room, instructor,
 * seats), then student details, guardian consent for minors and an accommodations note.
 * A plain HTML form that posts to your registration endpoint, no JavaScript.
 * Register: `ClassRegistrationBlock: classRegistrationBlock` in puck.config.tsx.
 */

type Heading = "h1" | "h2" | "h3" | "h4";

type Section = { code: string; days: string; time: string; location: string; instructor: string; seats: string };

export type ClassRegistrationProps = {
  eyebrow: string;
  heading: string;
  headingLevel: Heading;
  intro: string;
  courseCode: string;
  courseTitle: string;
  courseDetails: string;
  courseNote: string;
  formAction: string;
  sections: Section[];
  gradeOptions: string;
  showGuardian: boolean;
  submitLabel: string;
  privacyNote: string;
};

const childHeading: Record<Heading, "h2" | "h3" | "h4" | "h5"> = { h1: "h2", h2: "h3", h3: "h4", h4: "h5" };

const inputClass =
  "block min-h-11 w-full rounded-lg border-0 bg-white px-3.5 py-2.5 text-base text-neutral-950 shadow-xs ring-1 ring-neutral-300 ring-inset placeholder:text-neutral-500 focus:ring-2 focus:ring-indigo-600 focus:outline-none";
const labelClass = "block text-sm leading-6 font-medium text-neutral-900";
const checkboxClass = "size-5 rounded border-neutral-400 accent-indigo-600 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600";

const lines = (s?: string) =>
  (s || "")
    .split("\n")
    .map((l) => l.trim())
    .filter(Boolean);

const Optional = () => <span className="font-normal text-neutral-600">(optional)</span>;

const StepLegend = ({ n, children }: { n: number; children: React.ReactNode }) => (
  <legend className="flex items-center gap-3 text-base leading-7 font-semibold text-neutral-950">
    <span aria-hidden="true" className="flex size-8 shrink-0 items-center justify-center rounded-full bg-neutral-950 text-sm font-semibold text-white tabular-nums">
      {n}
    </span>
    {children}
  </legend>
);

export const classRegistrationBlock: ComponentConfig<ClassRegistrationProps> = {
  label: "Class Registration",
  fields: {
    eyebrow: { type: "text", label: "Eyebrow", metadata: { help: "Small line above the heading, such as the term. Leave blank to hide it." } },
    heading: { type: "text", label: "Heading" },
    headingLevel: {
      type: "select",
      label: "Heading level",
      options: [
        { label: "H1", value: "h1" },
        { label: "H2", value: "h2" },
        { label: "H3", value: "h3" },
        { label: "H4", value: "h4" },
      ],
      metadata: { help: "Sets the page outline for screen readers and search. The look doesn't change." },
    },
    intro: { type: "textarea", label: "Intro" },
    courseCode: { type: "text", label: "Course code", metadata: { help: "Such as BIO 110. Also sent with the form as course." } },
    courseTitle: { type: "text", label: "Course title" },
    courseDetails: { type: "textarea", label: "Course facts", metadata: { help: "One fact per line, such as credits, dates or fees. Shown in the summary card." } },
    courseNote: { type: "textarea", label: "Summary note", metadata: { help: "Small print in the summary card, such as prerequisites. Leave blank to hide it." } },
    formAction: {
      type: "text",
      label: "Form action URL",
      metadata: {
        help: "Where the form is sent with POST. Field names: course, section, first_name, last_name, student_id, email, grade, guardian_name, guardian_email, guardian_consent and accommodations.",
      },
    },
    sections: {
      type: "array",
      label: "Sections",
      min: 1,
      max: 8,
      getItemSummary: (item) => [item?.code, item?.days].filter(Boolean).join(" · ") || "Section",
      defaultItemProps: { code: "Section 04", days: "Sat", time: "9:00 – 11:30 a.m.", location: "Room 214", instructor: "", seats: "" },
      arrayFields: {
        code: { type: "text", label: "Section code", metadata: { help: "Sent with the form, so it must match your system." } },
        days: { type: "text", label: "Days" },
        time: { type: "text", label: "Time" },
        location: { type: "text", label: "Room or campus" },
        instructor: { type: "text", label: "Instructor" },
        seats: { type: "text", label: "Seats left", metadata: { help: "Text such as \"6 seats left\" or a data-source token. Type \"Full\" to close the section." } },
      },
      metadata: { help: "Each section is a choice card. A section whose seats text is \"Full\" can't be picked." },
    },
    gradeOptions: { type: "textarea", label: "Grade or year options", metadata: { help: "One choice per line for the grade or year menu." } },
    showGuardian: {
      type: "radio",
      label: "Ask for guardian consent",
      options: [
        { label: "Yes", value: true },
        { label: "No", value: false },
      ],
      metadata: { help: "Adds parent or guardian fields for students under 18, such as dual-credit high schoolers." },
    },
    submitLabel: { type: "text", label: "Button text" },
    privacyNote: { type: "textarea", label: "Privacy note", metadata: { help: "Shown under the button. Leave blank to hide it." } },
  },
  defaultProps: {
    eyebrow: "Spring 2027 · Dual credit",
    heading: "Register for a class section",
    headingLevel: "h2",
    intro: "Pick the section that fits your schedule, then tell us who you are. You'll get a confirmation email within one business day.",
    courseCode: "BIO 110",
    courseTitle: "Introduction to Environmental Science",
    courseDetails: "3 credit hours\nJanuary 19 – May 8\nNo course fee for dual-credit students",
    courseNote: "Open to high school juniors and seniors with a counselor's approval on file.",
    formAction: "/register/class",
    sections: [
      { code: "BIO 110-01", days: "Mon & Wed", time: "8:00 – 9:15 a.m.", location: "Science Hall 120", instructor: "Dr. Alana Ortiz", seats: "12 seats left" },
      { code: "BIO 110-02", days: "Tue & Thu", time: "2:30 – 3:45 p.m.", location: "Science Hall 120", instructor: "Prof. James Whitfield", seats: "3 seats left" },
      { code: "BIO 110-03", days: "Wed", time: "6:00 – 8:45 p.m.", location: "Downtown Campus, Room 310", instructor: "Dr. Alana Ortiz", seats: "Full" },
      { code: "BIO 110-W1", days: "Online", time: "Work at your own pace each week", location: "Online", instructor: "Prof. Mina Patel", seats: "18 seats left" },
    ],
    gradeOptions: "11th grade (junior)\n12th grade (senior)\nFirst-year college student\nReturning adult learner",
    showGuardian: true,
    submitLabel: "Submit registration",
    privacyNote: "Your details go only to the registrar's office. Seat counts are sample data.",
  },
  render: ({ id, eyebrow, heading, headingLevel, intro, courseCode, courseTitle, courseDetails, courseNote, formAction, sections, gradeOptions, showGuardian, submitLabel, privacyNote }) => {
    const H = headingLevel || "h2";
    const Sub = childHeading[H] || "h3";
    const uid = `cr-${id || "class"}`;
    const list = (sections ?? []).filter((s) => s?.code);
    const grades = lines(gradeOptions);
    const facts = lines(courseDetails);
    const hasSummary = Boolean(courseCode || courseTitle || facts.length || courseNote);
    const guardian = showGuardian !== false;
    let step = 0;

    return (
      <section className="bg-neutral-50 px-4 py-16 sm:px-6 sm:py-20 lg:px-8 lg:py-24">
        <div className="mx-auto max-w-6xl">
          {eyebrow || heading || intro ? (
            <div className="max-w-2xl">
              {eyebrow ? <p className="text-sm font-semibold tracking-wide text-indigo-700 uppercase">{eyebrow}</p> : null}
              {heading ? <H className={`text-3xl font-semibold tracking-tight text-balance text-neutral-950 sm:text-4xl ${eyebrow ? "mt-3" : ""}`}>{heading}</H> : null}
              {intro ? <p className="mt-4 text-lg leading-8 text-pretty text-neutral-600">{intro}</p> : null}
            </div>
          ) : null}

          <div className={`grid grid-cols-1 items-start gap-8 lg:gap-12 ${hasSummary ? "lg:grid-cols-12" : ""} ${eyebrow || heading || intro ? "mt-10 sm:mt-12" : ""}`}>
            {hasSummary ? (
              <aside aria-labelledby={`${uid}-course`} className="lg:sticky lg:top-8 lg:col-span-4">
                <div className="overflow-hidden rounded-2xl bg-neutral-950 text-white shadow-lg">
                  <div className="border-b border-white/10 p-6 sm:p-8">
                    {courseCode ? <p className="font-mono text-sm tracking-wider text-indigo-300 uppercase">{courseCode}</p> : null}
                    <Sub id={`${uid}-course`} className={`text-xl leading-7 font-semibold text-balance text-white ${courseCode ? "mt-2" : ""}`}>
                      {courseTitle || courseCode || "Course"}
                    </Sub>
                  </div>
                  {facts.length || courseNote ? (
                    <div className="p-6 sm:p-8">
                      {facts.length ? (
                        <ul role="list" className="space-y-3 text-sm leading-6 text-neutral-200">
                          {facts.map((f, i) => (
                            <li key={i} className="flex gap-3">
                              <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="mt-0.5 size-5 shrink-0 text-indigo-300">
                                <path fillRule="evenodd" d="M16.704 4.153a.75.75 0 0 1 .143 1.052l-8 10.5a.75.75 0 0 1-1.127.075l-4.5-4.5a.75.75 0 0 1 1.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 0 1 1.05-.143Z" clipRule="evenodd" />
                              </svg>
                              {f}
                            </li>
                          ))}
                        </ul>
                      ) : null}
                      {courseNote ? <p className={`text-sm leading-6 text-pretty text-neutral-300 ${facts.length ? "mt-6 border-t border-white/10 pt-6" : ""}`}>{courseNote}</p> : null}
                    </div>
                  ) : null}
                </div>
              </aside>
            ) : null}

            <form action={formAction || undefined} method="post" className={`rounded-2xl bg-white p-6 shadow-sm ring-1 ring-neutral-200 sm:p-8 ${hasSummary ? "lg:col-span-8" : ""}`}>
              {courseCode ? <input type="hidden" name="course" value={courseCode} /> : null}
              <p className="text-sm leading-6 text-neutral-600">All fields are required unless marked optional.</p>

              {list.length ? (
                <fieldset className="mt-8">
                  <StepLegend n={++step}>Choose a section</StepLegend>
                  <div className="mt-5 grid grid-cols-1 gap-3 sm:grid-cols-2">
                    {list.map((s, i) => {
                      const full = /^\s*full\b/i.test(s.seats || "");
                      return (
                        <label
                          key={`${s.code}-${i}`}
                          className={`relative flex min-h-11 flex-col rounded-xl p-4 ring-1 ring-inset select-none ${
                            full
                              ? "cursor-not-allowed bg-neutral-50 ring-neutral-200"
                              : "cursor-pointer bg-white ring-neutral-300 transition hover:ring-indigo-400 has-checked:bg-indigo-50 has-checked:ring-2 has-checked:ring-indigo-600 has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-indigo-600"
                          }`}
                        >
                          <input type="radio" name="section" value={s.code} required disabled={full} className="peer sr-only" />
                          <span className="flex items-start justify-between gap-3 pr-7">
                            <span className={`font-mono text-sm font-semibold tracking-wide ${full ? "text-neutral-600" : "text-indigo-700"}`}>{s.code}</span>
                          </span>
                          {s.days || s.time ? (
                            <span className={`mt-2 text-base leading-6 font-semibold ${full ? "text-neutral-600" : "text-neutral-950"}`}>
                              {[s.days, s.time].filter(Boolean).join(", ")}
                            </span>
                          ) : null}
                          {s.location || s.instructor ? (
                            <span className="mt-1 text-sm leading-6 text-neutral-600">{[s.location, s.instructor].filter(Boolean).join(" · ")}</span>
                          ) : null}
                          {s.seats ? (
                            <span className={`mt-3 inline-flex w-fit items-center rounded-full px-2.5 py-0.5 text-xs leading-5 font-semibold ${full ? "bg-neutral-200 text-neutral-700" : "bg-neutral-100 text-neutral-700"}`}>
                              {full ? "Full — not available" : s.seats}
                            </span>
                          ) : null}
                          <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="absolute top-4 right-4 hidden size-5 text-indigo-600 peer-checked:block">
                            <path fillRule="evenodd" d="M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm3.857-9.809a.75.75 0 0 0-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 1 0-1.06 1.061l2.5 2.5a.75.75 0 0 0 1.137-.089l4-5.5Z" clipRule="evenodd" />
                          </svg>
                        </label>
                      );
                    })}
                  </div>
                </fieldset>
              ) : null}

              <fieldset className="mt-10 border-t border-neutral-200 pt-8">
                <StepLegend n={++step}>About the student</StepLegend>
                <div className="mt-5 grid grid-cols-1 gap-x-6 gap-y-6 sm:grid-cols-2">
                  <div>
                    <label htmlFor={`${uid}-first`} className={labelClass}>First name</label>
                    <input id={`${uid}-first`} name="first_name" type="text" required autoComplete="given-name" className={`mt-2 ${inputClass}`} />
                  </div>
                  <div>
                    <label htmlFor={`${uid}-last`} className={labelClass}>Last name</label>
                    <input id={`${uid}-last`} name="last_name" type="text" required autoComplete="family-name" className={`mt-2 ${inputClass}`} />
                  </div>
                  <div>
                    <label htmlFor={`${uid}-email`} className={labelClass}>Email</label>
                    <input id={`${uid}-email`} name="email" type="email" required autoComplete="email" inputMode="email" className={`mt-2 ${inputClass}`} />
                  </div>
                  <div>
                    <label htmlFor={`${uid}-sid`} className={labelClass}>
                      Student ID <Optional />
                    </label>
                    <input id={`${uid}-sid`} name="student_id" type="text" autoComplete="off" aria-describedby={`${uid}-sid-hint`} className={`mt-2 ${inputClass}`} />
                    <p id={`${uid}-sid-hint`} className="mt-2 text-sm leading-6 text-neutral-600">
                      Leave blank if this is your first class with us.
                    </p>
                  </div>
                  {grades.length ? (
                    <div className="sm:col-span-2">
                      <label htmlFor={`${uid}-grade`} className={labelClass}>Grade or year</label>
                      <select id={`${uid}-grade`} name="grade" required defaultValue="" className={`mt-2 ${inputClass}`}>
                        <option value="" disabled>
                          Choose one
                        </option>
                        {grades.map((g, i) => (
                          <option key={`${g}-${i}`} value={g}>
                            {g}
                          </option>
                        ))}
                      </select>
                    </div>
                  ) : null}
                </div>
              </fieldset>

              <fieldset className="mt-10 border-t border-neutral-200 pt-8">
                <StepLegend n={++step}>{guardian ? "Consent and access" : "Access needs"}</StepLegend>
                <div className="mt-5 grid grid-cols-1 gap-x-6 gap-y-6 sm:grid-cols-2">
                  {guardian ? (
                    <>
                      <p id={`${uid}-guardian-hint`} className="text-sm leading-6 text-pretty text-neutral-600 sm:col-span-2">
                        Required if the student is under 18. Adult students can skip these three fields.
                      </p>
                      <div>
                        <label htmlFor={`${uid}-gname`} className={labelClass}>
                          Parent or guardian name <Optional />
                        </label>
                        <input id={`${uid}-gname`} name="guardian_name" type="text" autoComplete="off" aria-describedby={`${uid}-guardian-hint`} className={`mt-2 ${inputClass}`} />
                      </div>
                      <div>
                        <label htmlFor={`${uid}-gemail`} className={labelClass}>
                          Parent or guardian email <Optional />
                        </label>
                        <input id={`${uid}-gemail`} name="guardian_email" type="email" autoComplete="off" inputMode="email" aria-describedby={`${uid}-guardian-hint`} className={`mt-2 ${inputClass}`} />
                      </div>
                      <div className="flex gap-3 sm:col-span-2">
                        <div className="flex h-11 shrink-0 items-center">
                          <input id={`${uid}-consent`} name="guardian_consent" type="checkbox" value="yes" aria-describedby={`${uid}-guardian-hint`} className={checkboxClass} />
                        </div>
                        <label htmlFor={`${uid}-consent`} className="flex min-h-11 cursor-pointer items-center text-sm leading-6 text-neutral-900">
                          I am this student&rsquo;s parent or legal guardian and I give permission for them to enroll.
                        </label>
                      </div>
                    </>
                  ) : null}
                  <div className="sm:col-span-2">
                    <label htmlFor={`${uid}-access`} className={labelClass}>
                      Accessibility accommodations <Optional />
                    </label>
                    <textarea id={`${uid}-access`} name="accommodations" rows={3} aria-describedby={`${uid}-access-hint`} className={`mt-2 ${inputClass}`} />
                    <p id={`${uid}-access-hint`} className="mt-2 text-sm leading-6 text-neutral-600">
                      Tell us what helps you learn, such as captioning, a note-taker or extended test time. We share it only with disability services.
                    </p>
                  </div>
                </div>
              </fieldset>

              <div className="mt-10 flex flex-col gap-4 border-t border-neutral-200 pt-8 sm:flex-row sm:items-center sm:gap-6">
                <button
                  type="submit"
                  className="inline-flex min-h-11 shrink-0 items-center justify-center rounded-lg bg-indigo-600 px-6 py-3 text-base font-semibold text-white shadow-xs transition hover:bg-indigo-700 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
                >
                  {submitLabel || "Submit registration"}
                </button>
                {privacyNote ? <p className="text-sm leading-6 text-pretty text-neutral-600">{privacyNote}</p> : null}
              </div>
            </form>
          </div>
        </div>
      </section>
    );
  },
};
```
