<%- 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);">Certificate Apps </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 ID</th>
                                <th>Future</th>
                                <th>100+ servers?</th>
                                <th>Invite</th>
                                <th class="text-center dt-no-sorting">Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            <% apps.map(b => {%>
                            <tr>
                                <td><%= b.botID %></td>
                                <td><%= b.future %></td>
                                <td>Yes</td>
                                <td><button onclick="window.location.href='https://discord.com/api/oauth2/authorize?client_id=<%= b.botID %>&permissions=0&scope=bot'" class="btn btn-primary btn-sm">Perm 0</button>
                                    <button onclick="window.location.href='https://discord.com/api/oauth2/authorize?client_id=<%= b.botID %>&permissions=8&scope=bot" class="btn btn-info btn-sm">Perm 8</button> </td>
                               
                                <td class="text-center">
                                        <button onclick="window.location.href='/admin/certificate/give/<%= b.botID %>'" class="btn btn-success btn-sm">Give Certificate</button>
                                        <button onclick="window.location.href='/admin/certificate/delete/<%= b.botID %>'" class="btn btn-danger btn-sm">Delete Certificate</button>
                                    </td>
                            </tr>
                            <% }) %>
                        </tbody>
                        <tfoot>
                            <tr>
                                <th>Bot ID</th>
                                <th>Future</th>
                                <th>100+ servers?</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 2022 &copy electron.tk - All right reserved.'
        }).then((result) => {
      if (result.isConfirmed) {
        window.location.href = '/admin/certificate-apps';
      }
    })
        }
        if(urlParams.has('error') && urlParams.get('error')){
        Swal.fire({
         icon: 'error',
         title: 'Oops...',
         text: urlParams.get('message'),
         footer: 'Copyright 2022 &copy electron.tk - All right reserved.'
        }).then((result) => {
      if (result.isConfirmed) {
        window.location.href = '/admin/certificate-apps';
      }    
    })
        }
</script>
</div></div>
<%- include('static/foot.ejs', { bot,user,path}) %>
