Skip to content

Commit 1d7de16

Browse files
committed
feat: Refactor OAuth link retrieval to accept dynamic provider strings
1 parent 827b755 commit 1d7de16

2 files changed

Lines changed: 11 additions & 13 deletions

File tree

src/features/auth/api/getOauthLink.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ import { useMutation } from '@tanstack/react-query'
22
import { axios } from 'src/lib/axios'
33
import { MutationConfig } from 'src/lib/react-query'
44

5-
type Provider = 'google.com' | 'github.com'
6-
75
export type GetOauthLinkDTO = {
86
data: {
9-
provider: Provider
7+
provider: string
108
state: string
119
}
1210
}

src/features/auth/components/AuthModal.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ export const AuthModal = ({ showAuth }: AuthModalProps) => {
2525

2626
const requestOauthLink = useCallback(
2727
async (provider: AuthProvider) => {
28-
const getOauthLinkResponse = await getOauthLink.mutateAsync({
29-
data: {
30-
provider: provider.providerId as 'google.com' | 'github.com',
31-
state: BUILD_TARGET === 'web' ? window.location.origin : getBrowserName(),
32-
},
33-
})
34-
35-
if (getOauthLinkResponse.authLink) {
36-
window.open(getOauthLinkResponse.authLink, BUILD_TARGET === 'web' ? '_self' : '_blank')
37-
}
28+
getOauthLink
29+
.mutateAsync({
30+
data: {
31+
provider: provider.providerId,
32+
state: BUILD_TARGET === 'web' ? window.location.origin : getBrowserName(),
33+
},
34+
})
35+
.then(({ authLink }) => {
36+
window.open(authLink, BUILD_TARGET === 'web' ? '_self' : '_blank')
37+
})
3838
},
3939
[getOauthLink]
4040
)

0 commit comments

Comments
 (0)