-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathListeInscriptions.js
41 lines (35 loc) · 1.09 KB
/
ListeInscriptions.js
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
import React, { useState, useEffect } from 'react';
const ListeInscriptions = () => {
const [inscriptions, setInscriptions] = useState([]);
const [searchTerm, setSearchTerm] = useState('');
useEffect(() => {
fetch('votre_url_de_l_api')
.then(response => response.json())
.then(data => setInscriptions(data))
.catch(error => console.error('Erreur lors de la récupération des inscriptions:', error));
}, []);
const handleSearch = (e) => {
setSearchTerm(e.target.value);
};
const filteredInscriptions = inscriptions.filter((inscription) =>
inscription.ville.toLowerCase().includes(searchTerm.toLowerCase())
);
return (
<div>
<input
type="text"
placeholder="Rechercher par ville"
value={searchTerm}
onChange={handleSearch}
/>
<ul>
{filteredInscriptions.map((inscription, index) => (
<li key={index}>
{inscription.ville} - {inscription.option}
</li>
))}
</ul>
</div>
);
};
export default ListeInscriptions;