2026-03-18 12:45:44 +01:00
|
|
|
<app>
|
2026-03-19 14:37:08 +01:00
|
|
|
<header class="site-header">
|
|
|
|
|
<div class="header-inner">
|
2026-03-20 01:51:08 +01:00
|
|
|
<a class="logo" href="#/">
|
2026-03-20 02:35:15 +01:00
|
|
|
<span class="logo-icon"></span>
|
2026-03-19 14:37:08 +01:00
|
|
|
<span class="logo-text">Parcoursup <span class="logo-light">Explorer</span></span>
|
2026-03-20 01:51:08 +01:00
|
|
|
</a>
|
2026-03-20 02:35:15 +01:00
|
|
|
<div class="header-right">
|
|
|
|
|
<a href="#/comparateur" class="header-badge badge-clickable" if={ state.selectedFormations.length > 0 }>
|
|
|
|
|
{ state.selectedFormations.length } sélection(s)
|
|
|
|
|
</a>
|
2026-03-21 13:47:09 +01:00
|
|
|
<auth-panel user={ state.user } onauth={ surConnexion } onlogout={ surDeconnexion }></auth-panel>
|
2026-03-20 02:35:15 +01:00
|
|
|
</div>
|
2026-03-19 14:37:08 +01:00
|
|
|
</div>
|
|
|
|
|
</header>
|
2026-03-18 12:45:44 +01:00
|
|
|
|
2026-03-19 14:37:08 +01:00
|
|
|
<div class="page">
|
2026-03-18 13:54:33 +01:00
|
|
|
|
2026-03-20 01:51:08 +01:00
|
|
|
<!-- ============== VUE RECHERCHE ============== -->
|
|
|
|
|
<div if={ state.view === 'search' }>
|
2026-03-21 13:47:09 +01:00
|
|
|
<search-bar onsearch={ lancerRecherche }></search-bar>
|
2026-03-18 12:45:44 +01:00
|
|
|
|
2026-03-20 01:51:08 +01:00
|
|
|
<p class="result-count" if={ state.hasSearched && !state.loading }>
|
|
|
|
|
<b>{ state.query }</b> — { state.total } résultat(s)
|
|
|
|
|
</p>
|
2026-03-18 14:03:43 +01:00
|
|
|
|
2026-03-20 01:51:08 +01:00
|
|
|
<map-view results={ state.results }></map-view>
|
|
|
|
|
|
|
|
|
|
<div class="layout">
|
|
|
|
|
<div>
|
|
|
|
|
<result-list
|
|
|
|
|
results={ state.results }
|
|
|
|
|
hasSearched={ state.hasSearched }
|
|
|
|
|
loading={ state.loading }
|
2026-03-21 13:47:09 +01:00
|
|
|
ondetail={ afficherDetail }
|
|
|
|
|
onselect={ ajouterSelection }>
|
2026-03-20 01:51:08 +01:00
|
|
|
</result-list>
|
|
|
|
|
|
|
|
|
|
<div class="pagination" if={ state.total > state.limit }>
|
2026-03-21 13:47:09 +01:00
|
|
|
<button class="btn btn-outline" onclick={ pagePrecedente } disabled={ state.page === 1 }>
|
2026-03-20 01:51:08 +01:00
|
|
|
← Précédent
|
|
|
|
|
</button>
|
2026-03-21 13:47:09 +01:00
|
|
|
<span class="page-info">Page { state.page } / { nombreTotalPages() }</span>
|
|
|
|
|
<button class="btn btn-outline" onclick={ pageSuivante } disabled={ state.page === nombreTotalPages() }>
|
2026-03-20 01:51:08 +01:00
|
|
|
Suivant →
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- ============== VUE DÉTAIL ============== -->
|
|
|
|
|
<div if={ state.view === 'detail' && state.selected }>
|
|
|
|
|
<detail-view
|
|
|
|
|
formation={ state.selected }
|
2026-03-21 13:47:09 +01:00
|
|
|
onback={ retourRecherche }>
|
2026-03-20 01:51:08 +01:00
|
|
|
</detail-view>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div if={ state.view === 'detail' && !state.selected } class="message">
|
|
|
|
|
Chargement de la formation...
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- ============== VUE COMPARATEUR ============== -->
|
|
|
|
|
<div if={ state.view === 'comparateur' }>
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
<button class="btn btn-outline" onclick={ retourRecherche } style="margin-bottom: 16px;">← Retour à la recherche</button>
|
2026-03-20 01:51:08 +01:00
|
|
|
|
|
|
|
|
<div class="detail-card comparateur-card" if={ state.selectedFormations.length > 0 }>
|
|
|
|
|
<h2>Comparateur de formations</h2>
|
|
|
|
|
|
|
|
|
|
<p>Choisis ton profil pour estimer tes chances d'intégration.</p>
|
2026-03-18 14:03:43 +01:00
|
|
|
|
|
|
|
|
<div class="compare-controls">
|
|
|
|
|
<div>
|
2026-03-18 14:17:03 +01:00
|
|
|
<label><b>Note moyenne :</b></label><br />
|
2026-03-18 14:03:43 +01:00
|
|
|
<input
|
|
|
|
|
type="number"
|
|
|
|
|
min="0"
|
|
|
|
|
max="20"
|
|
|
|
|
step="0.1"
|
|
|
|
|
value={ state.note }
|
2026-03-21 13:47:09 +01:00
|
|
|
oninput={ mettreAJourNote }
|
2026-03-18 14:03:43 +01:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div>
|
2026-03-18 14:17:03 +01:00
|
|
|
<label><b>Série :</b></label><br />
|
2026-03-21 13:47:09 +01:00
|
|
|
<select onchange={ mettreAJourSerie }>
|
2026-03-18 14:03:43 +01:00
|
|
|
<option value="general" selected={ state.serie === 'general' }>Général</option>
|
|
|
|
|
<option value="techno" selected={ state.serie === 'techno' }>Technologique</option>
|
|
|
|
|
<option value="pro" selected={ state.serie === 'pro' }>Professionnel</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
2026-03-18 14:17:03 +01:00
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
<label><b>Trier par :</b></label><br />
|
2026-03-21 13:47:09 +01:00
|
|
|
<select onchange={ mettreAJourTri }>
|
2026-03-18 14:17:03 +01:00
|
|
|
<option value="nom" selected={ state.sortBy === 'nom' }>Nom</option>
|
|
|
|
|
<option value="ville" selected={ state.sortBy === 'ville' }>Ville</option>
|
|
|
|
|
<option value="taux" selected={ state.sortBy === 'taux' }>Taux d'accès</option>
|
2026-03-20 01:51:08 +01:00
|
|
|
<option value="estimation" selected={ state.sortBy === 'estimation' }>Estimation</option>
|
2026-03-18 14:17:03 +01:00
|
|
|
</select>
|
|
|
|
|
</div>
|
2026-03-18 14:03:43 +01:00
|
|
|
</div>
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
<button class="btn btn-danger" onclick={ viderSelection }>Vider la sélection</button>
|
2026-03-18 14:31:03 +01:00
|
|
|
|
2026-03-18 14:03:43 +01:00
|
|
|
<hr />
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
<div each={ f in obtenirSelectionTriee() } key={ f.id } class={ classeCarte(f) }>
|
2026-03-18 14:03:43 +01:00
|
|
|
<h4>{ f.nom }</h4>
|
2026-03-18 14:17:03 +01:00
|
|
|
|
2026-03-20 01:51:08 +01:00
|
|
|
<p><b>Établissement :</b> { f.etablissement }</p>
|
2026-03-18 14:03:43 +01:00
|
|
|
<p><b>Ville :</b> { f.ville }</p>
|
|
|
|
|
<p><b>Filière :</b> { f.filiere }</p>
|
2026-03-20 01:51:08 +01:00
|
|
|
<p><b>Capacité :</b> { f.capacite }</p>
|
2026-03-18 14:03:43 +01:00
|
|
|
<p><b>Taux d'accès :</b> { f.tauxAcces }%</p>
|
2026-03-18 14:17:03 +01:00
|
|
|
|
2026-03-18 13:54:33 +01:00
|
|
|
<p>
|
2026-03-20 01:51:08 +01:00
|
|
|
<b>Intégrés :</b>
|
2026-03-18 14:17:03 +01:00
|
|
|
Général { f.pctGeneral }% /
|
|
|
|
|
Techno { f.pctTechno }% /
|
|
|
|
|
Pro { f.pctPro }%
|
2026-03-18 13:54:33 +01:00
|
|
|
</p>
|
2026-03-18 14:17:03 +01:00
|
|
|
|
2026-03-20 01:51:08 +01:00
|
|
|
<p class="estimation-result">
|
2026-03-21 13:47:09 +01:00
|
|
|
<span class={ classeEstimation(f) }>
|
|
|
|
|
{ estimerFormation(f) }
|
2026-03-18 14:31:03 +01:00
|
|
|
</span>
|
2026-03-21 13:47:09 +01:00
|
|
|
<span class="estimation-detail">{ detailEstimation(f) }</span>
|
2026-03-18 14:31:03 +01:00
|
|
|
</p>
|
2026-03-18 14:17:03 +01:00
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
<button class="btn btn-small btn-outline" onclick={ retirerSelection.bind(this, f.id) }>
|
2026-03-18 14:17:03 +01:00
|
|
|
Retirer
|
|
|
|
|
</button>
|
2026-03-18 13:54:33 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-03-19 14:37:08 +01:00
|
|
|
|
2026-03-20 01:51:08 +01:00
|
|
|
<div class="message" if={ state.selectedFormations.length === 0 }>
|
|
|
|
|
<h3>Aucune formation sélectionnée</h3>
|
|
|
|
|
<p>Retourne à la <a href="#/">recherche</a> et clique sur "Ajouter à la sélection" pour comparer des formations.</p>
|
2026-03-19 14:37:08 +01:00
|
|
|
</div>
|
2026-03-18 13:21:19 +01:00
|
|
|
</div>
|
|
|
|
|
|
2026-03-18 12:45:44 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
state: {
|
2026-03-20 01:51:08 +01:00
|
|
|
view: 'search',
|
2026-03-18 12:45:44 +01:00
|
|
|
loading: false,
|
|
|
|
|
hasSearched: false,
|
|
|
|
|
results: [],
|
2026-03-18 13:54:33 +01:00
|
|
|
selected: null,
|
2026-03-18 14:03:43 +01:00
|
|
|
selectedFormations: [],
|
|
|
|
|
note: 12,
|
2026-03-18 14:17:03 +01:00
|
|
|
serie: 'general',
|
2026-03-18 14:54:01 +01:00
|
|
|
sortBy: 'nom',
|
|
|
|
|
query: '',
|
2026-03-20 01:51:08 +01:00
|
|
|
filters: {},
|
2026-03-18 14:54:01 +01:00
|
|
|
page: 1,
|
|
|
|
|
limit: 20,
|
2026-03-20 02:35:15 +01:00
|
|
|
total: 0,
|
|
|
|
|
user: null
|
2026-03-18 14:17:03 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onMounted() {
|
2026-03-20 01:51:08 +01:00
|
|
|
var saved = localStorage.getItem('selectionFormations')
|
2026-03-21 13:47:09 +01:00
|
|
|
var soi = this
|
2026-03-18 14:17:03 +01:00
|
|
|
|
2026-03-20 03:06:30 +01:00
|
|
|
// Charger la sélection locale si elle existe
|
2026-03-18 14:17:03 +01:00
|
|
|
if (saved) {
|
|
|
|
|
try {
|
2026-03-20 01:51:08 +01:00
|
|
|
this.state.selectedFormations = JSON.parse(saved)
|
2026-03-18 14:17:03 +01:00
|
|
|
} catch (e) {
|
2026-03-20 03:06:30 +01:00
|
|
|
console.error('Erreur lecture localStorage :', e)
|
2026-03-18 14:17:03 +01:00
|
|
|
}
|
|
|
|
|
}
|
2026-03-20 01:51:08 +01:00
|
|
|
|
2026-03-20 03:06:30 +01:00
|
|
|
// Écouter les changements de connexion Firebase
|
2026-03-20 02:35:15 +01:00
|
|
|
window.firebaseServices.onUserChanged(function(user) {
|
2026-03-20 03:06:30 +01:00
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
soi.update({ user: user })
|
2026-03-20 02:35:15 +01:00
|
|
|
|
2026-03-20 03:06:30 +01:00
|
|
|
// Si un utilisateur vient de se connecter, charger sa sélection depuis Firestore
|
2026-03-20 02:35:15 +01:00
|
|
|
if (user) {
|
2026-03-20 03:06:30 +01:00
|
|
|
window.firebaseServices.loadUserData(user.uid)
|
2026-03-21 13:47:09 +01:00
|
|
|
.then(function(donnees) {
|
|
|
|
|
if (donnees && donnees.selection) {
|
|
|
|
|
soi.update({ selectedFormations: donnees.selection })
|
|
|
|
|
localStorage.setItem('selectionFormations', JSON.stringify(donnees.selection))
|
2026-03-20 03:06:30 +01:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch(function(err) {
|
|
|
|
|
console.error('Erreur chargement Firestore :', err)
|
|
|
|
|
})
|
2026-03-20 02:35:15 +01:00
|
|
|
}
|
2026-03-20 03:06:30 +01:00
|
|
|
|
2026-03-20 02:35:15 +01:00
|
|
|
})
|
|
|
|
|
|
2026-03-20 01:51:08 +01:00
|
|
|
window.addEventListener('hashchange', function() {
|
2026-03-21 13:47:09 +01:00
|
|
|
soi.gererRoute()
|
2026-03-20 01:51:08 +01:00
|
|
|
})
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
this.gererRoute()
|
2026-03-18 12:45:44 +01:00
|
|
|
},
|
|
|
|
|
|
2026-03-20 03:06:30 +01:00
|
|
|
// Appelée après une connexion ou inscription réussie
|
2026-03-21 13:47:09 +01:00
|
|
|
surConnexion() {
|
2026-03-20 03:06:30 +01:00
|
|
|
// L'écouteur onUserChanged dans onMounted gère automatiquement le reste
|
2026-03-20 02:35:15 +01:00
|
|
|
},
|
|
|
|
|
|
2026-03-20 03:06:30 +01:00
|
|
|
// Appelée après une déconnexion
|
2026-03-21 13:47:09 +01:00
|
|
|
surDeconnexion() {
|
2026-03-20 03:06:30 +01:00
|
|
|
// On vide la sélection : l'utilisateur doit se reconnecter pour retrouver ses formations
|
2026-03-20 02:55:00 +01:00
|
|
|
this.update({ selectedFormations: [] })
|
|
|
|
|
localStorage.removeItem('selectionFormations')
|
2026-03-20 02:35:15 +01:00
|
|
|
},
|
|
|
|
|
|
2026-03-20 03:06:30 +01:00
|
|
|
// Sauvegarder la sélection en local ET dans Firestore si connecté
|
2026-03-21 13:47:09 +01:00
|
|
|
async sauvegarderSelection(selection) {
|
2026-03-20 03:06:30 +01:00
|
|
|
|
2026-03-20 02:35:15 +01:00
|
|
|
localStorage.setItem('selectionFormations', JSON.stringify(selection))
|
|
|
|
|
|
|
|
|
|
if (this.state.user) {
|
|
|
|
|
try {
|
|
|
|
|
await window.firebaseServices.saveUserData(this.state.user.uid, { selection: selection })
|
|
|
|
|
} catch (err) {
|
2026-03-20 03:06:30 +01:00
|
|
|
console.error('Erreur sauvegarde Firestore :', err)
|
2026-03-20 02:35:15 +01:00
|
|
|
}
|
|
|
|
|
}
|
2026-03-20 03:06:30 +01:00
|
|
|
|
2026-03-20 02:35:15 +01:00
|
|
|
},
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
gererRoute() {
|
|
|
|
|
var ancre = window.location.hash || '#/'
|
|
|
|
|
var chemin = ancre.slice(1) || '/'
|
2026-03-20 01:51:08 +01:00
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
if (chemin.startsWith('/formation/')) {
|
|
|
|
|
var id = decodeURIComponent(chemin.replace('/formation/', ''))
|
2026-03-20 01:51:08 +01:00
|
|
|
this.update({ view: 'detail' })
|
2026-03-21 13:47:09 +01:00
|
|
|
this.chargerFormationParId(id)
|
|
|
|
|
} else if (chemin === '/comparateur') {
|
2026-03-20 01:51:08 +01:00
|
|
|
this.update({ view: 'comparateur', selected: null })
|
|
|
|
|
} else {
|
|
|
|
|
this.update({ view: 'search', selected: null })
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
async chargerFormationParId(id) {
|
2026-03-20 01:51:08 +01:00
|
|
|
var i
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < this.state.results.length; i++) {
|
|
|
|
|
if (this.state.results[i].id === id) {
|
|
|
|
|
this.update({ selected: this.state.results[i] })
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < this.state.selectedFormations.length; i++) {
|
|
|
|
|
if (this.state.selectedFormations[i].id === id) {
|
|
|
|
|
this.update({ selected: this.state.selectedFormations[i] })
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
2026-03-21 13:47:09 +01:00
|
|
|
var parties = id.split('-')
|
|
|
|
|
var motCle = parties.slice(1).join(' ').substring(0, 30)
|
2026-03-20 01:51:08 +01:00
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
if (motCle) {
|
|
|
|
|
var donnees = await window.chargerFormations(motCle, 10, 0)
|
2026-03-20 01:51:08 +01:00
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
if (donnees.results && donnees.results.length > 0) {
|
|
|
|
|
for (i = 0; i < donnees.results.length; i++) {
|
|
|
|
|
var formation = window.creerFormation(donnees.results[i])
|
|
|
|
|
if (formation.id === id) {
|
|
|
|
|
this.update({ selected: formation })
|
2026-03-20 01:51:08 +01:00
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-21 13:47:09 +01:00
|
|
|
this.update({ selected: window.creerFormation(donnees.results[0]) })
|
2026-03-20 01:51:08 +01:00
|
|
|
}
|
|
|
|
|
}
|
2026-03-21 13:47:09 +01:00
|
|
|
} catch (erreur) {
|
|
|
|
|
console.error('Erreur chargement formation :', erreur)
|
2026-03-20 01:51:08 +01:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
afficherDetail(index) {
|
2026-03-20 01:51:08 +01:00
|
|
|
var formation = this.state.results[index]
|
|
|
|
|
this.update({ selected: formation, view: 'detail' })
|
|
|
|
|
window.location.hash = '#/formation/' + encodeURIComponent(formation.id)
|
|
|
|
|
},
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
retourRecherche() {
|
2026-03-20 01:51:08 +01:00
|
|
|
window.location.hash = '#/'
|
|
|
|
|
},
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
async lancerRecherche(requete, filtres) {
|
2026-03-18 12:45:44 +01:00
|
|
|
this.update({
|
|
|
|
|
loading: true,
|
|
|
|
|
hasSearched: true,
|
2026-03-18 14:54:01 +01:00
|
|
|
selected: null,
|
2026-03-20 01:51:08 +01:00
|
|
|
view: 'search',
|
2026-03-21 13:47:09 +01:00
|
|
|
query: requete,
|
|
|
|
|
filters: filtres || {},
|
2026-03-18 14:54:01 +01:00
|
|
|
page: 1
|
|
|
|
|
})
|
|
|
|
|
|
2026-03-20 01:51:08 +01:00
|
|
|
window.location.hash = '#/'
|
2026-03-21 13:47:09 +01:00
|
|
|
await this.chargerPage(1)
|
2026-03-18 14:54:01 +01:00
|
|
|
},
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
async chargerPage(page) {
|
2026-03-20 01:51:08 +01:00
|
|
|
this.update({ loading: true })
|
2026-03-18 12:45:44 +01:00
|
|
|
|
|
|
|
|
try {
|
2026-03-21 13:47:09 +01:00
|
|
|
var decalage = (page - 1) * this.state.limit
|
2026-03-18 14:54:01 +01:00
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
var donnees = await window.chargerFormations(
|
2026-03-18 14:54:01 +01:00
|
|
|
this.state.query,
|
|
|
|
|
this.state.limit,
|
2026-03-21 13:47:09 +01:00
|
|
|
decalage,
|
2026-03-20 01:51:08 +01:00
|
|
|
this.state.filters
|
2026-03-18 14:54:01 +01:00
|
|
|
)
|
|
|
|
|
|
2026-03-20 01:51:08 +01:00
|
|
|
var formations = []
|
2026-03-18 12:45:44 +01:00
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
if (donnees.results) {
|
|
|
|
|
for (var i = 0; i < donnees.results.length; i++) {
|
|
|
|
|
var brut = donnees.results[i]
|
|
|
|
|
formations.push(window.creerFormation(brut))
|
2026-03-18 12:45:44 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
var total = 0
|
|
|
|
|
|
|
|
|
|
if (donnees.total_count) {
|
|
|
|
|
total = donnees.total_count
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-18 12:45:44 +01:00
|
|
|
this.update({
|
|
|
|
|
results: formations,
|
2026-03-21 13:47:09 +01:00
|
|
|
total: total,
|
|
|
|
|
page: page,
|
2026-03-18 12:45:44 +01:00
|
|
|
loading: false
|
|
|
|
|
})
|
2026-03-21 13:47:09 +01:00
|
|
|
} catch (erreur) {
|
|
|
|
|
console.error(erreur)
|
2026-03-18 12:45:44 +01:00
|
|
|
this.update({
|
|
|
|
|
results: [],
|
2026-03-21 13:47:09 +01:00
|
|
|
total: 0,
|
2026-03-18 12:45:44 +01:00
|
|
|
loading: false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
nombreTotalPages() {
|
2026-03-18 14:54:01 +01:00
|
|
|
return Math.ceil(this.state.total / this.state.limit)
|
|
|
|
|
},
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
async pageSuivante() {
|
|
|
|
|
if (this.state.page < this.nombreTotalPages()) {
|
|
|
|
|
await this.chargerPage(this.state.page + 1)
|
2026-03-18 14:54:01 +01:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
async pagePrecedente() {
|
2026-03-18 14:54:01 +01:00
|
|
|
if (this.state.page > 1) {
|
2026-03-21 13:47:09 +01:00
|
|
|
await this.chargerPage(this.state.page - 1)
|
2026-03-18 14:54:01 +01:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
ajouterSelection(index) {
|
|
|
|
|
var formation = this.state.results[index]
|
|
|
|
|
var selection = this.state.selectedFormations.slice()
|
|
|
|
|
var dejaAjout = false
|
2026-03-18 13:44:30 +01:00
|
|
|
|
2026-03-20 01:51:08 +01:00
|
|
|
for (var i = 0; i < selection.length; i++) {
|
2026-03-18 13:54:33 +01:00
|
|
|
if (selection[i].id === formation.id) {
|
2026-03-21 13:47:09 +01:00
|
|
|
dejaAjout = true
|
2026-03-18 13:54:33 +01:00
|
|
|
}
|
|
|
|
|
}
|
2026-03-18 13:44:30 +01:00
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
if (!dejaAjout) {
|
2026-03-18 13:54:33 +01:00
|
|
|
selection.push(formation)
|
|
|
|
|
this.update({ selectedFormations: selection })
|
2026-03-21 13:47:09 +01:00
|
|
|
this.sauvegarderSelection(selection)
|
2026-03-18 13:54:33 +01:00
|
|
|
}
|
|
|
|
|
},
|
2026-03-18 13:44:30 +01:00
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
retirerSelection(id) {
|
|
|
|
|
var nouvelleSelection = []
|
2026-03-18 14:17:03 +01:00
|
|
|
|
2026-03-20 01:51:08 +01:00
|
|
|
for (var i = 0; i < this.state.selectedFormations.length; i++) {
|
|
|
|
|
var f = this.state.selectedFormations[i]
|
2026-03-18 14:17:03 +01:00
|
|
|
|
|
|
|
|
if (f.id !== id) {
|
2026-03-21 13:47:09 +01:00
|
|
|
nouvelleSelection.push(f)
|
2026-03-18 14:17:03 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
this.update({ selectedFormations: nouvelleSelection })
|
|
|
|
|
this.sauvegarderSelection(nouvelleSelection)
|
2026-03-18 14:03:43 +01:00
|
|
|
},
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
viderSelection() {
|
2026-03-20 01:51:08 +01:00
|
|
|
this.update({ selectedFormations: [] })
|
2026-03-21 13:47:09 +01:00
|
|
|
this.sauvegarderSelection([])
|
2026-03-18 14:31:03 +01:00
|
|
|
},
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
mettreAJourNote(e) {
|
2026-03-20 03:06:30 +01:00
|
|
|
this.update({ note: Number(e.target.value) })
|
|
|
|
|
},
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
mettreAJourSerie(e) {
|
2026-03-20 03:06:30 +01:00
|
|
|
this.update({ serie: e.target.value })
|
|
|
|
|
},
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
mettreAJourTri(e) {
|
2026-03-20 03:06:30 +01:00
|
|
|
this.update({ sortBy: e.target.value })
|
|
|
|
|
},
|
2026-03-18 14:17:03 +01:00
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
obtenirSelectionTriee() {
|
2026-03-20 01:51:08 +01:00
|
|
|
var selection = this.state.selectedFormations.slice()
|
2026-03-21 13:47:09 +01:00
|
|
|
var soi = this
|
2026-03-18 14:17:03 +01:00
|
|
|
|
|
|
|
|
if (this.state.sortBy === 'taux') {
|
2026-03-20 01:51:08 +01:00
|
|
|
selection.sort(function(a, b) { return b.tauxAcces - a.tauxAcces })
|
2026-03-18 14:17:03 +01:00
|
|
|
} else if (this.state.sortBy === 'ville') {
|
2026-03-20 01:51:08 +01:00
|
|
|
selection.sort(function(a, b) { return a.ville.localeCompare(b.ville) })
|
|
|
|
|
} else if (this.state.sortBy === 'estimation') {
|
2026-03-21 13:47:09 +01:00
|
|
|
selection.sort(function(a, b) { return soi.calculerScore(b) - soi.calculerScore(a) })
|
2026-03-18 14:17:03 +01:00
|
|
|
} else {
|
2026-03-20 01:51:08 +01:00
|
|
|
selection.sort(function(a, b) { return a.nom.localeCompare(b.nom) })
|
2026-03-18 14:17:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return selection
|
|
|
|
|
},
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
pourcentageSerie(f) {
|
|
|
|
|
if (this.state.serie === 'general') {
|
|
|
|
|
return f.pctGeneral || 0
|
|
|
|
|
}
|
|
|
|
|
if (this.state.serie === 'techno') {
|
|
|
|
|
return f.pctTechno || 0
|
|
|
|
|
}
|
|
|
|
|
if (this.state.serie === 'pro') {
|
|
|
|
|
return f.pctPro || 0
|
|
|
|
|
}
|
2026-03-20 01:51:08 +01:00
|
|
|
return 0
|
|
|
|
|
},
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
calculerScore(f) {
|
|
|
|
|
var score = 0
|
|
|
|
|
var note = this.state.note
|
2026-03-20 01:51:08 +01:00
|
|
|
var tauxAcces = f.tauxAcces || 0
|
2026-03-21 13:47:09 +01:00
|
|
|
var pctSerie = this.pourcentageSerie(f)
|
2026-03-20 01:51:08 +01:00
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
if (tauxAcces >= 80) {
|
|
|
|
|
score += 30
|
|
|
|
|
} else if (tauxAcces >= 50) {
|
|
|
|
|
score += 24
|
|
|
|
|
} else if (tauxAcces >= 30) {
|
|
|
|
|
score += 16
|
|
|
|
|
} else if (tauxAcces >= 15) {
|
|
|
|
|
score += 8
|
|
|
|
|
} else {
|
|
|
|
|
score += 2
|
|
|
|
|
}
|
2026-03-20 01:51:08 +01:00
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
if (note >= 17) {
|
|
|
|
|
score += 40
|
|
|
|
|
} else if (note >= 15) {
|
|
|
|
|
score += 32
|
|
|
|
|
} else if (note >= 13) {
|
|
|
|
|
score += 22
|
|
|
|
|
} else if (note >= 11) {
|
|
|
|
|
score += 14
|
|
|
|
|
} else if (note >= 9) {
|
|
|
|
|
score += 6
|
|
|
|
|
} else {
|
|
|
|
|
score += 0
|
|
|
|
|
}
|
2026-03-20 01:51:08 +01:00
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
if (pctSerie >= 60) {
|
|
|
|
|
score += 30
|
|
|
|
|
} else if (pctSerie >= 40) {
|
|
|
|
|
score += 24
|
|
|
|
|
} else if (pctSerie >= 20) {
|
|
|
|
|
score += 16
|
|
|
|
|
} else if (pctSerie >= 5) {
|
|
|
|
|
score += 8
|
|
|
|
|
} else {
|
|
|
|
|
score += 0
|
|
|
|
|
}
|
2026-03-20 01:51:08 +01:00
|
|
|
|
|
|
|
|
return score
|
|
|
|
|
},
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
estimerFormation(f) {
|
|
|
|
|
var score = this.calculerScore(f)
|
2026-03-18 14:03:43 +01:00
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
if (score >= 85) {
|
|
|
|
|
return 'Très favorable'
|
|
|
|
|
}
|
|
|
|
|
if (score >= 65) {
|
|
|
|
|
return 'Favorable'
|
|
|
|
|
}
|
|
|
|
|
if (score >= 45) {
|
|
|
|
|
return 'Possible'
|
|
|
|
|
}
|
|
|
|
|
if (score >= 25) {
|
|
|
|
|
return 'Difficile'
|
|
|
|
|
}
|
2026-03-20 01:51:08 +01:00
|
|
|
return 'Très difficile'
|
2026-03-18 14:31:03 +01:00
|
|
|
},
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
classeEstimation(f) {
|
|
|
|
|
var resultat = this.estimerFormation(f)
|
2026-03-18 14:31:03 +01:00
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
if (resultat === 'Très favorable') {
|
|
|
|
|
return 'estimate tres-favorable'
|
|
|
|
|
}
|
|
|
|
|
if (resultat === 'Favorable') {
|
|
|
|
|
return 'estimate favorable'
|
|
|
|
|
}
|
|
|
|
|
if (resultat === 'Possible') {
|
|
|
|
|
return 'estimate possible'
|
|
|
|
|
}
|
|
|
|
|
if (resultat === 'Difficile') {
|
|
|
|
|
return 'estimate difficile'
|
|
|
|
|
}
|
2026-03-20 01:51:08 +01:00
|
|
|
return 'estimate tres-difficile'
|
|
|
|
|
},
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
classeCarte(f) {
|
|
|
|
|
var resultat = this.estimerFormation(f)
|
2026-03-20 01:51:08 +01:00
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
if (resultat === 'Très favorable') {
|
|
|
|
|
return 'card card-tres-favorable'
|
|
|
|
|
}
|
|
|
|
|
if (resultat === 'Favorable') {
|
|
|
|
|
return 'card card-favorable'
|
|
|
|
|
}
|
|
|
|
|
if (resultat === 'Possible') {
|
|
|
|
|
return 'card card-possible'
|
|
|
|
|
}
|
|
|
|
|
if (resultat === 'Difficile') {
|
|
|
|
|
return 'card card-difficile'
|
|
|
|
|
}
|
2026-03-20 01:51:08 +01:00
|
|
|
return 'card card-tres-difficile'
|
|
|
|
|
},
|
|
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
detailEstimation(f) {
|
|
|
|
|
var tauxAcces = f.tauxAcces || 0
|
|
|
|
|
var pctSerie = this.pourcentageSerie(f)
|
|
|
|
|
var nomSerie = ''
|
2026-03-20 01:51:08 +01:00
|
|
|
|
2026-03-21 13:47:09 +01:00
|
|
|
if (this.state.serie === 'general') {
|
|
|
|
|
nomSerie = 'Gén'
|
|
|
|
|
} else if (this.state.serie === 'techno') {
|
|
|
|
|
nomSerie = 'Techno'
|
|
|
|
|
} else {
|
|
|
|
|
nomSerie = 'Pro'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 'Taux ' + tauxAcces + '% · ' + nomSerie + ' ' + pctSerie + '% · Note ' + this.state.note + '/20'
|
2026-03-18 12:45:44 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
2026-03-19 14:37:08 +01:00
|
|
|
</app>
|