{% extends "base/base.html" %}

{% block title %}
<h1>Gestion du compte</h1>
{% endblock %}

{% block content %}
<section class="form">
	<form action="{{ url_for('edit_account') }}" method="post" enctype="multipart/form-data">
		{{ form.hidden_tag() }}

		<h2>Général</h2>
		<div>
			{{ form.avatar.label }}
			<div>
				<img class="avatar" src="{{ url_for('avatar', filename=current_user.avatar) }}" meta="{{ current_user.avatar }}" />
				{{ form.avatar }}
			</div>
		</div>
		<div>
			{{ form.email.label }}
			{{ form.email(placeholder=current_user.email) }}
			{% for error in form.email.errors %}
			<span class="msgerror">{{ error }}</span>
			{% endfor %}
		</div>
		<div>
			{{ form.password.label }}
			{{ form.password(placeholder='************') }}
			{% for error in form.password.errors %}
			<span class="msgerror">{{ error }}</span>
			{% endfor %}
		</div>
		<div>
			{{ form.password2.label }}
			{{ form.password2(placeholder='************') }}
			{% for error in form.password2.errors %}
			<span class="msgerror">{{ error }}</span>
			{% endfor %}
		</div>
		<div>
			{{ form.old_password.label }}
			{{ form.old_password(placeholder='************') }}
			{% for error in form.old_password.errors %}
			<span class="msgerror">{{ error }}</span>
			{% endfor %}
		</div>

		<h2>À propos</h2>
		<div>
			{{ form.birthday.label }}
			{{ form.birthday(value=current_user.birthday) }}
			{% for error in form.birthday.errors %}
			<span class="msgerror">{{ error }}</span>
			{% endfor %}
		</div>
		<div>
			{{ form.signature.label }}
			<textarea id="{{ form.signature.name }}" name="{{ form.signature.name }}">{{ current_user.signature }}</textarea>
			{% for error in form.signature.errors %}
			<span class="msgerror">{{ error }}</span>
			{% endfor %}
		</div>
		<div>
			{{ form.biography.label }}
			<textarea id="{{ form.biography.name }}" name="{{ form.biography.name }}">{{ current_user.bio }}</textarea>
			{% for error in form.biography.errors %}
			<span class="msgerror">{{ error }}</span>
			{% endfor %}
		</div>

		<h2>Préférences</h2>
		<div>
			{{ form.newsletter.label }}
			{{ form.newsletter(checked=current_user.newsletter) }}
			<div class=desc>{{ form.newsletter.description }}</div>
			{% for error in form.newsletter.errors %}
			<span class="msgerror">{{ error }}</span>
			{% endfor %}
		</div>
		<div>{{ form.submit(class_="bg-green") }}</div>
	</form>

	<h2 style="margin-top:30px;">Supprimer le compte</h2>
	<a href="{{ url_for('delete_account') }}" class="button bg-red">Supprimer le compte</a>

</section>
{% endblock %}
