{% import 'macro/accordion.html' as accordion %}
{% import 'macro/card.html' as card %}

<div class="container">
  <div class="card mb-3">
    <div class="card-header">
      <h5 class="mb-0"><i class="ri-file-line"></i> Instructions</h5>
    </div>
    <div class="accordion accordion-flush" id="instructions">
      {{ accordion.header('Management', 'instructions-rename', 'instructions', expanded=true) }}
      {% if item.rebrickable %}
        <div class="d-flex justify-content-center">
          {% with item=item.rebrickable %}
            {% include 'set/mini.html' %}
          {% endwith %}
        </div>
      {% endif %}
      <form action="{{ url_for('instructions.do_rename', name=item.filename) }}" method="post">
        {% if error %}<div class="alert alert-danger" role="alert"><strong>Error:</strong> {{ error }}.</div>{% endif %}
        <div class="mb-3">
          <label for="filename" class="form-label">File name</label> (current name: <code>{{ item.filename }}</code>)
          <div class="input-group">
            <input type="input" class="form-control" id="filename" name="filename" value="{{ item.name }}" autocomplete="off">
            <span class="input-group-text">{{ item.extension }}</span>
          </div>
        </div>
        <div class="text-end">
          <a class="btn btn-primary" href="{{ url_for('instructions.list') }}" role="button"><i class="ri-arrow-left-long-line"></i> Back to the instructions</a>
          <button type="submit" class="btn btn-primary"><i class="ri-edit-line"></i> Rename</button>
        </div>
      </form>
      {{ accordion.footer() }}
    </div>
    <div class="card-footer"></div>
  </div>
</div>
