import { zodResolver } from '@hookform/resolvers/zod' import { useState } from 'react' import { SubmitHandler, useForm } from 'react-hook-form' import { Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogSection, DialogSectionSeparator, DialogTitle, DialogTrigger, FormControl_Shadcn_, FormField_Shadcn_, Form_Shadcn_, Input_Shadcn_, } from 'ui' import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout' import * as z from 'zod' import { useParams } from 'common' import { useAPIKeyCreateMutation } from 'data/api-keys/api-key-create-mutation' import { Plus } from 'lucide-react' const FORM_ID = 'create-secret-api-key' const SCHEMA = z.object({ name: z.string(), description: z.string().trim(), }) const CreateSecretAPIKeyDialog = () => { const [visible, setVisible] = useState(false) const { ref: projectRef } = useParams() const onClose = (value: boolean) => { setVisible(value) } const form = useForm>({ resolver: zodResolver(SCHEMA), defaultValues: { name: '', description: '', }, }) const { mutate: createAPIKey, isLoading: isCreatingAPIKey } = useAPIKeyCreateMutation() const onSubmit: SubmitHandler> = async (values) => { createAPIKey( { projectRef, type: 'secret', name: values.name, description: values.description, }, { onSuccess: () => { onClose(false) }, } ) } return ( Create new secret API key

Secret API keys are used to authorize requests to your project from servers, functions, workers or other backend components of your application.{' '}

Keep these keys private. Don't publish them online or commit them to source control.

( )} /> ( )} />
) } export default CreateSecretAPIKeyDialog