mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
71 lines
1.6 KiB
JavaScript
71 lines
1.6 KiB
JavaScript
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 (
|
|
<Alert
|
|
cancelButtonText={<T id={'cancel'} />}
|
|
confirmButtonText={<T id={'inactivate'} />}
|
|
intent={Intent.WARNING}
|
|
isOpen={isOpen}
|
|
onCancel={handleCancelInactiveAccount}
|
|
onConfirm={handleConfirmAccountActive}
|
|
loading={isLoading}
|
|
>
|
|
<p>
|
|
<T id={'are_sure_to_inactive_this_account'} />
|
|
</p>
|
|
</Alert>
|
|
);
|
|
}
|
|
|
|
export default compose(
|
|
withAlertStoreConnect(),
|
|
withAlertActions,
|
|
)(AccountInactivateAlert);
|