From d2b5730484171508af9f4e2bfd090ee5755f4e7c Mon Sep 17 00:00:00 2001 From: Georges Petrov Date: Thu, 6 Apr 2023 10:04:58 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20api=20keys=20not=20showing?= =?UTF-8?q?=20sometimes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/api/datastores/[id]/index.ts | 1 + pages/datastores/[datastoreId]/index.tsx | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pages/api/datastores/[id]/index.ts b/pages/api/datastores/[id]/index.ts index 126bef869..e1acafae5 100644 --- a/pages/api/datastores/[id]/index.ts +++ b/pages/api/datastores/[id]/index.ts @@ -20,6 +20,7 @@ export const getDatastore = async ( }, include: { datasources: true, + apiKeys: true, }, }); diff --git a/pages/datastores/[datastoreId]/index.tsx b/pages/datastores/[datastoreId]/index.tsx index 969d03977..e8622bd81 100644 --- a/pages/datastores/[datastoreId]/index.tsx +++ b/pages/datastores/[datastoreId]/index.tsx @@ -67,10 +67,10 @@ export default function DatastorePage() { refreshInterval: 5000, }); - const getApiKeysQuery = useSWR>( - `/api/datastores/${router.query?.datastoreId}/api-keys`, - fetcher - ); + // const getApiKeysQuery = useSWR>( + // `/api/datastores/${router.query?.datastoreId}/api-keys`, + // fetcher + // ); const handleChangeTab = (tab: string) => { router.query.tab = tab; @@ -98,7 +98,7 @@ export default function DatastorePage() { const handleCreatApiKey = async () => { await axios.post(`/api/datastores/${getDatastoreQuery?.data?.id}/api-keys`); - getApiKeysQuery.mutate(); + getDatastoreQuery.mutate(); }; const handleDeleteApiKey = async (id: string) => { @@ -112,7 +112,7 @@ export default function DatastorePage() { } ); - getApiKeysQuery.mutate(); + getDatastoreQuery.mutate(); } }; @@ -325,7 +325,7 @@ export default function DatastorePage() { - {getApiKeysQuery?.data?.map((each) => ( + {getDatastoreQuery?.data?.apiKeys?.map((each) => ( <> @@ -377,7 +377,7 @@ export default function DatastorePage() { )}/query \\`} -H 'Content-Type: application/json' \\ -H 'Authorization: Bearer ${ - getApiKeysQuery?.data?.[0]?.key || 'DATASTORE_API_KEY' + getDatastoreQuery?.data?.apiKeys?.[0]?.key || 'DATASTORE_API_KEY' }' \\ -d '${JSON.stringify({ queries: [