# Add the "Service Request" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/service-request) to this Pantheon Content Publisher (P1) Next.js project. 311-style problem report with request-type cards, location, description, an optional photo upload and optional contact details.

## Steps

1. Create `components/puck/service-request-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 { serviceRequestBlock } from "./components/puck/service-request-block";`
3. Register it under `components` as `ServiceRequestBlock: serviceRequestBlock`.
4. Add `"ServiceRequestBlock"` to the best-fitting entry in `categories` (this block's library category is "Forms"). 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/service-request-block.tsx`

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

/**
 * Service Request — a 311-style "report a problem" form: request type as radio cards, location,
 * description, an optional photo and optional contact details, with an emergency notice up top.
 * Register: `ServiceRequestBlock: serviceRequestBlock` in puck.config.tsx.
 */

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

type RequestType = { label: string; description: string };

export type ServiceRequestProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  emergencyText: string;
  formAction: string;
  requestTypes: RequestType[];
  allowPhoto: boolean;
  anonymousNote: string;
  submitLabel: string;
  afterSubmitNote: string;
};

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 stepLegend = "flex items-center gap-3 text-lg leading-7 font-semibold text-neutral-950";
const optional = <span className="font-normal text-neutral-600">(optional)</span>;

const StepNum = ({ n }: { n: number }) => (
  <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>
);

export const serviceRequestBlock: ComponentConfig<ServiceRequestProps> = {
  label: "Service Request",
  fields: {
    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" },
    emergencyText: {
      type: "textarea",
      label: "Emergency notice",
      metadata: { help: "Tells people when not to use this form. Leave blank to hide it, but most cities should keep it." },
    },
    formAction: {
      type: "text",
      label: "Form action URL",
      metadata: {
        help: "Where the form is sent with POST as multipart/form-data (so the photo can upload). Field names: request_type, address, cross_street, landmark, description, photo, name, email, phone.",
      },
    },
    requestTypes: {
      type: "array",
      label: "Request types",
      min: 1,
      max: 12,
      getItemSummary: (item) => item?.label || "Request type",
      defaultItemProps: { label: "New request type", description: "" },
      arrayFields: {
        label: { type: "text", label: "Name", metadata: { help: "Sent as the request_type value, so it should match your work-order categories." } },
        description: { type: "text", label: "Examples", metadata: { help: "A few words so people pick the right one. Leave blank to hide it." } },
      },
    },
    allowPhoto: {
      type: "radio",
      label: "Accept a photo",
      options: [
        { label: "Yes", value: true },
        { label: "No", value: false },
      ],
      metadata: { help: "Your form handler must accept file uploads." },
    },
    anonymousNote: { type: "textarea", label: "Contact note", metadata: { help: "Explains that contact details are optional. Leave blank to hide it." } },
    submitLabel: { type: "text", label: "Button text" },
    afterSubmitNote: { type: "textarea", label: "After you submit", metadata: { help: "What people can expect next, shown beside the button. Leave blank to hide it." } },
  },
  defaultProps: {
    heading: "Report a problem",
    headingLevel: "h2",
    intro: "Potholes, broken streetlights, missed trash pickups — tell us where and we'll route it to the right crew.",
    emergencyText: "If anyone is in danger, or you see a gas leak, downed power line or flooding on a roadway, call 911 now. This form isn't monitored around the clock.",
    formAction: "/311/request",
    requestTypes: [
      { label: "Pothole or road damage", description: "Holes, cracks, sunken pavement" },
      { label: "Streetlight out", description: "Dark, flickering or damaged pole" },
      { label: "Missed collection", description: "Trash, recycling or yard waste" },
      { label: "Graffiti", description: "On public property or a city sign" },
      { label: "Sidewalk hazard", description: "Trip hazards, blocked ramps" },
      { label: "Something else", description: "We'll sort it out" },
    ],
    allowPhoto: true,
    anonymousNote: "You can submit anonymously. Leave an email if you'd like a tracking number and updates when the work is done.",
    submitLabel: "Submit request",
    afterSubmitNote: "Most requests are reviewed within one business day. Average repair times vary by type.",
  },
  render: ({ id, heading, headingLevel, intro, emergencyText, formAction, requestTypes, allowPhoto, anonymousNote, submitLabel, afterSubmitNote }) => {
    const H = headingLevel || "h2";
    const uid = `sr-${id || "form"}`;
    const types = (requestTypes ?? []).filter((t) => t?.label?.trim());
    let step = 0;
    const next = () => ++step;

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

          {emergencyText ? (
            <div className={`flex gap-4 rounded-xl bg-neutral-950 p-5 text-white sm:p-6 ${heading || intro ? "mt-8" : ""}`}>
              <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="mt-0.5 size-6 shrink-0 text-indigo-300">
                <path fillRule="evenodd" d="M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495ZM10 5a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 10 5Zm0 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" clipRule="evenodd" />
              </svg>
              <div className="text-sm leading-6">
                <p className="font-semibold text-white">Emergency? Don&rsquo;t use this form.</p>
                <p className="mt-1 text-pretty text-neutral-200">{emergencyText}</p>
                <a
                  href="tel:911"
                  className="mt-3 inline-flex min-h-11 items-center rounded-lg bg-white px-4 font-semibold text-neutral-950 hover:bg-indigo-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white"
                >
                  Call 911
                </a>
              </div>
            </div>
          ) : null}

          <form action={formAction || undefined} method="post" encType="multipart/form-data" className={`space-y-12 ${heading || intro || emergencyText ? "mt-12" : ""}`}>
            <p className="text-sm leading-6 text-neutral-600">All fields are required unless marked optional.</p>

            {types.length ? (
              <fieldset>
                <legend className={stepLegend}>
                  <StepNum n={next()} />
                  What&rsquo;s the problem?
                </legend>
                <div className="mt-5 grid grid-cols-1 gap-3 sm:grid-cols-2">
                  {types.map((t, i) => (
                    <label
                      key={`${t.label}-${i}`}
                      className="relative flex min-h-16 cursor-pointer flex-col justify-center rounded-xl bg-white py-3 pr-12 pl-4 ring-1 ring-neutral-300 transition select-none ring-inset 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="request_type" value={t.label} required className="peer sr-only" />
                      <span className="text-base leading-6 font-semibold text-neutral-950">{t.label}</span>
                      {t.description ? <span className="text-sm leading-5 text-neutral-600">{t.description}</span> : null}
                      <span aria-hidden="true" className="absolute top-1/2 right-4 size-5 -translate-y-1/2 rounded-full ring-1 ring-neutral-400 ring-inset peer-checked:ring-6 peer-checked:ring-indigo-600" />
                    </label>
                  ))}
                </div>
              </fieldset>
            ) : null}

            <fieldset>
              <legend className={stepLegend}>
                <StepNum n={next()} />
                Where is it?
              </legend>
              <div className="mt-5 grid grid-cols-1 gap-6 sm:grid-cols-2">
                <div className="sm:col-span-2">
                  <label htmlFor={`${uid}-address`} className={labelClass}>Street address or block</label>
                  <input
                    id={`${uid}-address`}
                    name="address"
                    type="text"
                    required
                    autoComplete="off"
                    aria-describedby={`${uid}-address-hint`}
                    placeholder="e.g. 1200 block of Bardstown Rd"
                    className={`mt-2 ${inputClass}`}
                  />
                  <p id={`${uid}-address-hint`} className="mt-2 text-sm leading-6 text-neutral-600">
                    A nearby house number is fine if you don&rsquo;t know the exact address.
                  </p>
                </div>
                <div>
                  <label htmlFor={`${uid}-cross`} className={labelClass}>Nearest cross street {optional}</label>
                  <input id={`${uid}-cross`} name="cross_street" type="text" autoComplete="off" className={`mt-2 ${inputClass}`} />
                </div>
                <div>
                  <label htmlFor={`${uid}-landmark`} className={labelClass}>Landmark {optional}</label>
                  <input id={`${uid}-landmark`} name="landmark" type="text" autoComplete="off" placeholder="e.g. across from the library" className={`mt-2 ${inputClass}`} />
                </div>
              </div>
            </fieldset>

            <fieldset>
              <legend className={stepLegend}>
                <StepNum n={next()} />
                Tell us more
              </legend>
              <div className="mt-5 space-y-6">
                <div>
                  <label htmlFor={`${uid}-desc`} className={labelClass}>Description</label>
                  <textarea
                    id={`${uid}-desc`}
                    name="description"
                    rows={4}
                    required
                    minLength={10}
                    aria-describedby={`${uid}-desc-hint`}
                    className={`mt-2 ${inputClass}`}
                  />
                  <p id={`${uid}-desc-hint`} className="mt-2 text-sm leading-6 text-neutral-600">
                    Size, which lane or side of the street, and how long it&rsquo;s been there.
                  </p>
                </div>
                {allowPhoto !== false ? (
                  <div>
                    <label htmlFor={`${uid}-photo`} className={labelClass}>Photo {optional}</label>
                    <input
                      id={`${uid}-photo`}
                      name="photo"
                      type="file"
                      accept="image/*"
                      aria-describedby={`${uid}-photo-hint`}
                      className="mt-2 block w-full rounded-lg text-sm text-neutral-700 ring-1 ring-neutral-300 ring-inset file:mr-4 file:min-h-11 file:cursor-pointer file:rounded-l-lg file:border-0 file:bg-neutral-100 file:px-4 file:py-2.5 file:text-sm file:font-semibold file:text-neutral-900 hover:file:bg-neutral-200 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
                    />
                    <p id={`${uid}-photo-hint`} className="mt-2 text-sm leading-6 text-neutral-600">
                      One image, up to 10 MB. Please don&rsquo;t include faces or license plates.
                    </p>
                  </div>
                ) : null}
              </div>
            </fieldset>

            <fieldset aria-describedby={anonymousNote ? `${uid}-anon` : undefined}>
              <legend className={stepLegend}>
                <StepNum n={next()} />
                <span>
                  Your contact details <span className="text-base font-normal text-neutral-600">(optional)</span>
                </span>
              </legend>
              {anonymousNote ? (
                <p id={`${uid}-anon`} className="mt-2 text-sm leading-6 text-pretty text-neutral-600 sm:pl-11">
                  {anonymousNote}
                </p>
              ) : null}
              <div className="mt-5 grid grid-cols-1 gap-6 sm:grid-cols-3">
                <div>
                  <label htmlFor={`${uid}-name`} className={labelClass}>Name {optional}</label>
                  <input id={`${uid}-name`} name="name" type="text" autoComplete="name" className={`mt-2 ${inputClass}`} />
                </div>
                <div>
                  <label htmlFor={`${uid}-email`} className={labelClass}>Email {optional}</label>
                  <input id={`${uid}-email`} name="email" type="email" autoComplete="email" inputMode="email" className={`mt-2 ${inputClass}`} />
                </div>
                <div>
                  <label htmlFor={`${uid}-phone`} className={labelClass}>Phone {optional}</label>
                  <input id={`${uid}-phone`} name="phone" type="tel" autoComplete="tel" inputMode="tel" className={`mt-2 ${inputClass}`} />
                </div>
              </div>
            </fieldset>

            <div className="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-12 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 request"}
              </button>
              {afterSubmitNote ? <p className="text-sm leading-6 text-pretty text-neutral-600">{afterSubmitNote}</p> : null}
            </div>
          </form>
        </div>
      </section>
    );
  },
};
```
