import React from 'react';
import intl from 'react-intl-universal';
import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
import { Intent, Alert } from '@blueprintjs/core';
import { useDeleteItemCategory } from 'hooks/query';
import { AppToaster } from 'components';
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
import withAlertActions from 'containers/Alert/withAlertActions';
import { compose } from 'utils';
/**
* Item Category delete alerts.
*/
function ItemCategoryDeleteAlert({
name,
// #withAlertStoreConnect
isOpen,
payload: { itemCategoryId },
// #withAlertActions
closeAlert,
}) {
const {
mutateAsync: deleteItemCategory,
isLoading,
} = useDeleteItemCategory();
// handle cancel delete item category alert.
const handleCancelItemCategoryDelete = () => {
closeAlert(name);
};
// Handle alert confirm delete item category.
const handleConfirmItemDelete = () => {
deleteItemCategory(itemCategoryId)
.then(() => {
AppToaster.show({
message: intl.get('the_item_category_has_been_deleted_successfully'),
intent: Intent.SUCCESS,
});
})
.catch(() => {})
.finally(() => {
closeAlert(name);
});
};
return (