{% extends "core.html" %}

{% block main %}
<link href="/css/books.css" rel="stylesheet">
<link href="/css/upload.css" rel="stylesheet">

<section id="books">
	{% if account is not empty %}
	{% if account.permissions.books is defined and account.permissions.books == 1 %}
	<form class="upload unselectable" action="/storage/books/write" enctype="multipart/form-data" method="POST">
		<input type="file" name="books[]" accept=".pdf" oninput="this.parentElement.submit();" multiple="true">
		<p>+</p>
	</form>
	{% endif %}
	{% endif %}
	{% for book in books %}
	<article class="book">
		{% if account.permissions.books is defined and account.permissions.books == 1 %}
		<button onclick="return remove({{ book.id|e }}, this.parentElement);" title="Удалить"><i class="fa-solid fa-xmark"></i></button>
		{% endif %}
		<img src="/storage/books/{{ book.id|e }}/0" class="unselectable" alt='Обложка книги "{{ book.title|e }}"'>
		<h4><a href="/books/{{ book.id|e }}">{{ book.title|e }}</a></h3>
	</article>
	{% endfor %}
	{% if account.permissions.books is defined and account.permissions.books == 1 %}
	<script type="text/javascript" src="/js/delete.js"></script>
	{% endif %}
</section>
{% endblock %}
