import { DeleteIcon } from '@chakra-ui/icons' import { Spinner, Table, TableContainer, Tbody, Td, Th, Thead, Tooltip, Tr, } from '@chakra-ui/react' import { useEffect } from 'react' import { useSelector } from 'react-redux' import { deleteApiKey, fetchApiKeys, selectApiKeyList, selectApiKeyLoading, } from '../../store/apiKeySlice' import { selectAuthUser } from '../../store/authSlice' import { useAppDispatch } from '../../store/hooks' const ApiKeyRow = ({ apiKey }: any) => { const dispatch = useAppDispatch() const handleDelete = async () => { dispatch(deleteApiKey(apiKey._id)) } return ( {apiKey.apiKey} {apiKey.status} {/* */} ) } const ApiKeyList = () => { const dispatch = useAppDispatch() const loading = useSelector(selectApiKeyLoading) const apiKeyList = useSelector(selectApiKeyList) const authUser = useSelector(selectAuthUser) useEffect(() => { if (authUser) { dispatch(fetchApiKeys()) } }, [dispatch, authUser]) return ( {loading && ( )} {!loading && apiKeyList.length == 0 && ( )} {!loading && apiKeyList.length > 0 && apiKeyList.map((apiKey) => ( ))}
Your API Keys Status
No API Keys
) } export default ApiKeyList