{{ define "repo/pulls/fragments/pullEdit" }}
<form
  hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/edit"
  hx-trigger="submit, keydown[(ctrlKey || metaKey) && key=='Enter'] from:(find input[type=text],find textarea)"
  hx-swap="none"
  hx-indicator="find button[type=submit]"
>
  <div class="flex flex-col gap-2">
    <div>
      <label for="title">Title</label>
      <input type="text" name="title" id="title" class="w-full" value="{{ .Pull.Title }}" />
    </div>
    <div>
      <label for="body">Body</label>
      {{ template "fragments/markdownEditor"
        (dict "Name"        "body"
              "Value"       .Pull.Body
              "Rows"        15
              "Placeholder" "Describe your pull request. Markdown is supported.") }}
    </div>
    <div class="flex justify-between">
      <div id="pulls" class="error"></div>
      <div class="flex gap-2 items-stretch">
        <a
          class="btn-flat text-red-500 dark:text-red-400 flex items-center gap-2 no-underline hover:no-underline"
          type="button"
          href="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}"
        >
          {{ i "x" "size-4" }}
          Cancel
        </a>
        <button type="submit" class="btn-create-flat group flex items-center gap-2">
          {{ i "loader-circle" "size-4 animate-spin hidden group-[.htmx-request]:inline" }}
          {{ i "check" "size-4 inline group-[.htmx-request]:hidden" }}
          Save
        </button>
      </div>
    </div>
  </div>
</form>
{{ end }}
