-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 내 호스트 페이지 API 연동 #85
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
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fd2992d
feat: 내 호스트 페이지에 호스트 전체 조회 API 연동
Yejiin21 a63fb60
rename: 단순 데이터 조회, 재사용 되는 특징에 따라 entities 폴더로 이동
Yejiin21 cd1950e
refact: 중복된 API 연동 로직 삭제 및 기존 설정으로 변경
Yejiin21 e0ab5fb
rename: host 도메인에 대한 api 연동 폴더로 묶기
Yejiin21 df210fc
feat: 호스트 채널 상세 조회 API 연동
Yejiin21 7db35e3
fix: 대시보드 페이지 이동시 id값 prop 받도록 수정
Yejiin21 0d6bb3d
refact: API 추가 데이터 값에 맞게 수정
Yejiin21 17d6c12
design: 카운트다운 글씨 크기 수정
Yejiin21 49e5d5e
fix: children 누락 에러 해결
Yejiin21 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
File renamed without changes.
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,10 @@ | ||
| import { HostDetailResponse } from '../model/hostDetail'; | ||
| import { axiosClient } from '../../../shared/types/api/http-client'; | ||
| import { HostDetailRequest } from '../model/hostDetail'; | ||
|
|
||
| const hostDetail = async (dto: HostDetailRequest) => { | ||
| const response = await axiosClient.get<HostDetailResponse>(`/host-channels/${dto.hostChannelId}`); | ||
| return response.data; | ||
| }; | ||
|
|
||
| export default hostDetail; |
File renamed without changes.
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,13 @@ | ||
| import { useQuery } from '@tanstack/react-query'; | ||
| import hostDetail from '../api/hostDetail'; | ||
|
|
||
| const useHostDetail = (hostChannelId: number) => { | ||
| const { data } = useQuery({ | ||
| queryKey: ['hostDetail', hostChannelId], | ||
| queryFn: () => hostDetail({ hostChannelId }), | ||
| }); | ||
|
|
||
| return { data }; | ||
| }; | ||
|
|
||
| export default useHostDetail; |
File renamed without changes.
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,25 @@ | ||
| interface Event { | ||
| id: number; | ||
| bannerImageUrl: string; | ||
| title: string; | ||
| hostChannelName: string; | ||
| startDate: string; | ||
| address: string; | ||
| onlineType: string; | ||
| hashtags: string[]; | ||
| remainDays: string; | ||
| } | ||
|
|
||
| export interface HostDetailRequest { | ||
| hostChannelId: number; | ||
| } | ||
|
|
||
| export interface HostDetailResponse { | ||
| result: { | ||
| id: number; | ||
| profileImageUrl: string; | ||
| hostChannelName: string; | ||
| channelDescription: string; | ||
| events: Event[]; | ||
| }; | ||
| } |
Empty file.
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
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
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.
🛠️ Refactor suggestion
API 호출에 대한 로딩 상태 및 오류 처리 필요
API 호출을 사용하는 방식으로 잘 리팩토링되었지만, 로딩 상태와 오류 처리가 누락되었습니다. 또한
selectedHostId가null일 때 기본값으로0을 사용하고 있는데, 이것이 유효한 ID인지 확인이 필요합니다.다음과 같이 개선할 것을 제안합니다:
const [selectedHostId, setSelectedHostId] = useState<number | null>(null); const { data } = useHostChannelList(); - const { data: hostDetail } = useHostDetail(selectedHostId ?? 0); + const { data: hostDetail, isLoading, error } = useHostDetail(selectedHostId ?? undefined); + // 로딩 상태 처리 + if (isLoading) { + return <div className="flex justify-center items-center h-screen">로딩 중...</div>; + } + + // 오류 처리 + if (error) { + return <div className="flex justify-center items-center h-screen">오류가 발생했습니다: {error.message}</div>; + }또한
useHostDetail훅에서undefined나null을 처리하도록 수정하는 것이 좋습니다. 유효한 ID가 선택되었을 때만 API를 호출하도록 해야 합니다.📝 Committable suggestion