<link rel="stylesheet" href="{{ url_for('static', filename='css/forms.css') }}" />

<div id="form-wrapper">
    <h2>Update User</h2>
    {% if updating_user != None %}
        <form class="input-form" action="{{ url_for('main.users.update', id=updating_user.id) }}" method="POST">
            <div class="form-row">
                <input type="text" id="firstname" name="firstname" placeholder="First Name" value="{{updating_user.firstName}}" required>
                <input type="text" id="lastname" name="lastname" placeholder="Last Name" value="{{updating_user.lastName}}" required>
            </div>

            <div class="form-row">
                <input type="text" id="username" name="username" placeholder="Username" value="{{updating_user.username}}" required>
                <input type="email" id="email" name="email" placeholder="Email Address" value="{{updating_user.email}}" required>
            </div>

            <div class="form-row">
                <input type="tel" id="phone" name="phone" placeholder="Telephone Number" value="{{updating_user.phone}}" required>
            </div>

            <div class="form-row">
                <select name="role" id="role">
                    {% for role in roles %}
                        {% if role == updating_user.role %}
                            <option value="{{role}}" selected>{{role}}</option>
                        {% else %}
                            <option value="{{role}}">{{role}}</option>
                        {% endif%}
                    {% endfor %}
                </select>
            </div>

            <div class="form-row">
                <input type="submit" id="Update" value="Update User">
            </div>
        </form>
    {% else %}
    <p>No user found with the given ID.</p>
    {% endif %}
    
    <div id="form-footer">
        <p>Already have an account? <a href="{{ url_for('main.users.display_login') }}">Login</a><p>
    </div>
</div>
