From 81813dc6255e41a7447abc721d88642016deca81 Mon Sep 17 00:00:00 2001 From: Michael Borohovski Date: Wed, 4 Mar 2026 16:37:00 -0800 Subject: [PATCH] Fix token UI success handling, fetch error surfacing, and docs key stability --- src/app/admin/settings/tabs/ApiTab/ApiTab.tsx | 16 +++++++------ src/app/api-docs/page.tsx | 2 +- src/components/profile/ApiTokensSection.tsx | 2 ++ src/lib/hooks/useApiTokens.ts | 24 +++++++++++++++---- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/app/admin/settings/tabs/ApiTab/ApiTab.tsx b/src/app/admin/settings/tabs/ApiTab/ApiTab.tsx index f57bfb0..30508d8 100644 --- a/src/app/admin/settings/tabs/ApiTab/ApiTab.tsx +++ b/src/app/admin/settings/tabs/ApiTab/ApiTab.tsx @@ -47,9 +47,9 @@ export function ApiTab() { const extraBody: Record = {}; if (newTokenUserId) extraBody.userId = newTokenUserId; if (newTokenRole) extraBody.role = newTokenRole; - await api.handleCreate(extraBody); - // Reset admin-specific fields on success - if (!api.error) { + const created = await api.handleCreate(extraBody); + // Reset admin-specific fields only when create succeeds + if (created) { setNewTokenUserId(''); setNewTokenRole(''); } @@ -123,10 +123,12 @@ export function ApiTab() { -