From ccdb3c59319d4f1d7c6ad98683eea94f7974f31f Mon Sep 17 00:00:00 2001 From: Joel Date: Mon, 9 Dec 2024 16:28:13 +0800 Subject: [PATCH] fix: deleting problem --- .../documents/detail/completed/batch-action.tsx | 15 +++++++++++++-- web/service/knowledge/use-document.ts | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/web/app/components/datasets/documents/detail/completed/batch-action.tsx b/web/app/components/datasets/documents/detail/completed/batch-action.tsx index c158af3047..df3ae6e1ec 100644 --- a/web/app/components/datasets/documents/detail/completed/batch-action.tsx +++ b/web/app/components/datasets/documents/detail/completed/batch-action.tsx @@ -12,7 +12,7 @@ type IBatchActionProps = { selectedIds: string[] onBatchEnable: () => void onBatchDisable: () => void - onBatchDelete: () => void + onBatchDelete: () => Promise onArchive?: () => void onCancel: () => void } @@ -31,6 +31,15 @@ const BatchAction: FC = ({ setTrue: showDeleteConfirm, setFalse: hideDeleteConfirm, }] = useBoolean(false) + const [isDeleting, { + setTrue: setIsDeleting, + }] = useBoolean(false) + + const handleBatchDelete = async () => { + setIsDeleting() + await onBatchDelete() + hideDeleteConfirm() + } return (
@@ -80,8 +89,10 @@ const BatchAction: FC = ({ title={t('datasetDocuments.list.delete.title')} content={t('datasetDocuments.list.delete.content')} confirmText={t('common.operation.sure')} - onConfirm={onBatchDelete} + onConfirm={handleBatchDelete} onCancel={hideDeleteConfirm} + isLoading={isDeleting} + isDisabled={isDeleting} /> ) } diff --git a/web/service/knowledge/use-document.ts b/web/service/knowledge/use-document.ts index 5efc936f41..a0454b1b0e 100644 --- a/web/service/knowledge/use-document.ts +++ b/web/service/knowledge/use-document.ts @@ -59,7 +59,7 @@ export const useDocumentUnArchive = () => { export const useDocumentDelete = () => { return useMutation({ mutationFn: ({ datasetId, documentIds, documentId }: UpdateDocumentBatchParams) => { - return del(`/datasets/${datasetId}/documents/batch?${toBatchDocumentsIdParams(documentId || documentIds!)}`) + return del(`/datasets/${datasetId}/documents?${toBatchDocumentsIdParams(documentId || documentIds!)}`) }, }) }