Files
yaak/src-web/hooks/useDeleteFolder.tsx
2025-03-26 09:54:42 -07:00

27 lines
903 B
TypeScript

import type { Folder } from '@yaakapp-internal/models';
import { InlineCode } from '../components/core/InlineCode';
import { showConfirmDelete } from '../lib/confirm';
import { invokeCmd } from '../lib/tauri';
import { useFastMutation } from './useFastMutation';
import { getFolder } from './useFolders';
export function useDeleteFolder(id: string | null) {
return useFastMutation<Folder | null, string>({
mutationKey: ['delete_folder', id],
mutationFn: async () => {
const folder = getFolder(id);
const confirmed = await showConfirmDelete({
id: 'delete-folder',
title: 'Delete Folder',
description: (
<>
Permanently delete <InlineCode>{folder?.name}</InlineCode> and everything in it?
</>
),
});
if (!confirmed) return null;
return invokeCmd('cmd_delete_folder', { folderId: id });
},
});
}