feat: refactor verify connection mutation with the REST API endpoint
This commit is contained in:

committed by
Ali BARIN

parent
dc0273148c
commit
4d5fc50f1a
28
packages/web/src/hooks/useVerifyConnection.js
Normal file
28
packages/web/src/hooks/useVerifyConnection.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import api from 'helpers/api';
|
||||
|
||||
export default function useVerifyConnection() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const query = useMutation({
|
||||
mutationFn: async (connectionId) => {
|
||||
try {
|
||||
const { data } = await api.post(
|
||||
`/v1/connections/${connectionId}/verify`,
|
||||
);
|
||||
|
||||
return data;
|
||||
} catch {
|
||||
throw new Error('Failed while verifying connection!');
|
||||
}
|
||||
},
|
||||
onSuccess: (data) => {
|
||||
const appKey = data?.data.key;
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['apps', appKey, 'connections'],
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
return query;
|
||||
}
|
Reference in New Issue
Block a user