@props([
    'is_custom' => 'no',
])
<div id="confirmationModal" class="modal fade @if($is_custom == 'yes') custom--modal @endif" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">@lang('Confirmation Alert!')</h5>
                <button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
                    <i class="las la-times"></i>
                </button>
            </div>
            <form action="" method="POST">
                @csrf
                <div class="modal-body">
                    <p class="question"></p>
                </div>
                <div id="extra-fields"></div>
                <div class="modal-footer">
                    <button type="button" class="btn @if($is_custom == 'yes') btn--sm btn--danger @else btn--dark @endif" data-bs-dismiss="modal">@lang('No')</button>
                    <button type="submit" class="btn btn--primary @if($is_custom == 'yes') btn--sm bg--base @endif">@lang('Yes')</button>
                </div>
            </form>
        </div>
    </div>
</div>

@push('script')

<script>
    (function ($) {
        "use strict";
        $(document).on('click','.confirmationBtn', function () {
            var modal   = $('#confirmationModal');
            let data    = $(this).data();
            modal.find('.question').text(`${data.question}`);
            modal.find('form').attr('action', `${data.action}`);
            if(data.values){
                $('#extra-fields').html('');
                $.each(data.values, function(key, value){
                    $('#extra-fields').append(`<input type="hidden" name="${key}" value="${value}" />`);
                });
            }
            modal.modal('show');
        });
    })(jQuery);
</script>
@endpush
