Files
spacedrive/interface/hooks/useKeyDeleteFile.tsx
ameer2468 40beeb2a20 [ENG-623] - List view obstruction fix (#839)
* Obstruction fix

* add location_id as type

* PR tweaks

* Update core.ts
2023-05-22 04:25:53 +00:00

19 lines
552 B
TypeScript

import { useKey } from 'rooks';
import { ExplorerItem } from '@sd/client';
import { dialogManager } from '@sd/ui';
import DeleteDialog from '../app/$libraryId/Explorer/File/DeleteDialog';
const useKeyDeleteFile = (selectedItem: ExplorerItem | null, location_id: number | null) => {
return useKey('Delete', (e) => {
e.preventDefault();
if (!selectedItem || !location_id) return;
dialogManager.create((dp) => (
<DeleteDialog {...dp} location_id={location_id} path_id={selectedItem.item.id} />
));
});
};
export default useKeyDeleteFile;