import { ApiKeyDetailsRow } from "./DetailsRow"; import { ApiKeyKeyForm } from "./KeyForm"; import { ApiKeyValidationSchema } from "./validations"; import { ApiKey } from "@3rdweb-sdk/react/hooks/useApi"; import { Alert, AlertDescription, AlertIcon, AlertTitle, Divider, Flex, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay, VStack, } from "@chakra-ui/react"; import { UseFormReturn } from "react-hook-form"; import { Button, CodeBlock, Heading, Text } from "tw-components"; interface ApiKeysCreateModalProps { apiKey?: ApiKey | null; open: boolean; form?: UseFormReturn; loading?: boolean; onClose: () => void; onSubmit?: () => void; } export const ApiKeysCreateModal: React.FC = ({ open, apiKey, form, loading = false, onClose, onSubmit, }) => { const { secret, key } = apiKey || {}; const renderKeys = () => { return ( <> {secret && ( <> {key && ( } description="Identifies your application. It should generally be restricted to specific domains (web) and/or bundle-ids (native)." /> )} } description="Identifies and authenticates your application from the backend." /> Secret Key Handling Store the Secret Key in a secure place and{" "} never share it. You will not be able to retrieve it again. If you lose it, you will need to regenerate a new Secret Key. )} ); }; const renderCreateForm = () => { if (form && onSubmit) { return ; } return null; }; return ( undefined : onClose} size="xl"> {secret ? "Your New Api Key" : "Create API Key"} {!secret && } {apiKey ? renderKeys() : renderCreateForm()} ); };