mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-26 17:16:52 +08:00
### What problem does this PR solve? Feat: Create a folder #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
33
web/src/pages/files/use-create-folder.ts
Normal file
33
web/src/pages/files/use-create-folder.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import { useSetModalState } from '@/hooks/common-hooks';
|
||||
import { useCreateFolder } from '@/hooks/use-file-request';
|
||||
import { useCallback } from 'react';
|
||||
import { useGetFolderId } from './hooks';
|
||||
|
||||
export const useHandleCreateFolder = () => {
|
||||
const {
|
||||
visible: folderCreateModalVisible,
|
||||
hideModal: hideFolderCreateModal,
|
||||
showModal: showFolderCreateModal,
|
||||
} = useSetModalState();
|
||||
const { createFolder, loading } = useCreateFolder();
|
||||
const id = useGetFolderId();
|
||||
|
||||
const onFolderCreateOk = useCallback(
|
||||
async (name: string) => {
|
||||
const ret = await createFolder({ parentId: id, name });
|
||||
|
||||
if (ret === 0) {
|
||||
hideFolderCreateModal();
|
||||
}
|
||||
},
|
||||
[createFolder, hideFolderCreateModal, id],
|
||||
);
|
||||
|
||||
return {
|
||||
folderCreateLoading: loading,
|
||||
onFolderCreateOk,
|
||||
folderCreateModalVisible,
|
||||
hideFolderCreateModal,
|
||||
showFolderCreateModal,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user