{% extends "report/template_upsert_base.html" %}
{% load report_filters i18n %}

{% block title %}
    {% blocktrans with page_title=report.page_title|title %}Page {{ page_title }}{% endblocktrans %}
{% endblock %}

{% block modals %}
    {% startpartial modal %}
        <div class="modal modal-blur fade" id="userModal" tabindex="-1">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title">User</h5>
                        <button type="button"
                                class="btn-close"
                                data-bs-dismiss="modal"
                                aria-label="Close"></button>
                    </div>
                    <div class="modal-body">
                        <div class="card card-borderless">
                            <div class="card-body">
                                <h3 class="card-title">{{ user.full_name }}</h3>
                                <div>{{ user.username }}</div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn me-auto" data-bs-dismiss="modal">Close</button>
                    </div>
                </div>
            </div>
        </div>
    {% endpartial %}
    <div id="userModalContainer"></div>
{% endblock %}

{% block content %}
    <div>صفحه {{ report.page_title }}</div>
    {% show_page_report %}
{% endblock content %}

{% block js %}
    <script>
        document.addEventListener('test-link', e => {
            console.log(e.type, event.detail)
        });
        document.addEventListener('open-user-modal', e => htmx.ajax('GET', "", {
            target: '#userModalContainer',
            values: {
                pk: event.detail.pk,
                modal: true
            }
        }).then(() => $('#userModal').modal('show')));
    </script>
{% endblock js %}
