This commit is contained in:
Ahmed Bouhuolia
2025-11-20 17:41:16 +02:00
parent d90b6ffbe7
commit 56e00d254b
71 changed files with 1167 additions and 185 deletions

View File

@@ -1,68 +0,0 @@
// @ts-nocheck
import React from 'react';
import { AppToaster, FormattedMessage as T } from '@/components';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core';
import { size } from 'lodash';
import { useBulkDeleteItems } from '@/hooks/query/items';
import withAlertStoreConnect from '@/containers/Alert/withAlertStoreConnect';
import withAlertActions from '@/containers/Alert/withAlertActions';
import { compose } from '@/utils';
/**
* Item bulk delete alert.
*/
function ItemBulkDeleteAlert({
name,
// #withAlertStoreConnect
isOpen,
payload: { itemsIds },
// #withAlertActions
closeAlert,
}) {
const { mutateAsync: bulkDeleteItems, isLoading } = useBulkDeleteItems();
// handle cancel item bulk delete alert.
const handleCancelBulkDelete = () => {
closeAlert(name);
};
// Handle confirm items bulk delete.
const handleConfirmBulkDelete = () => {
bulkDeleteItems(itemsIds)
.then(() => {
AppToaster.show({
message: intl.get('the_items_has_been_deleted_successfully'),
intent: Intent.SUCCESS,
});
closeAlert(name);
})
.catch((errors) => { });
};
return (
<Alert
cancelButtonText={<T id={'cancel'} />}
confirmButtonText={
<T id={'delete_count'} values={{ count: size(itemsIds) }} />
}
icon="trash"
intent={Intent.DANGER}
isOpen={isOpen}
onCancel={handleCancelBulkDelete}
onConfirm={handleConfirmBulkDelete}
loading={isLoading}
>
<p>
<T id={'once_delete_these_items_you_will_not_able_restore_them'} />
</p>
</Alert>
);
}
export default compose(
withAlertStoreConnect(),
withAlertActions,
)(ItemBulkDeleteAlert);