import { Search } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Field, Input } from "@/components/ui/input";

/**
 * Certificate verification form.
 *
 * A plain GET form pointing at `/verifikasi`, with no JavaScript involved. The
 * public page must work for a parent on a locked-down school laptop and for
 * anyone arriving from a QR code, so this deliberately does not depend on a
 * server action or a client component. The result page does the normalisation
 * and the lookup.
 */
export function VerifyForm({
  initialSerial = "",
  className,
}: {
  initialSerial?: string;
  className?: string;
}) {
  return (
    <form action="/verifikasi" method="get" className={className}>
      <Field
        label="Nomor sertifikat"
        htmlFor="nomor"
        hint="Tercetak di bagian bawah sertifikat, contoh: TC-CERT-2026-K7M2Q9"
      >
        <div className="flex flex-col gap-2 sm:flex-row">
          <Input
            id="nomor"
            name="nomor"
            defaultValue={initialSerial}
            placeholder="TC-CERT-…"
            autoComplete="off"
            spellCheck={false}
            className="font-mono uppercase sm:flex-1"
            required
          />
          <Button type="submit">
            <Search className="size-4" />
            Verifikasi
          </Button>
        </div>
      </Field>
    </form>
  );
}
