diff --git a/packages/web/pages/settings/api-keys.tsx b/packages/web/pages/settings/api-keys.tsx index f09ec61bf..e5aeccf63 100644 --- a/packages/web/pages/settings/api-keys.tsx +++ b/packages/web/pages/settings/api-keys.tsx @@ -8,6 +8,7 @@ import { FormInputProps } from '../../components/elements/FormElements' import { generateApiKeyMutation } from '../../lib/networking/mutations/generateApiKeyMutation' import { showErrorToast, showSuccessToast } from '../../lib/toastHelpers' import { FormModal } from '../../components/patterns/FormModal' +import { ConfirmationModal } from '../../components/patterns/ConfirmationModal' interface ApiKey { name: string @@ -24,6 +25,7 @@ export default function ApiKeys(): JSX.Element { // const [scopes, setScopes] = useState(undefined) const [expiresAt, setExpiresAt] = useState(new Date()) const [formInputs, setFormInputs] = useState([]) + const [apiKeyGenerated, setApiKeyGenerated] = useState('') const headers = ['Name', 'Scopes', 'Used on', 'Expires on'] const rows = useMemo(() => { @@ -54,6 +56,7 @@ export default function ApiKeys(): JSX.Element { async function onCreate(): Promise { const result = await generateApiKeyMutation({ name, expiresAt }) if (result) { + setApiKeyGenerated(result) showSuccessToast('Api key generated', { position: 'bottom-right' }) } else { showErrorToast('Failed to add', { position: 'bottom-right' }) @@ -79,6 +82,20 @@ export default function ApiKeys(): JSX.Element { /> )} + {apiKeyGenerated && ( + { + await navigator.clipboard.writeText(apiKeyGenerated) + setApiKeyGenerated('') + }} + onOpenChange={() => setApiKeyGenerated('')} + /> + )} + {/*{onDeleteId && (*/} {/*