-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathauth.ts
More file actions
35 lines (30 loc) · 785 Bytes
/
auth.ts
File metadata and controls
35 lines (30 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { useQuery } from '@tanstack/react-query';
import { get, REQUEST } from '@/shared/api';
interface KakaoLoginRequest {
code: string;
}
interface KakaoLoginResponse {
kakaoEmail: string;
tokenDto: {
grantType: string;
accessToken: string;
accessTokenExpiresIn: number;
refreshToken: string;
};
signedUp: boolean;
}
const submitKakaoLogin = async (code: string) => {
const response = await get<KakaoLoginResponse, KakaoLoginRequest>({
request: REQUEST.LOGIN,
params: { code: code },
});
return response.data;
};
export const useKakaoLogin = (code: string | null) => {
return useQuery<KakaoLoginResponse>({
retry: false,
enabled: !!code,
queryKey: ['kakaoLogin', code],
queryFn: () => submitKakaoLogin(code!),
});
};