import React from 'react'; import { FormattedMessage as T, useIntl } from 'react-intl'; import { Intent, Alert } from '@blueprintjs/core'; import { AppToaster } from 'components'; import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect'; import withAlertActions from 'containers/Alert/withAlertActions'; import { compose } from 'utils'; import { useInactivateAccount } from 'hooks/query'; /** * Account inactivate alert. */ function AccountInactivateAlert({ name, // #withAlertStoreConnect isOpen, payload: { accountId }, // #withAlertActions closeAlert, }) { const { formatMessage } = useIntl(); const { mutateAsync: inactivateAccount, isLoading } = useInactivateAccount(); const handleCancelInactiveAccount = () => { closeAlert('account-inactivate'); }; const handleConfirmAccountActive = () => { inactivateAccount(accountId).then(() => { AppToaster.show({ message: formatMessage({ id: 'the_account_has_been_successfully_inactivated', }), intent: Intent.SUCCESS, }); }).catch(() => { }).finally(() => { closeAlert('account-inactivate'); }); }; return ( } confirmButtonText={} intent={Intent.WARNING} isOpen={isOpen} onCancel={handleCancelInactiveAccount} onConfirm={handleConfirmAccountActive} loading={isLoading} >

); } export default compose( withAlertStoreConnect(), withAlertActions, )(AccountInactivateAlert);