{% extends 'preferences/layout.html' %}
{% load i18n %}

{% block title %}{% trans "Edit Profile" %}{% endblock %}

{% block header %}
{% trans "Edit Profile" %}
{% endblock %}

{% block profile-tabs %}
<ul class="menu-list">
    <li><a href="#profile">{% trans "Profile" %}</a></li>
    <li><a href="#display-preferences">{% trans "Display" %}</a></li>
    <li><a href="#privacy">{% trans "Privacy" %}</a></li>
</ul>
{% endblock %}

{% block panel %}
{% if form.non_field_errors %}
<p class="notification is-danger">{{ form.non_field_errors }}</p>
{% endif %}
<form name="edit-profile" action="{% url 'prefs-profile' %}" method="post" enctype="multipart/form-data">
    {% csrf_token %}
    <section class="block" id="profile">
        <h2 class="title is-4">{% trans "Profile" %}</h2>
        <div class="box">
            <label class="label" for="id_avatar">{% trans "Avatar:" %}</label>
            <div class="field columns is-mobile">
                {% if request.user.avatar %}
                <div class="column is-narrow">
                    {% include 'snippets/avatar.html' with user=request.user large=True %}
                </div>
                {% endif %}
                <div class="column">
                    {{ form.avatar }}

                    {% include 'snippets/form_errors.html' with errors_list=form.avatar.errors id="desc_avatar" %}
                </div>
            </div>
            <div class="field">
                <label class="label" for="id_name">{% trans "Display name:" %}</label>
                {{ form.name }}

                {% include 'snippets/form_errors.html' with errors_list=form.name.errors id="desc_name" %}
            </div>
            <div class="field">
                <label class="label" for="id_summary">{% trans "Summary:" %}</label>
                {{ form.summary }}

                {% include 'snippets/form_errors.html' with errors_list=form.summary.errors id="desc_summary" %}
            </div>
            <div class="field">
                <label class="label" for="id_email">{% trans "Email address:" %}</label>
                {{ form.email }}

                {% include 'snippets/form_errors.html' with errors_list=form.email.errors id="desc_email" %}
            </div>
        </div>
    </section>

    <hr aria-hidden="true">

    <section class="block" id="display-preferences">
        <h2 class="title is-4">{% trans "Display" %}</h2>
        <div class="box">
            <div class="field">
                <label class="checkbox label" for="id_show_goal">
                    {{ form.show_goal }}
                    {% trans "Show reading goal prompt in feed" %}
                </label>
            </div>
            <div class="field">
                <label class="checkbox label" for="id_show_suggested_users">
                    {{ form.show_suggested_users }}
                    {% trans "Show suggested users" %}
                </label>
            </div>
            <div class="field">
                <label class="checkbox label" for="id_discoverable">
                    {{ form.discoverable }}
                    {% trans "Show this account in suggested users" %}
                </label>
                {% url 'directory' as path %}
                <p class="help" id="desc_discoverable">
                    {% blocktrans %}Your account will show up in the <a href="{{ path }}">directory</a>, and may be recommended to other BookWyrm users.{% endblocktrans %}
                </p>
            </div>
            <div class="field">
                <label class="label" for="id_preferred_timezone">{% trans "Preferred Timezone: " %}</label>
                <div class="select">
                    {{ form.preferred_timezone }}
                </div>
            </div>
            <div class="field">
                <label class="label" for="id_preferred_language">{% trans "Language:" %}</label>
                <div class="select">
                    {{ form.preferred_language }}
                </div>
            </div>
            <div class="field">
                <label class="label" for="id_them">{% trans "Theme:" %}</label>
                <div class="select">
                    {{ form.theme }}
                </div>
            </div>
        </div>
    </section>

    <hr aria-hidden="true">

    <section class="block" id="privacy">
        <h2 class="title is-4">{% trans "Privacy" %}</h2>
        <div class="box">
            <div class="field">
                <label class="checkbox label" for="id_manually_approves_followers">
                    {{ form.manually_approves_followers }}
                    {% trans "Manually approve followers" %}
                </label>
            </div>
            <div class="field">
                <label class="checkbox label" for="id_hide_follows">
                    {{ form.hide_follows }}
                    {% trans "Hide followers and following on profile" %}
                </label>
            </div>
            <div class="field">
                <label class="label" for="id_default_post_privacy">
                    {% trans "Default post privacy:" %}
                </label>
                <div class="select">
                    {{ form.default_post_privacy }}
                </div>
            </div>
            {% url 'user-shelves' request.user.localname as path %}
            <p class="notification is-light">
                {% blocktrans %}Looking for shelf privacy? You can set a separate visibility level for each of your shelves. Go to <a href="{{ path }}">Your Books</a>, pick a shelf from the tab bar, and click "Edit shelf."{% endblocktrans %}
            </p>
        </div>
    </section>
    <div class="field"><button class="button is-primary" type="submit">{% trans "Save" %}</button></div>
</form>
{% endblock %}
