Files
ragflow/web/src/pages/files/use-bulk-operate-file.tsx
balibabu 5bb1c383ac Feat: Bind data to the agent module of the home page #3221 (#7385)
### What problem does this PR solve?

Feat: Bind data to the agent module of the home page #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
2025-04-29 09:50:54 +08:00

49 lines
1.3 KiB
TypeScript

import { useSelectedIds } from '@/hooks/logic-hooks/use-row-selection';
import { IFile } from '@/interfaces/database/file-manager';
import { OnChangeFn, RowSelectionState } from '@tanstack/react-table';
import { FolderInput, Trash2 } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { useHandleDeleteFile } from './use-delete-file';
import { UseMoveDocumentShowType } from './use-move-file';
export function useBulkOperateFile({
files,
rowSelection,
showMoveFileModal,
setRowSelection,
}: {
files: IFile[];
rowSelection: RowSelectionState;
setRowSelection: OnChangeFn<RowSelectionState>;
} & UseMoveDocumentShowType) {
const { t } = useTranslation();
const { selectedIds } = useSelectedIds(rowSelection, files);
const { handleRemoveFile } = useHandleDeleteFile();
const list = [
{
id: 'move',
label: t('common.move'),
icon: <FolderInput />,
onClick: () => {
showMoveFileModal(selectedIds, true);
},
},
{
id: 'delete',
label: t('common.delete'),
icon: <Trash2 />,
onClick: async () => {
const code = await handleRemoveFile(selectedIds);
if (code === 0) {
setRowSelection({});
}
},
},
];
return { list };
}