mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-16 14:06:49 +01:00
20 lines
700 B
TypeScript
20 lines
700 B
TypeScript
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
import { invoke } from '@tauri-apps/api';
|
|
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
|
|
import { requestsQueryKey } from './useRequests';
|
|
|
|
export function useDeleteRequest(id: string | null) {
|
|
const workspaceId = useActiveWorkspaceId();
|
|
const queryClient = useQueryClient();
|
|
return useMutation<void, string>({
|
|
mutationFn: async () => {
|
|
if (id === null) return;
|
|
await invoke('delete_request', { requestId: id });
|
|
},
|
|
onSuccess: async () => {
|
|
if (workspaceId === null || id === null) return;
|
|
await queryClient.invalidateQueries(requestsQueryKey(workspaceId));
|
|
},
|
|
});
|
|
}
|