{% extends request.content_only|yesno:"empty.html,base.html" %}

{% load crispy_forms_filters crispy_forms_tags i18n %}

{% block content %}
    <form method="post">
        <div id="form-content">
            {% csrf_token %}
            {{ form|crispy }}
            {% crispy participation_form %}
        </div>
        <button class="btn btn-success" type="submit">{% trans "Update" %}</button>
    </form>
{% endblock content %}

{% block extrajavascript %}
    <script>
        const tournamentSelect = document.getElementById('id_tournament')
        const idfWarningBanner = document.getElementById('idf_warning_banner')
        const unifiedRegistrationTournamentIds = idfWarningBanner.getAttribute('data-tid-unified').split(',')
        if (idfWarningBanner.getAttribute('data-tid-unified') !== "") {
            function updateIDFWarningBannerVisibility() {
                const tid = tournamentSelect.value
                if (unifiedRegistrationTournamentIds.includes(tid))
                    idfWarningBanner.classList.remove('d-none')
                else
                    idfWarningBanner.classList.add('d-none')
            }

            tournamentSelect.addEventListener('change', updateIDFWarningBannerVisibility)
            updateIDFWarningBannerVisibility()
        }
        else {
            idfWarningBanner.classList.add('d-none')
        }
    </script>
{% endblock %}
