j'arrive pas a commit
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
const API_BASE = "https://data.education.gouv.fr/api/explore/v2.1/catalog/datasets/fr-esr-parcoursup/records";
|
||||
|
||||
export async function recupereFormations(motCle, limit = 20) {
|
||||
const url = `${API_BASE}?where=search("${motCle}")&limit=${limit}`;
|
||||
|
||||
const response = await fetch(url);
|
||||
const data = await response.json();
|
||||
|
||||
return data.results;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<ligne-resultat>
|
||||
<div class="ligne-resultat">
|
||||
<h3>{ props.formation.fil_lib_voe_acc } — { props.formation.g_ea_lib_vx }</h3>
|
||||
<p>{ props.formation.ville_etab } ({ props.formation.dep_lib })</p>
|
||||
<p>Taux d'accès : { props.formation.taux_acces_ens }%</p>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.ligne-resultat {
|
||||
border: 1px solid #ccc;
|
||||
padding: 10px;
|
||||
margin: 5px 0;
|
||||
}
|
||||
</style>
|
||||
</ligne-resultat>
|
||||
@@ -0,0 +1,27 @@
|
||||
import * as riot from 'riot'
|
||||
import LigneResultat from './components/ligne-resultat.riot'
|
||||
import { recupereFormations } from './api/parcoursup.js'
|
||||
|
||||
|
||||
riot.register('ligne-resultat', LigneResultat)
|
||||
|
||||
const bouton = document.getElementById("entrerRequete")
|
||||
const champRecherche = document.getElementById("requete")
|
||||
const divResultats = document.getElementById("affichageResultats")
|
||||
|
||||
bouton.addEventListener("click", async () => {
|
||||
const motCle = champRecherche.value
|
||||
divResultats.innerHTML = "Chargement..."
|
||||
|
||||
const formations = await recupereFormations(motCle)
|
||||
|
||||
divResultats.innerHTML = ""
|
||||
|
||||
formations.forEach(f => {
|
||||
const listeFormations = riot.mount(
|
||||
document.createElement('ligne-resultat'),
|
||||
{ formation: f }
|
||||
)
|
||||
divResultats.appendChild(listeFormations[0].root)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user