### What problem does this PR solve? Feat: Create a folder #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
28 lines
790 B
TypeScript
28 lines
790 B
TypeScript
import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
|
|
import { useFetchParentFolderList } from '@/hooks/use-file-request';
|
|
import { Routes } from '@/routes';
|
|
import { useCallback } from 'react';
|
|
|
|
export const useNavigateToOtherFolder = () => {
|
|
const { navigateToFiles } = useNavigatePage();
|
|
|
|
const navigateToOtherFolder = useCallback(
|
|
(folderId: string) => {
|
|
navigateToFiles(folderId);
|
|
},
|
|
[navigateToFiles],
|
|
);
|
|
|
|
return navigateToOtherFolder;
|
|
};
|
|
|
|
export const useSelectBreadcrumbItems = () => {
|
|
const parentFolderList = useFetchParentFolderList();
|
|
|
|
return parentFolderList.length === 1
|
|
? []
|
|
: parentFolderList.map((x) => ({
|
|
title: x.name === '/' ? 'root' : x.name,
|
|
path: `${Routes.Files}?folderId=${x.id}`,
|
|
}));
|
|
};
|