/** * Reporting API Client * * Client functions for the Executive Reporting module. * Communicates with the Go backend via Next.js API proxy at /api/sdk/v1/reporting/* */ import type { ExecutiveReport, ComplianceScoreResponse, Deadline, RiskOverview, } from './types' const BASE_URL = '/api/sdk/v1/reporting' async function apiFetch(path: string): Promise { const res = await fetch(`${BASE_URL}${path}`, { headers: { 'Content-Type': 'application/json', 'X-Tenant-ID': typeof window !== 'undefined' ? (localStorage.getItem('bp-tenant-id') || 'default') : 'default', }, }) if (!res.ok) { const error = await res.json().catch(() => ({ error: res.statusText })) throw new Error(error.error || `API Error: ${res.status}`) } return res.json() } /** * Vollstaendigen Executive Report abrufen * GET /sdk/v1/reporting/executive */ export async function getExecutiveReport(): Promise { return apiFetch('/executive') } /** * Nur den Compliance-Score abrufen (leichtgewichtig) * GET /sdk/v1/reporting/score */ export async function getComplianceScore(): Promise { return apiFetch('/score') } /** * Bevorstehende Fristen abrufen * GET /sdk/v1/reporting/deadlines */ export async function getUpcomingDeadlines(): Promise<{ deadlines: Deadline[]; total: number }> { return apiFetch<{ deadlines: Deadline[]; total: number }>('/deadlines') } /** * Risikouebersicht abrufen * GET /sdk/v1/reporting/risks */ export async function getRiskOverview(): Promise { return apiFetch('/risks') }