$(document).ready(function() {
    $(document).on('click', '#refreshWebhooksButton', function(e) {
        $('#webhooksTableLoader').html(whLoader);
        $.ajax({
            url: '/clients/admin/ajax/fetch-webhooks.php',
            method: 'POST',
            data: {},
            success: function (data) {
                // console.log(data);
                // $('#webhooksTableLoader').html('<i class="bi bi-arrow-repeat"></i>');
                $('#webhooksTableContainer').html(data);
                new DataTable('#webhooksDT', {
                    // dom: '<"d-flex justify-content-between my-2"<"d-flex me-auto"l><"d-flex ms-auto"f>>',
                    layout: {
                        topStart: {
                            pageLength: {
                                menu: [10, 25, 50, 100],
                                text: '_MENU_'
                            }
                        },
                        topEnd: {
                            search: {
                                text: '',
                                placeholder: 'Search'
                            }
                        },
                        bottomStart: null
                    },
                    pageLength: 50
                });
            },
            error: function (e) {
            }
        });
    });

    new DataTable('#webhooksDT', {
        // dom: '<"d-flex justify-content-between my-2"<"d-flex me-auto"l><"d-flex ms-auto"f>>',
        layout: {
            topStart: {
                pageLength: {
                    menu: [10, 25, 50, 100],
                    text: '_MENU_'
                }
            },
            topEnd: {
                search: {
                    text: '',
                    placeholder: 'Search'
                }
            },
            bottomStart: null
        },
        pageLength: 50
    });
});