mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-16 05:56:47 +01:00
21 lines
755 B
TypeScript
21 lines
755 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 () => {
|
|
console.log('DELETE REQUEST2', id, workspaceId);
|
|
if (id === null) return;
|
|
await invoke('delete_request', { requestId: id });
|
|
},
|
|
onSuccess: async () => {
|
|
if (workspaceId === null || id === null) return;
|
|
await queryClient.invalidateQueries(requestsQueryKey(workspaceId));
|
|
},
|
|
});
|
|
}
|