{% extends 'auth_layout.html' %}
{% block content %}
{% if context.message %}
    <div class="row">
        <div class="col text-center text-primary">
            <i class="ri-error-warning-fill"></i> {{ context.message }}
        </div>
    </div>
{% endif %}
<div class="row">
    <div class="col">
        <a href="{{ url_for('admin_ils_users') }}" class="btn btn-secondary">Back</a>
    </div>
    <div class="col text-center">
        <h3><i class="ri-shield-user-fill"></i> Edit ILS User</h3>
    </div>
    <div class="col text-end">
        {% if context.suspend_setting == "false" %}
            <a href="#!" class="disabled btn btn-danger"><i class="ri-delete-bin-line"></i> Delete ILS User</a>
        {% else %}
            <a href="#!" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#remove-user"><i class="ri-delete-bin-line"></i> Delete ILS User</a>
        {% endif %}
    </div>
</div>
<div class="row justify-content-center">
    <div class="col-sm-12 col-md-6 col-lg-4">
        <form action="" method="post">
            <div class="mb-3">
                <label class="form-label" for="username">ILS Username</label>
                <input type="text" class="form-control" value="{{ context.user.username }}" id="username" name="username" required>
            </div>
            <div class="mb-3">
                <label class="form-label" for="email">Email Address</label>
                <input type="text" class="form-control" value="{{ context.user.email }}" id="email" name="email" required>
            </div>
            <div class="mb-3">
                <label class="form-label" for="date">Last Password Reset Date</label>
                <input type="date" class="form-control" id="date" name="date" value="{{ context.user.reset_datetime }}">
            </div>
            <div class="mb-3 text-center">
                {% if context.suspend_setting == "false" %}
                    <input type="submit" class="disabled btn btn-primary w-100" value="Save">
                {% else %}
                    <input type="submit" class="btn btn-primary w-100" value="Save">
                {% endif %}
            </div>
        </form>
    </div>
</div>

<div class="modal fade" id="remove-user" tabindex="-1">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header bg-light">
                <h1 class="modal-title fs-5">Confirmation</h1>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <div class="mb-3">
                    <p class="lead">Are you sure you want to delete this user?</p>
                </div>
            </div>
            <div class="modal-footer bg-light">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
                <a class="btn btn-danger" href="{{ url_for('admin_ils_users_delete', id=context.user.id) }}">Yes, remove the user</a>
            </div>
        </div>
    </div>
</div>
{% endblock %}