// @ts-nocheck
import React from 'react';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core';
import {
AppToaster,
FormattedMessage as T,
FormattedHTMLMessage,
} from '@/components';
import { useDeleteWarehouseTransfer } from '@/hooks/query';
import withAlertStoreConnect from '@/containers/Alert/withAlertStoreConnect';
import withAlertActions from '@/containers/Alert/withAlertActions';
import withDrawerActions from '@/containers/Drawer/withDrawerActions';
import { compose } from '@/utils';
import { DRAWERS } from '@/constants/drawers';
/**
* Warehouse transfer delete alert
* @returns
*/
function WarehouseTransferDeleteAlert({
name,
// #withAlertStoreConnect
isOpen,
payload: { warehouseTransferId },
// #withAlertActions
closeAlert,
// #withDrawerActions
closeDrawer,
}) {
const { mutateAsync: deleteWarehouseTransferMutate, isLoading } =
useDeleteWarehouseTransfer();
// handle cancel delete warehouse alert.
const handleCancelDeleteAlert = () => {
closeAlert(name);
};
// handleConfirm delete warehouse transfer.
const handleConfirmWarehouseTransferDelete = () => {
deleteWarehouseTransferMutate(warehouseTransferId)
.then(() => {
AppToaster.show({
message: intl.get('warehouse_transfer.alert.delete_message'),
intent: Intent.SUCCESS,
});
closeDrawer(DRAWERS.WAREHOUSE_TRANSFER_DETAILS);
})
.catch(
({
response: {
data: { errors },
},
}) => {},
)
.finally(() => {
closeAlert(name);
});
};
return (