-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#109 feat: 내 친구 목록, 전체 친구 목록 및 검색 api 연결
- Loading branch information
1 parent
57086f6
commit a7c9a21
Showing
9 changed files
with
193 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { axiosInstance } from '../utils/apiConfig'; | ||
import { FollowersListData } from '../types/ConnectionType'; | ||
|
||
// * 내 친구 목록 get | ||
export const getFollowersList = async ( | ||
page: number, | ||
size: number | ||
): Promise<FollowersListData | null> => { | ||
try { | ||
const response = await axiosInstance.get(`/member/follow?page=${page}&size=${size}`, { | ||
params: { | ||
page: page, | ||
size: size, | ||
}, | ||
}); | ||
console.log('내 친구 목록', response.data); | ||
return response.data.data; | ||
} catch (error) { | ||
console.error('Error fetching data:', error); | ||
return null; | ||
} | ||
}; | ||
|
||
// * 전체 친구 목록 get + 검색 | ||
export const getSearchFriendsList = async ( | ||
keyword: string, | ||
page: number, | ||
size: number | ||
): Promise<FollowersListData | null> => { | ||
try { | ||
const response = await axiosInstance.get( | ||
`/member/follow/search/all?keyword=${keyword}&page=${page}&size=${size}` | ||
); | ||
console.log('검색 친구 목록', response.data); | ||
|
||
return { | ||
followInfoResDto: response.data.data.memberInfoForFollowResDtos, // 원하는 필드 이름으로 매핑 | ||
pageInfoResDto: response.data.data.pageInfoResDto, | ||
}; | ||
} catch (error) { | ||
console.error('Error fetching data:', error); | ||
return null; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { FollowersListData } from '../types/ConnectionType'; | ||
import { getFollowersList, getSearchFriendsList } from '../api/ConnectionApi'; | ||
|
||
export const useFollowersList = (page: number, size: number) => { | ||
return useQuery<FollowersListData | null>({ | ||
queryKey: ['followersList', page, size], | ||
queryFn: () => getFollowersList(page, size), | ||
staleTime: 1000 * 60 * 5, | ||
}); | ||
}; | ||
|
||
export const useSearchFriendsList = (keyword: string, page: number, size: number) => { | ||
return useQuery<FollowersListData | null>({ | ||
queryKey: ['followersList', keyword, page, size], | ||
queryFn: () => getSearchFriendsList(keyword, page, size), | ||
staleTime: 1000 * 60 * 5, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export type FollowInfo = { | ||
memberId?: number; | ||
nickname?: string; | ||
name?: string; | ||
profileImage?: string; | ||
isFollow?: boolean; | ||
}; | ||
|
||
export type PageInfo = { | ||
currentPage: number; | ||
totalPages: number; | ||
totalItems: number; | ||
}; | ||
|
||
export type FollowersListData = { | ||
followInfoResDto: FollowInfo[]; | ||
pageInfoResDto: PageInfo; | ||
}; |