This commit is contained in:
pro.boooooo
2023-03-09 14:41:05 +01:00
parent 563864e461
commit 2b1132fdf9
4 changed files with 40 additions and 59 deletions

View File

@@ -195,13 +195,12 @@ export default class Model {
}
/**
* Retourne la liste d'etablissement.
* @param { int } howMany Combien d'etablissement il y a
* @return { json } Les donnees demandees en JSON.
* Retourne la liste d'etablissement
* @return { json } les donnees demandees en JSON
* */
getModelData3(howMany) {
getModelData3() {
if(!localStorage.getItem(`sec-etab-${this.state.page.cat}-${this.state.page.scat}-${this.state.page.tcat}`)) {
const link = `${this.state.api.link}&rows=${howMany}` +
const link = `${this.state.api.link}&rows=10000` +
`&facet=${this.state.api.facet.filiaire}` +
`&facet=${this.state.api.facet.formation}` +
`&facet=${this.state.api.facet.spec}` +
@@ -209,6 +208,8 @@ export default class Model {
`&refine.${this.state.api.facet.formation}=${this.state.page.scat}` +
`&refine.${this.state.api.facet.spec}=${this.state.page.tcat}`
console.log(link)
return fetch(link)
.then((res) => {
return res.json()
@@ -217,6 +218,7 @@ export default class Model {
try {
if(data) {
localStorage.setItem(`sec-etab-${this.state.page.cat}-${this.state.page.scat}-${this.state.page.tcat}`, JSON.stringify(data.records))
this.state.page.tcat = null
return data.records
}
} catch(donothing) {}
@@ -224,6 +226,7 @@ export default class Model {
} else {
return new Promise((resolve, reject) => {
resolve(JSON.parse(localStorage.getItem(`sec-etab-${this.state.page.cat}-${this.state.page.scat}-${this.state.page.tcat}`)))
this.state.page.tcat = null
})
}
}