Add account API key management

This commit is contained in:
Mike Cao committed 2026-09-01 21:50:07 -07:00
1 parent 98b824ce48
commit f1c5b4f7bb
32 files changed
+1618 -15

No files matched your search

+1
View File
@@ -11,6 +11,7 @@ export * from './context/useWebsite';
// Query hooks
export * from './queries/useActiveUsersQuery';
export * from './queries/useApiKeysQuery';
export * from './queries/useBoardQuery';
export * from './queries/useBoardSharesQuery';
export * from './queries/useBoardsQuery';
@@ -0,0 +1,20 @@
import { useApi } from '../useApi';
import { useModified } from '../useModified';
export interface ApiKeyData {
id: string;
name: string;
keyPrefix: string;
lastUsedAt: string | null;
createdAt: string;
}
export function useApiKeysQuery() {
const { get, useQuery } = useApi();
const { modified } = useModified('api-keys');
return useQuery<ApiKeyData[]>({
queryKey: ['api-keys', { modified }],
queryFn: () => get('/me/api-keys'),
});
}
+8
View File
@@ -430,6 +430,12 @@ export const labels: Record<string, string> = {
twoFactorGlobalActiveTooltip: 'label.two-factor-global-active-tooltip',
twoFactorVerify: 'label.two-factor-verify',
twoFactorLogin: 'label.two-factor-login',
apiKeys: 'label.api-keys',
apiKey: 'label.api-key',
createApiKey: 'label.create-api-key',
lastUsed: 'label.last-used',
never: 'label.never',
copy: 'label.copy',
};
export const messages: Record<string, string> = {
@@ -511,4 +517,6 @@ export const messages: Record<string, string> = {
twoFactorErrorNoPendingSetup: 'message.two-factor-error-no-pending-setup',
twoFactorErrorNotConfigured: 'message.two-factor-error-not-configured',
replayMinDurationDescription: 'message.replay-min-duration-description',
apiKeyCreated: 'message.api-key-created',
noApiKeys: 'message.no-api-keys',
};
@@ -2,7 +2,6 @@
import { useQueryClient } from '@tanstack/react-query';
import {
Alert,
AlertDescription,
AlertTitle,
Box,
Button,
@@ -193,8 +192,7 @@ export function TwoFactorSetupModal({ required, onClose }: TwoFactorSetupModalPr
{error && (
<Alert variant="danger">
<AlertTitle>{t(messages.error)}</AlertTitle>
<AlertDescription>{error}</AlertDescription>
<AlertTitle>{error}</AlertTitle>
</Alert>
)}