import React from 'react'; import intl from 'react-intl-universal'; import { Intent, Alert } from '@blueprintjs/core'; import { FormattedMessage as T } from 'components'; import { useMarkPrimaryBranches } from 'hooks/query'; import { AppToaster } from 'components'; import withAlertActions from 'containers/Alert/withAlertActions'; import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect'; import { compose } from 'utils'; /** * branch mark primary alert. */ function BranchMarkPrimaryAlert({ name, // #withAlertStoreConnect isOpen, payload: { branchId }, // #withAlertActions closeAlert, }) { const { mutateAsync: markPrimaryBranchMutate, isLoading } = useMarkPrimaryBranches(); // Handle cancel mark primary alert. const handleCancelMarkPrimaryAlert = () => { closeAlert(name); }; // andle cancel mark primary confirm. const handleConfirmMarkPrimaryBranch = () => { markPrimaryBranchMutate(branchId) .then(() => { AppToaster.show({ message: intl.get('branch.alert.mark_primary_message'), intent: Intent.SUCCESS, }); closeAlert(name); }) .catch((error) => { closeAlert(name); }); }; return ( } confirmButtonText={} intent={Intent.WARNING} isOpen={isOpen} onCancel={handleCancelMarkPrimaryAlert} onConfirm={handleConfirmMarkPrimaryBranch} loading={isLoading} >

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