Merge development into feature/table-invoice
This commit is contained in:
34
frontend/src/lib/api/dashboard/a76/app-settings.ts
Normal file
34
frontend/src/lib/api/dashboard/a76/app-settings.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { BACKEND_URL } from '$lib/config/backend';
|
||||
|
||||
export interface AppSettingsRequest {
|
||||
tenant_id?: number | null;
|
||||
company_id?: number | null;
|
||||
settings: Record<string, any>;
|
||||
}
|
||||
|
||||
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();
|
||||
},
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
};
|
||||
@@ -77,5 +77,5 @@ export async function updatePackage(
|
||||
}
|
||||
|
||||
export async function deletePackage(id: number, companyId: number): Promise<ApiResponse<void>> {
|
||||
return await api.delete(`/v1/a76/packages/${id}/?company_id=${companyId}`);
|
||||
return await api.delete(`/v1/a76/packages/${id}?company_id=${companyId}`);
|
||||
}
|
||||
Reference in New Issue
Block a user