diff --git a/src/lib/api/facility-admin.ts b/src/lib/api/facility-admin.ts index fbff788..ea79a26 100644 --- a/src/lib/api/facility-admin.ts +++ b/src/lib/api/facility-admin.ts @@ -29,10 +29,14 @@ import apiFetch from '@/src/utils/apiFetch'; /** * Handle API response + * Flask backend wraps responses in: { status: 'success'|'fail', data: {...} } */ async function handleApiResponse(response: Response): Promise> { if (response.ok) { - const data = await response.json(); + const json = await response.json(); + // Flask returns { status: 'success', data: {...} } + // Extract the actual data from the wrapper + const data = json.data !== undefined ? json.data : json; return { success: true, data }; } @@ -529,7 +533,15 @@ export async function getPolicy( headers: { 'Content-Type': 'application/json' }, }); - return handleApiResponse(response); + const result = await handleApiResponse(response); + + // Backend returns { status: 'success', data: { policy: {...} } } + // Extract the policy object + if (result.success && result.data.policy) { + return { success: true, data: result.data.policy }; + } + + return result as FacilityAdminApiResult; } catch (error) { return { success: false,