import React, { useEffect } from 'react'; import { defineMessages, FormattedDate, useIntl } from 'react-intl'; import { fetchOAuthTokens, revokeOAuthTokenById } from 'soapbox/actions/security'; import { Button, Card, CardBody, CardHeader, CardTitle, Column, Spinner, Stack, Text } from 'soapbox/components/ui'; import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; import { Token } from 'soapbox/reducers/security'; const messages = defineMessages({ header: { id: 'security.headers.tokens', defaultMessage: 'Sessions' }, revoke: { id: 'security.tokens.revoke', defaultMessage: 'Revoke' }, }); interface IAuthToken { token: Token, } const AuthToken: React.FC = ({ token }) => { const dispatch = useAppDispatch(); const intl = useIntl(); const handleRevoke = () => { dispatch(revokeOAuthTokenById(token.id)); }; return (
{token.app_name}
); }; const AuthTokenList: React.FC = () =>{ const dispatch = useAppDispatch(); const intl = useIntl(); const tokens = useAppSelector(state => state.security.get('tokens').reverse()); useEffect(() => { dispatch(fetchOAuthTokens()); }, []); const body = tokens ? (
{tokens.map((token) => ( ))}
) : ; return ( {body} ); }; export default AuthTokenList;