mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-17 06:26:58 +01:00
17 lines
691 B
TypeScript
17 lines
691 B
TypeScript
import { useMutation } from '@tanstack/react-query';
|
|
import { invoke } from '@tauri-apps/api';
|
|
import { trackEvent } from '../lib/analytics';
|
|
import type { HttpResponse } from '../lib/models';
|
|
import { useActiveEnvironmentId } from './useActiveEnvironmentId';
|
|
import { useAlert } from './useAlert';
|
|
|
|
export function useSendAnyRequest() {
|
|
const environmentId = useActiveEnvironmentId();
|
|
const alert = useAlert();
|
|
return useMutation<HttpResponse, string, string | null>({
|
|
mutationFn: (id) => invoke('send_request', { requestId: id, environmentId }),
|
|
onSettled: () => trackEvent('http_request', 'send'),
|
|
onError: (err) => alert({ title: 'Export Failed', body: err }),
|
|
});
|
|
}
|