import { DeleteIcon } from '@chakra-ui/icons' import { Spinner, Table, TableContainer, Tbody, Td, Th, Thead, Tooltip, Tr, useToast, } from '@chakra-ui/react' import { useEffect, useState } from 'react' import { useDispatch, useSelector } from 'react-redux' import { deleteApiKeyRequest } from '../../services' import { fetchApiKeyList, selectApiKeyList, } from '../../store/apiKeyListReducer' import { selectAuth } from '../../store/authReducer' const ApiKeyList = () => { const toast = useToast() const dispatch = useDispatch() const { data, loading } = useSelector(selectApiKeyList) const { user, accessToken } = useSelector(selectAuth) useEffect(() => { if (user && accessToken) { dispatch(fetchApiKeyList()) } }, [dispatch, user, accessToken]) const onDelete = (apiKeyId: string) => { deleteApiKeyRequest(apiKeyId) dispatch(fetchApiKeyList()) toast({ title: 'Success', description: 'API Key deleted', isClosable: true, }) } return ( {loading ? ( ) : ( <> {data.length == 0 ? ( ) : ( data.map(({ _id, apiKey, status }) => ( )) )} )}
Your API Keys Status
No API Keys
{apiKey} {status} { onDelete(_id) }} />
) } export default ApiKeyList