<!DOCTYPE html>
<html>
    <head>
        <title>Edit</title>
        <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
    </head>
    <body>
        <div class="container mt-4">
            <h2>Edit User - <%= user.username %></h2>
            <form action="/update/<%= user.id %>" method="post">
                <div class="form-group">
                    <label for="username">Username:</label>
                    <input type="text" class="form-control" id="username" name="username" value="<%= user.username %>" required>
                </div>
                <% if (loggedinuser.level === "admin"){ %>
                <div class="form-group">
                    <label for="mainRid">Main RID:</label>
                    <input type="text" class="form-control" id="mainRid" name="mainRid" value="<%= user.mainRid %>">
                </div>
                <div class="form-group">
                    <label for="level">Level:</label>
                    <select class="form-control" id="level" name="level">
                        <option value="admin" <%= user.level === 'admin' ? 'selected' : '' %>>Admin</option>
                        <option value="operator" <%= user.level === 'operator' ? 'selected' : '' %>>Operator</option>
                    </select>
                </div>
                <% } %>
                <button type="submit" class="btn btn-success">Update</button>
            </form>
        </div>

        <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
    </body>
</html>
