Skip to content

Commit ed0e4a2

Browse files
authored
Feat(client): 유저 정보 조회 api 연동 (team-bofit#184)
* feat: 유저 정보 조회 api 연동 * feat: types 폴더로 타입 이전
1 parent 74972f3 commit ed0e4a2

File tree

5 files changed

+38
-0
lines changed

5 files changed

+38
-0
lines changed

apps/client/src/pages/my/my-page.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1+
import { useQuery } from '@tanstack/react-query';
2+
3+
import { USER_QUERY_OPTIONS } from '@shared/api/domain/mypage/queries';
4+
15
const MyPage = () => {
6+
const { data: userData } = useQuery(USER_QUERY_OPTIONS.PROFILE());
7+
console.log(userData);
8+
29
return <div>MyPage</div>;
310
};
411

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { queryOptions } from '@tanstack/react-query';
2+
3+
import { api } from '@shared/api/config/instance';
4+
import { UserProfile } from '@shared/api/types/types';
5+
import { END_POINT } from '@shared/constants/end-point';
6+
import { USER_QUERY_KEY } from '@shared/constants/query-key';
7+
8+
export const USER_QUERY_OPTIONS = {
9+
PROFILE: () => {
10+
return queryOptions({
11+
queryKey: USER_QUERY_KEY.PROFILE(),
12+
queryFn: getUserProfile,
13+
});
14+
},
15+
};
16+
17+
export const getUserProfile = async (): Promise<UserProfile | null> => {
18+
const response = await api.get(END_POINT.GET_USER_INFO).json<UserProfile>();
19+
return response;
20+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { paths } from '@shared/types/schema';
2+
3+
export type UserProfile =
4+
paths['/users/info']['get']['responses']['200']['content']['*/*'];
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const END_POINT = {
2+
GET_USER_INFO: 'users/info',
3+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const USER_QUERY_KEY = {
2+
ALL: ['users'],
3+
PROFILE: () => [...USER_QUERY_KEY.ALL, 'profile'],
4+
} as const;

0 commit comments

Comments
 (0)