<!--Canopy - The next generation of stoner streaming software
Copyright (C) 2024  Rainbownapkin and the TTN Community

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.-->
<div id="admin-user-list-div" class="admin-list-div">
    <h3>User List:</h3>
    <div class="dynamic-container">
        <table id="admin-user-list-table" class="admin-list-table">
        <tr id="admin-user-list-entry-title" class="admin-list-entry-title-row">
                <td id="admin-user-list-entry-img-title" class="admin-list-entry-title admin-list-entry-item admin-list-entry-img-title">
                    <h3>Img</h3>
                </td>
                <td id="admin-user-list-entry-id-title" class="admin-list-entry-title admin-list-entry-item not-first-col">
                    <h3>ID</h3>
                </td> 
                <td id="admin-user-list-entry-name-title" class="admin-list-entry-title admin-list-entry-item not-first-col">
                    <h3>Name</h3>
                </td> 
                <td id="admin-user-list-entry-rank-title" class="admin-list-entry-title admin-list-entry-item not-first-col">
                    <h3>Rank</h3>
                </td> 
                <td id="admin-user-list-entry-mail-title" class="admin-list-entry-title admin-list-entry-item not-first-col">
                    <h3>E-Mail</h3>
                </td>
                <td id="admin-user-list-entry-date-title" class="admin-list-entry-title admin-list-entry-item not-first-col">
                    <h3>Sign-Up<br>Date</h3>
                </td>
                <td id="admin-user-list-entry-control-title" class="admin-list-entry-title admin-list-entry-item not-first-col">
                    &nbsp;
                </td>
            </tr>
        <% userList.forEach((curUser) => { %>
            <tr id="admin-user-list-entry-<%- curUser.user %>" class="admin-list-entry">
                <td id="admin-user-list-entry-img-<%- curUser.user %>" class="admin-list-entry-item">
                    <a href="/profile/<%- curUser.user %>" class="admin-list-entry-item">
                        <img id="admin-user-list-entry-img-<%- curUser.user %>" class="admin-list-entry-item" src="<%- curUser.img %>">
                    </a>
                </td>
                <td id="admin-user-list-entry-id-<%- curUser.user %>" class="admin-list-entry-item not-first-col">
                    <a href="/profile/<%- curUser.user %>" class="admin-list-entry-item">
                        <%- curUser.id %>
                    </a>
                </td>
                <td id="admin-user-list-entry-name-<%- curUser.user %>" class="admin-list-entry-item not-first-col">
                    <a href="/profile/<%- curUser.user %>" class="admin-list-entry-item">
                        <%- curUser.user %>
                    </a>
                </td>
                <td id="admin-user-list-entry-rank-<%- curUser.user %>" class="admin-list-entry-item not-first-col">
                    <% if(rankEnum.indexOf(curUser.rank) < rankEnum.indexOf(user.rank)){%>
                        <select id="admin-user-list-rank-select-<%- curUser.user %>" class="admin-user-list-rank-select">
                            <%rankEnum.slice().reverse().forEach((rank)=>{ %>
                                <option <%if(curUser.rank == rank){%> selected <%}%> value="<%- rank %>"><%- rank %></option>
                            <% }); %>
                        </select>
                    <% }else{ %> 
                        <%- curUser.rank %>
                    <% } %>
                </td>
                <td id="admin-user-list-entry-email-<%- curUser.user %>" class="admin-list-entry-item not-first-col">
                        <%- curUser.email ? curUser.email : "N/A" %>
                </td>
                <td id="admin-user-list-entry-date-<%- curUser.user %>" class="admin-list-entry-item not-first-col">
                        <%- curUser.date.toUTCString() %>
                </td>
                <td id="admin-user-list-entry-action-<%- curUser.user %>" class="admin-list-entry-item not-first-col">
                    <!-- It's either this or add whitespce >:( -->
                    <i class="bi-radioactive admin-user-list-icon admin-user-list-nuke-icon" id="admin-user-list-nuke-icon-<%- curUser.user %>" title="Nuke Account: <%- curUser.user %>"></i><i class="bi-fire admin-user-list-icon admin-user-list-ban-icon" id="admin-user-list-ban-icon-<%- curUser.user %>" title="Ban User: <%- curUser.user %>"></i><i class="bi-arrow-clockwise admin-user-list-icon admin-user-list-pw-reset-icon" id="admin-user-list-pw-reset-icon-<%- curUser.user %>" title="Generate Password Reset Link for <%- curUser.user %>"></i>
                </td>
            </tr>
        <% }); %>
        </table>
    </div>
</div>