{% extends 'service_partner_app/base_service_partner.html' %}

{% block title %}Change Username{% endblock %}

{% block content %}
<section class="py-5">
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-lg-6">
                <div class="card shadow-sm border-0 rounded-4">
                    <div class="card-body p-4 p-lg-5">
                        <h2 class="mb-4">Change Username</h2>

                        <form method="post">
                            {% csrf_token %}

                            {% for field in form %}
                                <div class="mb-3">
                                    <label class="form-label" for="{{ field.id_for_label }}">{{ field.label }}</label>
                                    {{ field }}
                                    {% for error in field.errors %}
                                        <div class="text-danger small mt-1">{{ error }}</div>
                                    {% endfor %}
                                </div>
                            {% endfor %}

                            <div class="d-flex gap-2 flex-wrap">
                                <button type="submit" class="btn btn-primary">Update Username</button>
                                <a href="{% url 'service_partner_app:service_partner_profile_page' %}" class="btn btn-outline-secondary">Cancel</a>
                            </div>

                            {% if form.non_field_errors %}
                                <div class="alert alert-danger mt-3 mb-0">
                                    {% for error in form.non_field_errors %}
                                        <div>{{ error }}</div>
                                    {% endfor %}
                                </div>
                            {% endif %}
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
{% endblock %}