feat(админка): Мой день с очередью

This commit is contained in:
anor
2026-11-06 21:23:53 +10:00
parent 0e7fd76fa1
commit 33240f6ddd
12 changed files with 274 additions and 7 deletions
+14
View File
@@ -0,0 +1,14 @@
export class ApiError extends Error {
constructor(status, message) { super(message); this.status = status; }
}
export async function api(path, opts = {}) {
const token = localStorage.getItem('token') || '';
const headers = {...(opts.headers || {})};
if (token) headers.Authorization = 'Bearer ' + token;
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);
return r.json();
}