-
Notifications
You must be signed in to change notification settings - Fork 1
/
controle.html
80 lines (73 loc) · 3.58 KB
/
controle.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Controles</title>
<link rel="icon" type="image/png" href="./assets/images/petflix-logo.png">
<link rel="stylesheet" href="assets/css/reset.css">
<link rel="stylesheet" href="assets/css/app.css">
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@^2.2.19/dist/tailwind.min.css" rel="stylesheet">
</head>
<body class="bg-gray-900 text-white">
<header class="bg-gray-800 p-4">
<div class="container mx-auto">
<a href="index.html" class="underline">Revenir à l'accueil</a>
</div>
</header>
<main class="container mx-auto mt-8">
<h1 class="text-xl font-bold mb-6">Contrôle à venir</h1>
<div id="controleInfo">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-800">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-bold text-gray-300 uppercase tracking-wider">Date du contrôle</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-bold text-gray-300 uppercase tracking-wider">Date d'adoption</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-bold text-gray-300 uppercase tracking-wider">Nom et Prénom de l'adoptant</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-bold text-gray-300 uppercase tracking-wider">Nom de l'animal</th>
</tr>
</thead>
<tbody class="bg-white text-black divide-y divide-gray-200" id="controlesTable">
</tbody>
</table>
</div>
</main>
<footer class="bg-gray-800 p-4 mt-8">
<div class="container mx-auto text-center text-gray-400">
<p>2024 - Petflix</p>
</div>
</footer>
<script>
fetch("http://localhost:8000/get-controles-a-venir")
.then(response => {
if (!response.ok) {
throw new Error('Problème lors de la récupération des données');
console.log('test')
}
return response.json();
console.log('qsdfqsqs')
})
.then(data => {
const controlesTable = document.getElementById('controlesTable');
data.controles_a_venir.forEach(controle => {
const row = controlesTable.insertRow();
const dateControleCell = row.insertCell(0);
dateControleCell.classList.add('px-6', 'py-3');
const dateAdoptionCell = row.insertCell(1);
dateAdoptionCell.classList.add('px-6', 'py-3');
const nomAdoptantCell = row.insertCell(2);
nomAdoptantCell.classList.add('px-6', 'py-3');
const nomAnimalCell = row.insertCell(3);
nomAnimalCell.classList.add('px-6', 'py-3');
dateControleCell.textContent = new Date(controle.date_controle).toLocaleDateString("fr-FR");
dateAdoptionCell.textContent = new Date(controle.date_adoption).toLocaleDateString("fr-FR");
nomAdoptantCell.textContent = `${controle.nom_adoptant} ${controle.prenom_adoptant}`;
nomAnimalCell.textContent = controle.nom_animal;
});
})
.catch(error => {
console.error('Erreur:', error);
});
</script>
</body>
</html>