{% extends 'base.html.twig' %}
{% block title %}
	{{parent()}}Liste des contacts
{% endblock %}
{% block body %}
	<div class="container-fluid">
		<h1 class="text-center text-primary mt-4 pt-4 display-1 fw-bold">
			Liste des contacts</h1>
		<div class="row justify-content-center">
			<div class="col-12 col-md-8 bg-white p-4 m-0 text-primary">
				<div class="table-responsive">
					<table class="table table-hover">
						<thead>
							<tr class="fw-bold text-primary">
								<th scope="col">Nom</th>
								<th scope="col">Sujet</th>
								<th scope="col">Email</th>
								<th scope="col">Date d'envoi</th>
							</tr>
						</thead>
						<tbody>
							{% for contact in contacts |sort((a, b) =>
b.dateEnvoi <=> a.dateEnvoi) %}
								<tr class="{{ cycle(['table-primary', 'table-secondary'], loop.index0) }}">
									<td>{{ contact.nom |
capitalize }}</td>
									<td>{{ contact.sujet |
capitalize }}</td>
									<td>{{ contact.email | lower }}</td>
									<td>{{ contact.dateEnvoi |
date("d-m-Y à H:i:s") }}</td>
								</tr>
							{% endfor %}
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>
{% endblock %}
