{% extends "aasrp/base.html" %}

{% load i18n %}

{% block page_title %}
    {% translate "SRP requests" %} » {% translate "Ship Replacement" %}
{% endblock %}

{% block aasrp_body %}
    {% include "aasrp/partials/view-requests/overview.html" %}
    {% include "aasrp/partials/view-requests/bulk-actions.html" %}
    {% include "aasrp/partials/view-requests/requests.html" %}

    {% include "aasrp/modals/view-requests/request-details.html" %}
    {% include "aasrp/modals/view-requests/mark-complete.html" %}
    {% include "aasrp/modals/view-requests/accept-request.html" %}
    {% include "aasrp/modals/view-requests/bulk-accept-requests.html" %}
    {% include "aasrp/modals/view-requests/accept-rejected-request.html" %}
    {% include "aasrp/modals/view-requests/reject-request.html" %}
    {% include "aasrp/modals/view-requests/delete-request.html" %}
    {% include "aasrp/modals/view-requests/bulk-delete-requests.html" %}
{% endblock %}

{% block extra_css %}
    {% include "bundles/datatables-css-bs5.html" %}
    {% include "bundles/checkbox-css.html" %}
    {% include "aasrp/bundles/x-editable-css.html" %}

    {% include "aasrp/bundles/aa-srp-css.html" %}
    {% include "aasrp/bundles/aa-srp-form-css.html" %}
{% endblock %}

{% block extra_javascript %}
    {% translate "Request status" as translateRequestStatus %}
    {% translate "Ship" as translateShip %}
    {% translate "Character" as translateCharacter %}
    {% translate "Click here to change the payout amount for this SRP request." as translateChangeSrpPayoutAmount %}
    {% translate "Enter SRP payout value" as translateChangeSrpPayoutHeader %}
    {% translate "Empty values are not allowed" as translateEditableValidate %}
    {% translate "This field is required." as translateFieldRequired %}
    {% translate "Requestor" as translateRequestor %}
    {% translate "Insurance payout" as translateInsurancePayout %}
    {% translate "Additional information" as translateAdditionalInformation %}
    {% translate "Reject information" as translateRejectInformation %}

    <script>
        /**
         * passing some settings to our JS
         */
        const aaSrpJsSettingsOverride = {
            srpCode: '{{ srp_link.srp_code }}',
            csrfToken: '{{ csrf_token }}',
            url: {
                requestsForSrpLink: '{% url "aasrp:ajax_srp_link_view_requests_data" srp_link.srp_code %}',
                changeSrpAmount: '{% url "aasrp:ajax_srp_request_change_payout" srp_link.srp_code 'SRP_REQUEST_CODE' %}'
            },
            translation: {
                filter: {
                    requestStatus: '{{ translateRequestStatus|escapejs }}',
                    ship: '{{ translateShip|escapejs }}',
                    character: '{{ translateCharacter|escapejs }}'
                },
                changeSrpPayoutAmount: '{{ translateChangeSrpPayoutAmount|escapejs }}',
                changeSrpPayoutHeader: '{{ translateChangeSrpPayoutHeader|escapejs }}',
                editableValidate: '{{ translateEditableValidate|escapejs }}',
                modal: {
                    srpDetails: {
                        body: {
                            requestor: '{{ translateRequestor|escapejs }}',
                            character: '{{ translateCharacter|escapejs }}',
                            ship: '{{ translateShip|escapejs }}',
                            insurance: '{{ translateInsurancePayout|escapejs }}',
                            additionalInformation: '{{ translateAdditionalInformation|escapejs }}',
                            rejectInformation: '{{ translateRejectInformation|escapejs }}'
                        }
                    },
                    form: {
                        error: {
                            fieldRequired: '{{ translateFieldRequired|escapejs }}'
                        }
                    }
                }
            }
        };
    </script>

    {% include "bundles/clipboard-js.html" %}
    {% include "aasrp/bundles/aa-srp-js.html" %}

    <script>
        new ClipboardJS('.copy-to-clipboard')
            .on('success', (e) => {
                e.clearSelection();
            })
            .on('error', (e) => {
                console.error('Action:', e.action);
                console.error('Trigger:', e.trigger);
            });
    </script>

    {% include "aasrp/bundles/x-editable-js.html" %}
    {% include "bundles/moment-js.html" with locale=True %}
    {% include "bundles/datatables-js-bs5.html" %}
    {% include "bundles/filterdropdown-js.html" %}
    {% include "aasrp/bundles/view-requests-js.html" %}
{% endblock %}
