Files
public-html2/parcoursup/app.riot
T

105 lines
2.8 KiB
Plaintext
Raw Normal View History

<app>
2026-03-31 17:54:23 +02:00
<h1>Mini projet Parcoursup</h1>
<p>Recherche de formations Parcoursup avec Riot</p>
<div if={ !state.selected }>
<input
type="text"
placeholder="Ex : BUT informatique"
oninput={ updateQuery }
value={ state.query }
/>
<button onclick={ search }>Rechercher</button>
<p if={ state.loading }>Chargement...</p>
<p if={ !state.loading && state.results.length === 0 && state.hasSearched }>
Aucun résultat trouvé
</p>
<div each={ f, i in state.results } key={ f.id }
style="border:1px solid #ccc; padding:10px; margin:10px;">
<h3>{ f.nom }</h3>
<p><b>Établissement :</b> { f.etablissement }</p>
<p><b>Ville :</b> { f.ville } ({ f.departement })</p>
<p><b>Filière :</b> { f.filiere }</p>
<p><b>Taux d'accès :</b> { f.tauxAcces }%</p>
<button onclick={ () => showDetail(i) }>Voir détail</button>
2026-03-19 14:37:08 +01:00
</div>
2026-03-31 17:54:23 +02:00
</div>
2026-03-31 17:54:23 +02:00
<div if={ state.selected }>
<h2>{ state.selected.nom }</h2>
<p><b>Établissement :</b> { state.selected.etablissement }</p>
<p><b>Ville :</b> { state.selected.ville }</p>
<p><b>Département :</b> { state.selected.departement }</p>
<p><b>Filière :</b> { state.selected.filiere }</p>
<p><b>Sélectivité :</b> { state.selected.selectivite }</p>
<p><b>Capacité :</b> { state.selected.capacite }</p>
<p><b>Candidats :</b> { state.selected.candidats }</p>
<p><b>Admis :</b> { state.selected.admis }</p>
<p><b>Taux d'accès :</b> { state.selected.tauxAcces }%</p>
2026-03-31 17:54:23 +02:00
<button onclick={ backToList }>Retour</button>
</div>
<script>
2026-03-31 17:54:23 +02:00
import { fetchFormations } from './api.js'
import { createFormation } from './formation.js'
export default {
state: {
2026-03-31 17:54:23 +02:00
query: '',
loading: false,
hasSearched: false,
results: [],
2026-03-31 17:54:23 +02:00
selected: null
},
2026-03-31 17:54:23 +02:00
updateQuery(e) {
this.update({ query: e.target.value })
},
2026-03-31 17:54:23 +02:00
async search() {
this.update({
loading: true,
hasSearched: true,
2026-03-31 17:54:23 +02:00
selected: null
})
try {
2026-03-31 17:54:23 +02:00
const data = await fetchFormations(this.state.query)
const formations = []
2026-03-31 17:54:23 +02:00
if (data.results) {
for (let i = 0; i < data.results.length; i++) {
formations.push(createFormation(data.results[i]))
}
}
this.update({
results: formations,
loading: false
2026-03-31 17:54:23 +02:00
})
} catch (error) {
console.error(error)
this.update({
results: [],
loading: false
2026-03-31 17:54:23 +02:00
})
}
},
2026-03-31 17:54:23 +02:00
showDetail(index) {
this.update({
selected: this.state.results[index]
})
},
2026-03-31 17:54:23 +02:00
backToList() {
this.update({
selected: null
})
}
2026-03-31 17:54:23 +02:00
}
</script>
2026-03-31 17:54:23 +02:00
</app>