feat(админка): действия в карточке и тост отмены

This commit is contained in:
anor
2026-11-06 22:01:23 +10:00
parent e15369c4d4
commit 0e9a95e95b
9 changed files with 166 additions and 9 deletions
+5 -1
View File
@@ -9,6 +9,10 @@ export async function api(path, opts = {}) {
if (opts.body && !headers['Content-Type']) headers['Content-Type'] = 'application/json';
const r = await fetch(path, {...opts, headers});
if (r.status === 401 || r.status === 403) throw new ApiError(r.status, 'Нужен вход оператора');
if (!r.ok) throw new ApiError(r.status, 'Ошибка ' + r.status);
if (!r.ok) {
let detail = '';
try { detail = String((await r.json()).detail || ''); } catch (e) { /* не JSON */ }
throw new ApiError(r.status, detail || ('Ошибка ' + r.status));
}
return r.json();
}