import React from 'react'; import { FormattedMessage as T } from 'components'; import intl from 'react-intl-universal'; 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 { mutateAsync: inactivateAccount, isLoading } = useInactivateAccount(); const handleCancelInactiveAccount = () => { closeAlert('account-inactivate'); }; const handleConfirmAccountActive = () => { inactivateAccount(accountId).then(() => { AppToaster.show({ message: intl.get('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);