fix(erp): enable erp pages and menu items

This commit is contained in:
Erik Silva
2025-12-29 17:23:59 -03:00
parent e124a64a5d
commit adbff9bb1e
13990 changed files with 1110936 additions and 59 deletions

View File

@@ -43,13 +43,24 @@ export async function apiRequest<T = any>(
},
});
const data = await response.json();
// Handle empty responses
const text = await response.text();
let data: any = {};
if (text) {
try {
data = JSON.parse(text);
} catch (e) {
// If not JSON but has text, might be an error or plain text
data = { message: text };
}
}
if (!response.ok) {
throw new Error(data.message || `Erro ${response.status}`);
}
return data;
return data as T;
} catch (error) {
if (error instanceof Error) {
throw error;