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 { useActivateContact } from 'hooks/query'; import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect'; import withAlertActions from 'containers/Alert/withAlertActions'; import { compose } from 'utils'; /** * Vendor activate alert. */ function VendorActivateAlert({ name, // #withAlertStoreConnect isOpen, payload: { vendorId }, // #withAlertActions closeAlert, }) { const { mutateAsync: activateContact, isLoading } = useActivateContact(); // Handle activate vendor alert cancel. const handleCancelActivateVendor = () => { closeAlert(name); }; // Handle confirm vendor activated. const handleConfirmVendorActivate = () => { activateContact(vendorId) .then(() => { AppToaster.show({ message: intl.get('vendor.alert.activated_message'), intent: Intent.SUCCESS, }); }) .catch((error) => {}) .finally(() => { closeAlert(name); }); }; return ( } confirmButtonText={} intent={Intent.WARNING} isOpen={isOpen} onCancel={handleCancelActivateVendor} loading={isLoading} onConfirm={handleConfirmVendorActivate} >

{intl.get('vendor.alert.are_you_sure_want_to_activate_this_vendor')}

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