test session
Browse files- templates/index.html +36 -5
templates/index.html
CHANGED
|
@@ -380,25 +380,50 @@
|
|
| 380 |
if (confirmRoleBtn) {
|
| 381 |
confirmRoleBtn.addEventListener('click', function () {
|
| 382 |
if (selectedRole) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 383 |
fetch('/api/ask', {
|
| 384 |
method: 'POST',
|
| 385 |
headers: { 'Content-Type': 'application/json' },
|
| 386 |
body: JSON.stringify({ role_selection: selectedRole }),
|
| 387 |
credentials: 'same-origin'
|
| 388 |
})
|
| 389 |
-
.then(response =>
|
|
|
|
|
|
|
|
|
|
| 390 |
.then(data => {
|
|
|
|
| 391 |
if (data.status === 'role_selected') {
|
| 392 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 393 |
}
|
| 394 |
})
|
| 395 |
-
.catch(error =>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 396 |
}
|
| 397 |
});
|
| 398 |
}
|
| 399 |
|
| 400 |
if (resetRoleBtn) {
|
| 401 |
resetRoleBtn.addEventListener('click', function () {
|
|
|
|
|
|
|
|
|
|
| 402 |
fetch('/api/reset-role', {
|
| 403 |
method: 'POST',
|
| 404 |
headers: { 'Content-Type': 'application/json' },
|
|
@@ -406,11 +431,17 @@
|
|
| 406 |
})
|
| 407 |
.then(response => response.json())
|
| 408 |
.then(data => {
|
|
|
|
| 409 |
if (data.status === 'role_reset') {
|
| 410 |
-
|
|
|
|
|
|
|
| 411 |
}
|
| 412 |
})
|
| 413 |
-
.catch(error =>
|
|
|
|
|
|
|
|
|
|
| 414 |
});
|
| 415 |
}
|
| 416 |
|
|
|
|
| 380 |
if (confirmRoleBtn) {
|
| 381 |
confirmRoleBtn.addEventListener('click', function () {
|
| 382 |
if (selectedRole) {
|
| 383 |
+
console.log('Envoi de la sélection de rôle:', selectedRole);
|
| 384 |
+
confirmRoleBtn.disabled = true;
|
| 385 |
+
confirmRoleBtn.textContent = 'En cours...';
|
| 386 |
+
|
| 387 |
fetch('/api/ask', {
|
| 388 |
method: 'POST',
|
| 389 |
headers: { 'Content-Type': 'application/json' },
|
| 390 |
body: JSON.stringify({ role_selection: selectedRole }),
|
| 391 |
credentials: 'same-origin'
|
| 392 |
})
|
| 393 |
+
.then(response => {
|
| 394 |
+
console.log('Réponse status:', response.status);
|
| 395 |
+
return response.json();
|
| 396 |
+
})
|
| 397 |
.then(data => {
|
| 398 |
+
console.log('Données reçues:', data);
|
| 399 |
if (data.status === 'role_selected') {
|
| 400 |
+
console.log('Rôle sélectionné avec succès, rechargement...');
|
| 401 |
+
// Attendre 500ms avant de recharger pour assurer la sauvegarde de la session
|
| 402 |
+
setTimeout(() => {
|
| 403 |
+
window.location.href = window.location.origin + '/';
|
| 404 |
+
}, 500);
|
| 405 |
+
} else {
|
| 406 |
+
console.error('Erreur: statut inattendu', data);
|
| 407 |
+
alert('Erreur lors de la sélection du rôle. Veuillez réessayer.');
|
| 408 |
+
confirmRoleBtn.disabled = false;
|
| 409 |
+
confirmRoleBtn.textContent = '✓ Confirmer mon profil';
|
| 410 |
}
|
| 411 |
})
|
| 412 |
+
.catch(error => {
|
| 413 |
+
console.error('Erreur lors de la sélection de rôle:', error);
|
| 414 |
+
alert('Erreur réseau: ' + error.message);
|
| 415 |
+
confirmRoleBtn.disabled = false;
|
| 416 |
+
confirmRoleBtn.textContent = '✓ Confirmer mon profil';
|
| 417 |
+
});
|
| 418 |
}
|
| 419 |
});
|
| 420 |
}
|
| 421 |
|
| 422 |
if (resetRoleBtn) {
|
| 423 |
resetRoleBtn.addEventListener('click', function () {
|
| 424 |
+
console.log('Réinitialisation du rôle...');
|
| 425 |
+
resetRoleBtn.disabled = true;
|
| 426 |
+
|
| 427 |
fetch('/api/reset-role', {
|
| 428 |
method: 'POST',
|
| 429 |
headers: { 'Content-Type': 'application/json' },
|
|
|
|
| 431 |
})
|
| 432 |
.then(response => response.json())
|
| 433 |
.then(data => {
|
| 434 |
+
console.log('Réponse réinitialisation:', data);
|
| 435 |
if (data.status === 'role_reset') {
|
| 436 |
+
setTimeout(() => {
|
| 437 |
+
window.location.href = window.location.origin + '/';
|
| 438 |
+
}, 500);
|
| 439 |
}
|
| 440 |
})
|
| 441 |
+
.catch(error => {
|
| 442 |
+
console.error('Erreur lors de la réinitialisation:', error);
|
| 443 |
+
resetRoleBtn.disabled = false;
|
| 444 |
+
});
|
| 445 |
});
|
| 446 |
}
|
| 447 |
|