import { Button, chakra, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay, Spinner, Text, useToast, } from '@chakra-ui/react'; import { ArrowPathIcon } from '@heroicons/react/24/outline'; import { useUsers } from 'stores'; import { FC, useState } from 'react'; import { Trans, useTranslation } from 'react-i18next'; import { Icon } from 'components/icon'; const ResetIcon = chakra(ArrowPathIcon, { baseStyle: { w: 5, h: 5, }, }); export type RevokeSubscriptionModalProps = {}; export const RevokeSubscriptionModal: FC = () => { const [loading, setLoading] = useState(false); const { revokeSubscriptionUser: user, revokeSubscription } = useUsers(); const { t } = useTranslation(); const toast = useToast(); const onClose = () => { useUsers.setState({ revokeSubscriptionUser: null }); }; const onReset = () => { if (user) { setLoading(true); revokeSubscription(user) .then(() => { toast({ title: t('revokeUserSub.success', { username: user.username }), status: 'success', isClosable: true, position: 'top', duration: 3000, }); }) .catch(() => { toast({ title: t('revokeUserSub.error'), status: 'error', isClosable: true, position: 'top', duration: 3000, }); }) .finally(() => { setLoading(false); }); } }; return ( {t('revokeUserSub.title')} {user && ( }}> {t('revokeUserSub.prompt', { username: user.username })} )} ); };