From 87338af052767fdc75b4aeef09c424a80dc705c4 Mon Sep 17 00:00:00 2001 From: oabrivard Date: Sun, 22 Mar 2026 22:16:28 +0100 Subject: [PATCH] fix: align frontend API types and error handling with backend contracts - updateRole return type matches backend's {id, role} instead of full AdminUser - fetchFile error priority aligned with central client (message before error) Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/api/admin.ts | 4 ++-- frontend/src/api/syntheses.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/api/admin.ts b/frontend/src/api/admin.ts index f10415c..50d41c7 100644 --- a/frontend/src/api/admin.ts +++ b/frontend/src/api/admin.ts @@ -46,6 +46,6 @@ export const adminUsersApi = { api.get('/admin/users'), /** PUT /admin/users/:id/role -- promote or demote a user (admin/user). */ - updateRole: (id: string, data: UpdateUserRoleRequest): Promise => - api.put(`/admin/users/${id}/role`, data), + updateRole: (id: string, data: UpdateUserRoleRequest): Promise<{ id: string; role: string }> => + api.put<{ id: string; role: string }>(`/admin/users/${id}/role`, data), }; diff --git a/frontend/src/api/syntheses.ts b/frontend/src/api/syntheses.ts index de2021a..caba9f3 100644 --- a/frontend/src/api/syntheses.ts +++ b/frontend/src/api/syntheses.ts @@ -50,7 +50,7 @@ export async function fetchFile(path: string): Promise { const errorBody = await response.json().catch(() => ({ error: 'Unknown error' })); throw { status: response.status, - message: errorBody.error || errorBody.message || `HTTP ${response.status}`, + message: errorBody.message || errorBody.error || `HTTP ${response.status}`, }; }