Skip to content

Commit 074b1f9

Browse files
committed
feat: Implement getOauthLink API and custom hook for OAuth authentication
1 parent d60f3c4 commit 074b1f9

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { useMutation } from '@tanstack/react-query'
2+
import { axios } from 'src/lib/axios'
3+
import { MutationConfig } from 'src/lib/react-query'
4+
5+
type Provider = 'google.com' | 'github.com'
6+
7+
export type GetOauthLinkDTO = {
8+
data: {
9+
provider: Provider
10+
state: string
11+
}
12+
}
13+
const getOauthLink = ({ data }: GetOauthLinkDTO): Promise<{ authLink: string }> => {
14+
return axios.post('/engine/auth/auth_link', data)
15+
}
16+
17+
type QueryFnType = typeof getOauthLink
18+
19+
type UseGetArticlesOptions = {
20+
config?: MutationConfig<QueryFnType>
21+
}
22+
23+
export const useGetOauthLink = ({ config }: UseGetArticlesOptions = {}) => {
24+
return useMutation({
25+
...config,
26+
mutationFn: getOauthLink,
27+
})
28+
}

0 commit comments

Comments
 (0)