last update
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user