import { Box, Button, chakra, Flex, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay, useColorModeValue, useToast, } from '@chakra-ui/react' import { useState } from 'react' import QRCode from 'react-qr-code' import { generateApiKeyRequest } from '../../services' const NewApiKeyGeneratedModal = ({ isOpen = false, generatedApiKey, onClose, showQR = false, ...props }) => { const toast = useToast() return ( Api Key Generated {showQR && ( <> Open the SMS Gateway App and scan this QR to get started {' '} )} {generatedApiKey} {'Save this key, it wont be shown again ;)'} {' '} ) } export default function GenerateApiKey() { const [generatedApiKey, setGeneratedApiKey] = useState(null) const [generatingApiKey, setGeneratingApiKey] = useState(null) const [showGeneratedApiKeyModal, setShowGeneratedApiKeyModal] = useState(false) const generateApiKey = async () => { setGeneratingApiKey(true) const newApiKey = await generateApiKeyRequest() setGeneratedApiKey(newApiKey) setShowGeneratedApiKeyModal(true) setGeneratingApiKey(false) } return ( <> {' '} Generate Api Key and Register Device {' '} {generatedApiKey && ( <> { { setShowGeneratedApiKeyModal(false) }} /> } )} ) }