<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.12.9/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script src="{{ asset ('js/datatables-demo.js') }}"></script>
<script src="{{ asset ('datatables/jquery.dataTables.min.js') }}"></script>
<script src="{{ asset ('datatables/dataTables.bootstrap4.min.js') }}"></script>

<!-- Toastr CSS and JS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>

<!-- SweetAlert CSS and JS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sweetalert2@10.0.1/dist/sweetalert2.min.css">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10.0.1/dist/sweetalert2.all.min.js"></script>

<script>
    $(document).ready(function () {
        toastr.options = {
            "closeButton": true
        };

        @if(Session::has('success'))
            toastr.success('{{ Session::get('success') }}', 'Success');
        @endif

        @if(Session::has('error'))
            toastr.error('{{ Session::get('error') }}', 'Error');
        @endif

        @if(Session::has('status'))
            toastr.success('{{ Session::get('status') }}', 'Success');
        @endif

        @if(Session::has('resent'))
            toastr.success('Email verifikasi telah terkirim ulang.', 'Success');
        @endif
    });
</script>

<script>
    function notificationBeforeDelete(event, el) {
        event.preventDefault();
        const deleteUrl = $(el).attr('href'); // Mengambil URL penghapusan dari atribut href pada elemen a
        Swal.fire({
            title: 'Apakah anda yakin?',
            text: 'Anda akan menghapus data ini!',
            icon: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#4CAF50',
            cancelButtonColor: '#d33',
            confirmButtonText: 'Ya, Hapus!',
            cancelButtonText: 'Batal',
        }).then((result) => {
            if (result.isConfirmed) {
                window.location.href = deleteUrl; // Mengarahkan ke URL penghapusan
            }
        });
    }
</script>