$(document).ready( function () {
    $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });
    
    var allUserAccessLogsListTableUrl = $("#allUserAccessLogsListTable").attr('data-ajax-url');
    var allUserAccessLogsListTableEmptyText = $("#allUserAccessLogsListTable").attr('data-empty-text');
    $("#allUserAccessLogsListTable").DataTable({
        processing: true,
        serverSide: true,
        ajax: {
            url: allUserAccessLogsListTableUrl,
            type: 'post',
            "dataSrc": function ( json ) {
                for (var i = 0; i < json.data.length; i++) {
                    $.each( json.data[i], function( key, value ) {
                        json.data[i][key] = value ? value : '-';
                    });
                }

                return json.data;
            }    
        },
        columns: [
            {data: 'email', name: 'users.email'},
            {data: 'date', name: 'user_access_logs.created_at'},
            {data: 'time', name: 'user_access_logs.created_at'},
            {data: 'event', name: 'user_access_logs.event'},
            {data: 'description', name: 'user_access_logs.description'},
            {data: 'status', name: 'user_access_logs.status'},
        ],
        order: [[1, "desc"]],
        searchDelay: 500,
        "language": {
            "paginate": {
                "next": ">",         // Text for the "Next" page button
                "previous": "<"  // Text for the "Previous" page button
            },
              "emptyTable": allUserAccessLogsListTableEmptyText
            // Add more text customizations if needed
        }
    });
} );