{{!
    This file is part of Moodle - http://moodle.org/

    Moodle is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Moodle is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{!
    @template block_deft/activation

    This template renders the main content area for the deft choice block.

    Example context (json):
    {
        "url": "https://deftly.us/admin/tool/deft/message.php?id_token=dlasfjlewqrlj"
    }
}}

<div id="activate_deft" class="container-fluid p-0">
    <div>Please automatically activate service by clicking the button below</div>
    <a class="btn btn-secondary" href="{{ url }}">Activate</a>
</div>
{{# js }}
require(['jquery', 'core/modal_factory', 'core/modal_events', 'core/str'], function($, ModalFactory, ModalEvents, Str) {
    var trigger = $('#activate_deft');
    ModalFactory.create({
        title: Str.get_string('activate', 'block_deft'),
        type: ModalFactory.types.SAVE_CANCEL,
        buttons: {save: Str.get_string('confirm')},
        body: Str.get_string('activatemessage', 'block_deft'),
    }, trigger)
    .done(function(modal) {
        modal.getRoot().on(ModalEvents.save, function(e) {
            e.preventDefault();
            window.location.href = '{{ url }}';
        });
    });
});
{{/ js }}
