mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
refactoring: authentication with react-query.
This commit is contained in:
31
client/src/hooks/query/invite.js
Normal file
31
client/src/hooks/query/invite.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import { useMutation, useQuery } from 'react-query';
|
||||
import useApiRequest from '../useRequest';
|
||||
|
||||
/**
|
||||
* Authentication invite accept.
|
||||
*/
|
||||
export const useAuthInviteAccept = (props) => {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
([values, token]) => apiRequest.post(`invite/accept/${token}`, values),
|
||||
props,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the invite meta by the given token.
|
||||
* @param {string} token - Token.
|
||||
*/
|
||||
export const useInviteMetaByToken = (token, props) => {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery(
|
||||
['INVITE_META', token],
|
||||
() => apiRequest.get(`invite/invited/${token}`),
|
||||
{
|
||||
select: (res) => res.data,
|
||||
...props
|
||||
}
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user