fix: solución de bloqueos y estandarización de permisos
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { BACKEND_URL } from '$lib/config/backend';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
export interface AppSettingsRequest {
|
||||
tenant_id?: number | null;
|
||||
@@ -11,24 +11,17 @@ export const appSettingsApi = {
|
||||
* Resolves settings merging Global -> Tenant -> Company hierarchy
|
||||
*/
|
||||
async getResolved(tenantId: number, companyId: number): Promise<Record<string, any>> {
|
||||
const response = await fetch(`${BACKEND_URL}/v1/a76/app-settings/resolved?tenant_id=${tenantId}&company_id=${companyId}`);
|
||||
if (!response.ok) throw new Error('Error al obtener configuraciones');
|
||||
return response.json();
|
||||
const res = await api.get<Record<string, any>>(`/v1/a76/app-settings/resolved?tenant_id=${tenantId}&company_id=${companyId}`);
|
||||
if (res.error) throw new Error(res.error);
|
||||
return res.data || {};
|
||||
},
|
||||
|
||||
/**
|
||||
* Upserts an override at a specific level
|
||||
*/
|
||||
async upsert(payload: AppSettingsRequest): Promise<any> {
|
||||
const response = await fetch(`${BACKEND_URL}/v1/a76/app-settings/upsert`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
if (!response.ok) {
|
||||
const error = await response.json();
|
||||
throw new Error(error.detail || 'Error al guardar configuración');
|
||||
}
|
||||
return response.json();
|
||||
const res = await api.post<any>(`/v1/a76/app-settings/upsert`, payload);
|
||||
if (res.error) throw new Error(res.error);
|
||||
return res.data;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user