-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] 팔로잉 목록 api 및 msw 작업 #123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,14 @@ | ||
| import { baseAPI } from '@/api/core'; | ||
|
|
||
| export const followerServiceRemote = () => ({ | ||
| // 팔로워 목록 조회 | ||
| // 임시주소로 작성. 나중에 수정 필요. | ||
| getFollowers: async () => { | ||
| try { | ||
| const response = await baseAPI.get('http://localhost:4000/followers'); | ||
| return response.data; | ||
| } catch (error) { | ||
| throw error; | ||
| } | ||
| }, | ||
| }); |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| export * from './auth-service'; | ||
| export * from './follower-service'; | ||
| export * from './user-service'; |
This file contains hidden or 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 hidden or 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,11 @@ | ||
| import { useQuery } from '@tanstack/react-query'; | ||
|
|
||
| import { API } from '@/api'; | ||
|
|
||
| export const useGetFollowers = () => { | ||
| const query = useQuery({ | ||
| queryKey: ['followers'], | ||
| queryFn: () => API.followerService.getFollowers(), | ||
| }); | ||
| return query; | ||
| }; |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import { authHandlers } from './service/auth/auth-handlers'; | ||
| import { followerHandlers } from './service/followers/followers-handler'; | ||
| import { userHandlers } from './service/user/users-handler'; | ||
|
|
||
| export const handlers = [...userHandlers, ...authHandlers]; | ||
| export const handlers = [...userHandlers, ...authHandlers, ...followerHandlers]; |
This file contains hidden or 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,12 @@ | ||
| import { http, HttpResponse } from 'msw'; | ||
|
|
||
| import { mockFollowingItems } from './followers-mocks'; | ||
|
|
||
| const getFollowersMock = http.get('http://localhost:4000/followers', () => { | ||
| if (!mockFollowingItems) { | ||
| return HttpResponse.json({ message: '팔로잉 목록이 없습니다.' }, { status: 404 }); | ||
| } | ||
| return HttpResponse.json(mockFollowingItems); | ||
| }); | ||
|
|
||
| export const followerHandlers = [getFollowersMock]; |
This file contains hidden or 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,65 @@ | ||
| export const mockFollowingItems = [ | ||
| { | ||
| id: 1, | ||
| name: '신짱구', | ||
| profileImage: | ||
| 'https://images.unsplash.com/photo-1714635218254-740bad86a0e8?q=80&w=765&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D', | ||
| profileMessage: '안녕하세요 신짱구입니다!', | ||
| }, | ||
| { | ||
| id: 2, | ||
| name: '김맹구', | ||
| profileImage: | ||
| 'https://images.unsplash.com/photo-1534361960057-19889db9621e?q=80&w=870&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D', | ||
| profileMessage: '안녕하세요 김맹구입니다!', | ||
| }, | ||
| { | ||
| id: 3, | ||
| name: '흰둥이', | ||
| profileImage: | ||
| 'https://images.unsplash.com/photo-1533738363-b7f9aef128ce?q=80&w=735&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D', | ||
| profileMessage: '안녕하세요 흰둥이입니다!', | ||
| }, | ||
| { | ||
| id: 4, | ||
| name: '김철수', | ||
| profileImage: | ||
| 'https://images.unsplash.com/photo-1503777119540-ce54b422baff?w=400&auto=format&fit=crop&q=60&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MTV8fCVFQSVCMyVBMCVFQyU5NiU5MSVFQyU5RCVCNHxlbnwwfHwwfHx8MA%3D%3D', | ||
| profileMessage: '안녕하세요 김철수입니다!', | ||
| }, | ||
| { | ||
| id: 5, | ||
| name: '유환욱', | ||
| profileImage: | ||
| 'https://images.unsplash.com/photo-1571566882372-1598d88abd90?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MTl8fCVFQSVCMyVBMCVFQyU5NiU5MSVFQyU5RCVCNHxlbnwwfHwwfHx8MA%3D%3D', | ||
| profileMessage: '안녕하세요 유환욱입니다!', | ||
| }, | ||
| { | ||
| id: 6, | ||
| name: '호날두', | ||
| profileImage: | ||
| 'https://images.unsplash.com/photo-1589656966895-2f33e7653819?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxzZWFyY2h8M3x8JUVCJThGJTk5JUVCJUFDJUJDfGVufDB8fDB8fHww', | ||
| profileMessage: '안녕하세요 호날두입니다!', | ||
| }, | ||
| { | ||
| id: 7, | ||
| name: '메시', | ||
| profileImage: | ||
| 'https://images.unsplash.com/photo-1574068468668-a05a11f871da?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MTJ8fCVFQiU4RiU5OSVFQiVBQyVCQ3xlbnwwfHwwfHx8MA%3D%3D', | ||
| profileMessage: '안녕하세요 메시입니다!', | ||
| }, | ||
| { | ||
| id: 8, | ||
| name: '아이언맨', | ||
| profileImage: | ||
| 'https://images.unsplash.com/photo-1591824438708-ce405f36ba3d?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxzZWFyY2h8NHx8JUVCJThGJTk5JUVCJUFDJUJDfGVufDB8fDB8fHww', | ||
| profileMessage: '안녕하세요 아이언맨입니다!', | ||
| }, | ||
| { | ||
| id: 9, | ||
| name: '헐크', | ||
| profileImage: | ||
| 'https://images.unsplash.com/photo-1437622368342-7a3d73a34c8f?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MTB8fCVFQiU4RiU5OSVFQiVBQyVCQ3xlbnwwfHwwfHx8MA%3D%3D', | ||
| profileMessage: '안녕하세요 헐크입니다!', | ||
| }, | ||
| ]; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
지금도 좋지만, 나중에나 리팩토링 할 때 isLoading, isError을 활용하는 것도 좋을 거 같아요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
나중에 연동할 때 추가하겠습니다!😀