search etape 2/3
This commit is contained in:
parent
0e5f2bb792
commit
14e253bbc7
@ -4,7 +4,7 @@
|
|||||||
<div id="list-formations">
|
<div id="list-formations">
|
||||||
<ul>
|
<ul>
|
||||||
<li each={item in this.state.items}>
|
<li each={item in this.state.items}>
|
||||||
<a href={item.path} target="_blank">{item.name}</a>
|
<span onclick={()=>filter(item.name)}>{item.name}</span>
|
||||||
<span>{item.count}</span>
|
<span>{item.count}</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -12,8 +12,8 @@
|
|||||||
</label>
|
</label>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
async function formation(){
|
async function formation(whatToSearch){
|
||||||
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 result = await fetch("https://data.enseignementsup-recherche.gouv.fr/api/records/1.0/search/?dataset=fr-esr-parcoursup&q=&sort=tri&facet="+whatToSearch+"&timezone=Europe%2FBerlin")
|
||||||
let resultats = await result.json()
|
let resultats = await result.json()
|
||||||
let table = resultats["facet_groups"][0]["facets"]
|
let table = resultats["facet_groups"][0]["facets"]
|
||||||
return table
|
return table
|
||||||
@ -26,9 +26,10 @@
|
|||||||
this.state = {
|
this.state = {
|
||||||
formation: props.formation,
|
formation: props.formation,
|
||||||
items: null,
|
items: null,
|
||||||
allitems: null
|
allitems: null,
|
||||||
|
whatToSearch: "fili"
|
||||||
}
|
}
|
||||||
formation().then((response) => {
|
formation(this.state.whatToSearch).then((response) => {
|
||||||
this.update({
|
this.update({
|
||||||
items: response,
|
items: response,
|
||||||
allitems: response
|
allitems: response
|
||||||
@ -38,14 +39,44 @@
|
|||||||
searchF(e){
|
searchF(e){
|
||||||
let responseFiltered=[]
|
let responseFiltered=[]
|
||||||
this.state.allitems.forEach(formation => {
|
this.state.allitems.forEach(formation => {
|
||||||
if (formation.name.includes(e.target.value)) {
|
if (formation.name.toUpperCase().includes(e.target.value.toUpperCase())) {
|
||||||
responseFiltered.push(formation)
|
responseFiltered.push(formation)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.update({
|
this.update({
|
||||||
items: responseFiltered
|
items: responseFiltered
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
filter(fili){
|
||||||
|
console.log("filter! "+fili)
|
||||||
|
if (this.state.whatToSearch==="form_lib_voe_acc"){
|
||||||
|
this.update({
|
||||||
|
formation: "Filière de formation détaillée",
|
||||||
|
whatToSearch: "lib_for_voe_ins"
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.update({
|
||||||
|
formation: "Filière de formation",
|
||||||
|
whatToSearch: "form_lib_voe_acc"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
formation(this.state.whatToSearch).then((response) => {
|
||||||
|
this.update({
|
||||||
|
allitems: response,
|
||||||
|
item: response
|
||||||
|
})
|
||||||
console.log(this.state.items)
|
console.log(this.state.items)
|
||||||
|
})
|
||||||
|
let responseFiltered=[]
|
||||||
|
this.state.allitems.forEach(formation => {
|
||||||
|
if (formation.name.includes(fili)) {
|
||||||
|
responseFiltered.push(formation)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.update({
|
||||||
|
allitems: responseFiltered,
|
||||||
|
items: responseFiltered
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user