<div>
  <h2 class="mb-8 text-xl text-center title text-primary-400">
    {@title}
  </h2>
  <.form
    :let={f}
    for={@changeset}
    id="invite-form"
    class="flex flex-col justify-center items-center space-y-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4"
    phx-target={@myself}
    phx-change="validate"
    phx-submit="save"
    phx-hook="CtrlEnter"
  >
    <div
      :if={@changeset.action && not @changeset.valid?}
      class="col-span-3 text-center invalid-feedback"
    >
      {changeset_errors(@changeset)}
    </div>

    {label(f, :name, gettext("name"),
      class: "title text-lg text-primary-400",
      phx_debounce: 300
    )}
    {text_input(f, :name,
      class: "input input-primary col-span-2",
      phx_debounce: 300,
      required: true
    )}
    {error_tag(f, :name, "col-span-3")}

    {label(f, :uses_left, gettext("uses left"),
      class: "title text-lg text-primary-400",
      phx_debounce: 300
    )}
    {number_input(f, :uses_left,
      min: 0,
      class: "input input-primary col-span-2",
      phx_debounce: 300
    )}
    {error_tag(f, :uses_left, "col-span-3")}

    <span class="col-span-3 italic text-center text-primary-500">
      {gettext(~s/leave "uses left" blank to make invite unlimited/)}
    </span>

    {submit(dgettext("actions", "save"),
      class: "mx-auto btn btn-primary col-span-3",
      phx_disable_with: dgettext("prompts", "saving...")
    )}
  </.form>
</div>