Skip to content

Commit

Permalink
🐛 Fix api keys not showing sometimes
Browse files Browse the repository at this point in the history
  • Loading branch information
gmpetrov committed Apr 6, 2023
1 parent 2c6d54e commit d2b5730
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions pages/api/datastores/[id]/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const getDatastore = async (
},
include: {
datasources: true,
apiKeys: true,
},
});

Expand Down
16 changes: 8 additions & 8 deletions pages/datastores/[datastoreId]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ export default function DatastorePage() {
refreshInterval: 5000,
});

const getApiKeysQuery = useSWR<Prisma.PromiseReturnType<typeof getApiKeys>>(
`/api/datastores/${router.query?.datastoreId}/api-keys`,
fetcher
);
// const getApiKeysQuery = useSWR<Prisma.PromiseReturnType<typeof getApiKeys>>(
// `/api/datastores/${router.query?.datastoreId}/api-keys`,
// fetcher
// );

const handleChangeTab = (tab: string) => {
router.query.tab = tab;
Expand Down Expand Up @@ -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) => {
Expand All @@ -112,7 +112,7 @@ export default function DatastorePage() {
}
);

getApiKeysQuery.mutate();
getDatastoreQuery.mutate();
}
};

Expand Down Expand Up @@ -325,7 +325,7 @@ export default function DatastorePage() {
</Typography>

<Stack direction={'column'} gap={2} mt={2}>
{getApiKeysQuery?.data?.map((each) => (
{getDatastoreQuery?.data?.apiKeys?.map((each) => (
<>
<Stack key={each.id} direction={'row'} gap={2}>
<Alert color="neutral" sx={{ width: '100%' }}>
Expand Down Expand Up @@ -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: [
Expand Down

1 comment on commit d2b5730

@vercel
Copy link

@vercel vercel bot commented on d2b5730 Apr 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.