Remove frontend hack for requesting persistent browser sessions, part iii (frontend) (#3053)
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { getClient } from "@/api/AxiosClient";
|
||||
import { DebugSessionApiResponse } from "@/api/types";
|
||||
import { useCredentialGetter } from "@/hooks/useCredentialGetter";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
interface Opts {
|
||||
workflowPermanentId?: string;
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
function useDebugSessionQuery({ workflowPermanentId, enabled }: Opts) {
|
||||
const credentialGetter = useCredentialGetter();
|
||||
|
||||
return useQuery<DebugSessionApiResponse>({
|
||||
queryKey: ["debugSession", workflowPermanentId],
|
||||
queryFn: async () => {
|
||||
const client = await getClient(credentialGetter, "sans-api-v1");
|
||||
return client
|
||||
.get(`/debug-session/${workflowPermanentId}`)
|
||||
.then((response) => response.data);
|
||||
},
|
||||
enabled:
|
||||
enabled !== undefined
|
||||
? enabled && !!workflowPermanentId
|
||||
: !!workflowPermanentId,
|
||||
});
|
||||
}
|
||||
|
||||
export { useDebugSessionQuery };
|
||||
Reference in New Issue
Block a user