last update

This commit is contained in:
PTA
2026-08-27 11:38:59 +02:00
parent 1a67080268
commit 90e8a06ca0
11 changed files with 2423 additions and 708 deletions

View File

@@ -26,7 +26,7 @@
const PTA = window.PTA;
if (!PTA) return;
const { readJsonResponse, apiErrorMessage } = PTA.utils;
const { apiJson } = PTA.utils;
const corps = () => document.querySelector('#agent-assignment-body');
@@ -41,14 +41,6 @@
boite.textContent = texte;
}
/** Appel d'API mutualisé : toute réponse non-OK devient une exception. */
async function api(url, options = {}) {
const reponse = await fetch(url, options);
const donnees = await readJsonResponse(reponse);
if (!reponse.ok) throw new Error(apiErrorMessage(donnees, 'Opération impossible.'));
return donnees;
}
/**
* Met un bouton de ligne à l'état du compte correspondant.
*
@@ -100,7 +92,7 @@
if (!corps() || chargement) return;
chargement = true;
try {
const donnees = await api('api/acces_comptes.php?role=AGENT');
const donnees = await apiJson('api/acces_comptes.php?role=AGENT');
comptesParAgent = new Map(
(donnees.comptes || [])
.filter((compte) => compte.id_agent !== null)
@@ -130,7 +122,7 @@
bouton.disabled = true;
try {
const donnees = await api('api/acces_compte_statut.php', {
const donnees = await apiJson('api/acces_compte_statut.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({