{% extends 'babybuddy/page.html' %}
{% load i18n widget_tweaks babybuddy %}

{% block title %}{% trans "User Settings" %}{% endblock %}

{% block breadcrumbs %}
    <li class="breadcrumb-item">{% trans "User" %}</li>
    <li class="breadcrumb-item active">{% trans "Settings" %}</li>
{% endblock %}

{% block content %}
    <h1>{% trans "User Settings" %}</h1>
    <div class="container-fluid">
        <form role="form" method="post">
            {% csrf_token %}
            {% if form.non_field_errors %}
                {% for error in form.non_field_errors %}
                    <div class="alert alert-danger" role="alert">
                        {% blocktrans trimmed %}
                            <strong>Error:</strong> {{ error }}
                        {% endblocktrans %}
                    </div>
                {% endfor %}
            {% elif form.errors %}
                <div class="alert alert-danger" role="alert">
                    {% blocktrans trimmed %}
                        <strong>Error:</strong> Some fields have errors. See
                        below for details.
                    {% endblocktrans %}
                </div>
            {% endif %}
            <fieldset>
                <legend>{% trans "User Profile" %}</legend>
                <div class="form-group row">
                    {% with form_user.first_name as field %}
                        {% include 'babybuddy/form_field.html' %}
                    {% endwith %}
                </div>
                <div class="form-group row">
                    {% with form_user.last_name as field %}
                        {% include 'babybuddy/form_field.html' %}
                    {% endwith %}
                </div>
                <div class="form-group row">
                    {% with form_user.email as field %}
                        {% include 'babybuddy/form_field.html' %}
                    {% endwith %}
                </div>
                <div class="form-group row">
                    {% with form_settings.language as field %}
                        {% include 'babybuddy/form_field.html' %}
                    {% endwith %}
                </div>
                <div class="form-group row">
                    {% with form_settings.timezone as field %}
                        {% include 'babybuddy/form_field.html' %}
                    {% endwith %}
                </div>
            </fieldset>
            <fieldset>
                <legend>{% trans "Dashboard" %}</legend>
                <div class="form-group row">
                    {% with form_settings.dashboard_refresh_rate as field %}
                        {% include 'babybuddy/form_field.html' %}
                    {% endwith %}
                </div>
                <div class="form-group row">
                    {% with form_settings.dashboard_hide_empty as field %}
                        {% include 'babybuddy/form_field.html' %}
                    {% endwith %}
                </div>
                <div class="form-group row">
                    {% with form_settings.dashboard_hide_age as field %}
                        {% include 'babybuddy/form_field.html' %}
                    {% endwith %}
                </div>
            </fieldset>
            <fieldset>
                <legend>{% trans "API" %}</legend>
                <div class="form-group row">
                    <label class="col-sm-2 col-form-label">{% trans "Key" %}</label>
                    <div class="col-sm-10">
                        <samp>{{ user.settings.api_key }}</samp>
                        <input type="submit" name="api_key_regenerate" value="{% trans "Regenerate" %}" class="btn btn-danger btn-xs" />
                    </div>
                </div>
            </fieldset>
            <input type="hidden" name="next" value="{% url 'babybuddy:user-settings' %}" />
            <input type="submit" name="save_settings" value="{% trans "Submit" %}" class="btn btn-primary">
        </form>
    </div>
{% endblock %}
