{% extends 'layouts/app.html' %}
{% import 'macros/form.html'as f with context %}
{% import 'macros/modal-window.html' as modal with context %}
{% import 'macros/rating.html' as r %}
{% import 'macros/status.html' as s %}
{% block body %}

    <div class="row md-margin-top">
        <div class="left-block col-md-4">
            <div class="card" style="width: 18rem;">
                <img class="card-img-top" src="{{ url_for('static', filename=icon_path) }}" alt="Card image cap">
                <div class="card-body">
                    <h5 class="card-title">{{ book.title }}</h5>
                    <p class="card-text">{{ book.desc }}</p>
                    <h4>Genre:</h4><a href="#" class="badge badge-success">{{ book.genre.title }}</a>
                    <h4>Status: {{ s.render_status(book.status, book_id=book.id, genre=book.genre, title=book.title) }}</h4>
                    <a href="{{ url_for('library.download_book',
                    genre=book.genre.title, book_id=book.id, title=book.title) }}" class="btn btn-primary btn-block">download</a>
                    <a href="#" class="btn btn-primary btn-block">send to telegram</a>
                    <button type="button" class="btn btn-danger btn-block" data-toggle="modal"
                        data-target="#DeleteBook{{ book.id|string }}">
                    delete
                </button>
                {% call modal.render_modal_window('DeleteBook'+ book.id|string,'library.delete_book',
                                                           btn_class='danger', btn_comfirm_text='DELETE', title_form='DELETE BOOK',
                                                           genre=book.genre.title, book_id=book.id, title=book.title) %}
                    <p>Are you sure about that?</p>
                {% endcall %}
                </div>
            </div>
            <div class="jumbotron sm-margin-top">
                <div class="d-flex justify-content-between">
                    <h3>Rating</h3>
                    <a href="{{ url_for('library.edit_book', book_id=book.id, genre=book.genre.title, title=book.title ) }}" ><i class="fas fa-cog fa-2x" ></i></a>
                </div>
                {{ r.rander_set_rating(book.rating, book) }}
                <h3>Change status</h3>
                {% for status in [('success','Done'), ('danger','Todo'),('warning','In progress'), ('secondary','Save')] %}
                    {% call f.form_tag('library.change_status', genre=book.genre.title, book_id=book.id, title=book.title, status=status[1]) %}
                    <button class="badge badge-{{ status[0] }}">{{ status[1] }}</button>
                    {% endcall %}
                {% endfor %}
            </div>
        </div>
        <div class="right-block col-md-8 md-margin-button ">
            {% block note %}
            {% endblock %}
        </div>
    </div>
{% endblock %}