search 3/3
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<search>
|
||||
<label>
|
||||
<input onkeydown={searchF} type="input" placeholder= {state.placeholder}>
|
||||
<button onclick={back}><</button>
|
||||
<div id="list-formations">
|
||||
<ul>
|
||||
<li each={item in this.state.items}>
|
||||
@@ -12,11 +13,27 @@
|
||||
</label>
|
||||
<script>
|
||||
|
||||
async function apiLink(whatToSearch, whereToSearch){
|
||||
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 table = resultats["facet_groups"][whereToSearch]["facets"]
|
||||
return table
|
||||
const searchURL = `https://data.enseignementsup-recherche.gouv.fr/api/records/1.0/search/?dataset=fr-esr-parcoursup&timezone=Europe%2FBerlin`
|
||||
|
||||
async function fetchFiliere0() {
|
||||
let request = await fetch(`${searchURL}&rows=0&sort=tri&facet=fili`)
|
||||
let result = await request.json()
|
||||
|
||||
return result["facet_groups"][0]["facets"]
|
||||
}
|
||||
|
||||
async function fetchFiliere1(filiere) {
|
||||
let request = await fetch(`${searchURL}&rows=0&sort=tri&facet=form_lib_voe_acc&refine.fili=${filiere}`)
|
||||
let result = await request.json()
|
||||
|
||||
return result["facet_groups"][0]["facets"]
|
||||
}
|
||||
|
||||
async function fetchFiliere2(sousfiliere) {
|
||||
let request = await fetch(`${searchURL}&rows=0&sort=tri&facet=fil_lib_voe_acc&refine.form_lib_voe_acc=${sousfiliere}`)
|
||||
let result = await request.json()
|
||||
|
||||
return result["facet_groups"][0]["facets"]
|
||||
}
|
||||
|
||||
export default function search(){
|
||||
@@ -27,11 +44,10 @@
|
||||
placeholder: "Formation",
|
||||
items: null,
|
||||
allitems: null,
|
||||
whatToSearch: "fili",
|
||||
fili: null,
|
||||
sousfili: null
|
||||
}
|
||||
apiLink(this.state.whatToSearch,0).then((response) => {
|
||||
fetchFiliere0().then((response) => {
|
||||
this.update({
|
||||
items: response,
|
||||
allitems: response
|
||||
@@ -51,27 +67,59 @@
|
||||
},
|
||||
filter(fili){
|
||||
console.log("filter! "+fili)
|
||||
let step=0;
|
||||
if (this.state.placeholder==="Filière de formation"){
|
||||
this.update({
|
||||
placeholder: "Filière de formation détaillée",
|
||||
sousfili: fili,
|
||||
whatToSearch: "fili&facet=form_lib_voe_acc&facet=fil_lib_voe_acc&refine.form_lib_voe_acc="+this.state.sousfili+"&refine.fili="this.state.fili
|
||||
})
|
||||
} else {
|
||||
this.update({
|
||||
placeholder: "Filière de formation",
|
||||
fili: fili,
|
||||
whatToSearch: "fili&facet=form_lib_voe_acc&refine.fili="+this.state.fili
|
||||
})
|
||||
}
|
||||
apiLink(this.state.whatToSearch).then((response) => {
|
||||
this.update({
|
||||
allitems: response,
|
||||
item: response
|
||||
fetchFiliere2(this.state.sousfili).then((response) => {
|
||||
this.update({
|
||||
allitems: response,
|
||||
items: response
|
||||
})
|
||||
})
|
||||
console.log(this.state.items)
|
||||
})
|
||||
} else if (this.state.placeholder="Formation"){
|
||||
this.update({
|
||||
placeholder: "Filière de formation",
|
||||
fili: fili
|
||||
})
|
||||
fetchFiliere1(this.state.fili).then((response) => {
|
||||
this.update({
|
||||
allitems: response,
|
||||
items: response
|
||||
})
|
||||
console.log(this.state.items)
|
||||
})
|
||||
}
|
||||
},
|
||||
back(){
|
||||
console.log("back")
|
||||
if (this.state.placeholder==="Filière de formation"){
|
||||
this.update({
|
||||
placeholder: "Formation",
|
||||
fili: null,
|
||||
})
|
||||
fetchFiliere0().then((response) => {
|
||||
this.update({
|
||||
allitems: response,
|
||||
items: response
|
||||
})
|
||||
})
|
||||
console.log(this.state.items)
|
||||
} else if (this.state.placeholder="Filière de formation détaillée"){
|
||||
this.update({
|
||||
placeholder: "Filière de formation",
|
||||
sousfili: null
|
||||
})
|
||||
fetchFiliere1(this.state.fili).then((response) => {
|
||||
this.update({
|
||||
allitems: response,
|
||||
items: response
|
||||
})
|
||||
console.log(this.state.items)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user