search pour formation etape 1/3

This commit is contained in:
Haïssous Kayyissa 2023-03-26 22:12:11 +02:00
parent afba3c0abc
commit 0e5f2bb792
3 changed files with 16 additions and 64 deletions

View File

@ -1,6 +1,6 @@
<search> <search>
<label> <label>
<input oninput={searchF} type="input" placeholder= {state.formation}> <input onkeydown={searchF} type="input" placeholder= {state.formation}>
<div id="list-formations"> <div id="list-formations">
<ul> <ul>
<li each={item in this.state.items}> <li each={item in this.state.items}>
@ -25,20 +25,25 @@
// initial state // initial state
this.state = { this.state = {
formation: props.formation, formation: props.formation,
items: null items: null,
allitems: null
} }
formation().then((response) => { formation().then((response) => {
this.update({ this.update({
items: response items: response,
allitems: response
}) })
}) })
console.log(this.state.items)
}, },
searchF(){ searchF(e){
formation().then((response) => { let responseFiltered=[]
this.state.allitems.forEach(formation => {
if (formation.name.includes(e.target.value)) {
responseFiltered.push(formation)
}
});
this.update({ this.update({
items: response items: responseFiltered
})
}) })
console.log(this.state.items) console.log(this.state.items)
} }

View File

@ -1,52 +0,0 @@
<formation>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.9.3/css/bulma.min.css">
<table class="table is-fullwidth is-hoverable">
<tbody1>
<tr >
<th></th>
<th></th>
</tr>
</tbody1>
</table>
<script>
async function formation (){
let result = await fetch("https://data.enseignementsup-recherche.gouv.fr/api/records/1.0/search/?dataset=fr-esr-parcoursup&q=&sort=tri&facet=fili&timezone=Europe%2FBerlin")
let resultats = await result.json()
console.log(result)
console.log(resultats)
let base=[]
let filieretable=[]
let filieredetail=[]
let table = resultats["facet_groups"][0]["facets"]
console.log(table)
const tableBody = document.querySelector("tbody1")
for(tes of table){
const tableRow = document.createElement("tr")
const formationCell = document.createElement("td")
let texteformation = document.createTextNode(tes.name)
formationCell.appendChild(texteformation)
tableRow.appendChild(formationCell)
const nombredeplaceCell = document.createElement("td")
const nombredeplace = document.createTextNode(tes.count)
nombredeplaceCell.appendChild(nombredeplace)
tableRow.appendChild(nombredeplaceCell)
tableBody.appendChild(tableRow)
}
}
export default{
onMounted(){
formation()
}
}
</script>
</formation>

View File

@ -18,8 +18,7 @@
riot.compile().then(() => { riot.compile().then(() => {
riot.mount('search', { riot.mount('search', {
formation:'Formation', formation:'Formation',
items: null, items: null
text: null
}) })
}) })
</script> </script>