<% unless @turbo_status %>
  <div class="alert alert-danger">
    There was an error contacting Redis: please make sure the Redis server is running.
  </div>
<% end %>

<% if @prompts.any? %>
  <p>Interact with Echo by selecting a saved prompt to use with this Issue. You can edit the prompt before sending it, any changes are one-off and won't affect the saved prompt template.</p>

  <div class="row" data-controller="dradis--plugins--echo--prompt-selector">
    <div class="col-12 mb-3">
      <p class="form-label">Saved Prompts</p>
      <select class="form-select">
        <% @prompts.each do |prompt| %>
          <option
            data-combobox-option-icon="fa-solid <%= prompt.icon %>"
            value="<%= echo.preview_project_prompt_path(current_project, prompt.id, type: @type, record: @record.id) %>">
            <%= prompt.title %>
          </option>
        <% end %>
      </select>
    </div>

    <div class="col-12">
      <p class="form-label">Selected Prompt</p>
      <turbo-frame id="echo-prompt-preview" data-dradis--plugins--echo--prompt-selector-target="frame">
      </turbo-frame>
    </div>
  </div>
<% else %>
  <%= render 'shared/empty_state',
    actions_partial: 'dradis/plugins/echo/prompts/empty_state_actions',
    docs_link: 'https://dradis.com/support/guides/echo/prompts.html',
    name: 'prompt',
    text: 'Create reusable prompts to standardize how your team analyzes findings, writes reports, summarizes vulnerabilities, and more. Save time by building a library of prompts that anyone on your team can use for consistent results.'
  %>
<% end %>
