<%- include('static/head.ejs', { bot,user,path})  %>
<div id="content" class="main-content">
    <div class="layout-px-spacing">

        <div class="page-header">
            <nav class="breadcrumb-one" aria-label="breadcrumb">
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="javascript:void(0);">Bot List</a></li>
                    <li class="breadcrumb-item active"><a href="javascript:void(0);">UnApproved Bots</a></li>
                </ol>
            </nav>
        </div>
        
        <div class="row layout-top-spacing" id="cancel-row">
        
            <div class="col-xl-12 col-lg-12 col-sm-12  layout-spacing">
                <div class="widget-content widget-content-area br-6">
                    <table id="default-ordering" class="table table-hover" style="width:100%">
                        <thead>
                            <tr>
                                <th>Bot Name</th>
                                <th>Owner</th>
                                <th>Prefix</th>
                                <th>Invite</th>
                                <th class="text-center dt-no-sorting">Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            <% botdata.filter(a => a.status === "UnApproved").map(b => {%>
                            <tr>
                                <td><%= b.username %></td>
                                <td><%= b.ownerName %></td>
                                <td><%= b.prefix %></td>
                                <td><button onclick="newtab('https://discord.com/api/oauth2/authorize?client_id=<%= b.botID %>&permissions=0&scope=bot applications.commands')" class="btn btn-primary btn-sm">Perm 0</button>
                                    <button onclick="newtab('https://discord.com/api/oauth2/authorize?client_id=<%= b.botID %>&permissions=8&scope=bot applications.commands')" class="btn btn-info btn-sm">Perm 8</button> </td>
                                <td class="text-center">
                                    <button onclick="newtab('/admin/confirm/<%= b.botID %>')" class="btn btn-success btn-sm">Confirm</button>
                                    <button onclick="newtab('/admin/decline/<%= b.botID %>')" class="btn btn-danger btn-sm">Delete</button>
                                </td>
                            </tr>
                            <% }) %>
                        </tbody>
                        <tfoot>
                            <tr>
                                <th>Bot Name</th>
                                <th>Owner</th>
                                <th>Prefix</th>
                                <th>Invite</th>
                                <th class="invisible"></th>
                            </tr>
                        </tfoot>
                    </table>
                </div>
            </div>
        </div>
        <script>
            var urlParams = new URLSearchParams(window.location.search);
            if(urlParams.has('success') && urlParams.get('success')){
            Swal.fire({
             icon: 'success',
             title: 'Succesfull...',
             closeOnConfirm: false,
             text: urlParams.get('message'),
             footer: 'Copyright 2023 &copy vCodes.xyz - All right reserved.'
            }).then((result) => {
          if (result.isConfirmed) {
            window.location.href = '/admin/unapproved';
          }
        })
            }
            if(urlParams.has('error') && urlParams.get('error')){
            Swal.fire({
             icon: 'error',
             title: 'Oops...',
             text: urlParams.get('message'),
             footer: 'Copyright 2023 &copy vCodes.xyz - All right reserved.'
            }).then((result) => {
          if (result.isConfirmed) {
            window.location.href = '/admin/unapproved';
          }    
        })
            }
           </script>
        </div></div>
        <%- include('static/foot.ejs', { bot,user,path}) %>
