-
Notifications
You must be signed in to change notification settings - Fork 2
✨ feat: 사이드바 대시보드 목록 API 연동 #60
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
6 commits
Select commit
Hold shift + click to select a range
7f234c8
✨ feat: 사이드바 대시보드 목록 API 연동
LeeCh0129 db3ea0d
🫧 modify: 대시보드 생성모달 URL 수정
LeeCh0129 74527cf
🗑️ remove: 불필요한 파일 제거
LeeCh0129 77df61c
♻️ refactor: 코드래빗 리뷰 반영 - useCallback 적용
LeeCh0129 f65a301
♻️ refactor: 코드래빗 리뷰 반영 - 환경변수 검증 추가 및 오타 수정
LeeCh0129 4a1b2cb
Merge branch 'develop' into feature/Sidebar_dashboardList
LeeCh0129 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| 'use client' | ||
|
|
||
| import { useCallback, useEffect, useState } from 'react' | ||
|
|
||
| import api from '../lib/axios' | ||
| import { DashboardListResponse } from '../types/dashboard' | ||
|
|
||
| export function useDashboard() { | ||
| const [dashboards, setDashboards] = useState< | ||
| DashboardListResponse['dashboards'] | ||
| >([]) | ||
| const [isLoading, setIsLoading] = useState(true) | ||
| const [error, setError] = useState<string | null>(null) | ||
|
|
||
| const fetchDashboards = useCallback(async () => { | ||
| try { | ||
| setIsLoading(true) | ||
| setError(null) | ||
|
|
||
| if (!process.env.NEXT_PUBLIC_TEAM_ID) { | ||
| throw new Error('NEXT_PUBLIC_TEAM_ID 환경변수가 설정되지 않았습니다.') | ||
| } | ||
|
|
||
| const response = await api.get<DashboardListResponse>( | ||
| `/${process.env.NEXT_PUBLIC_TEAM_ID}/dashboards?navigationMethod=infiniteScroll`, | ||
| ) | ||
| setDashboards(response.data.dashboards) | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } catch (err) { | ||
| console.error('대시보드 목록 조회 실패:', err) | ||
| setError('대시보드 목록을 불러오는데 실패했습니다.') | ||
| } finally { | ||
| setIsLoading(false) | ||
| } | ||
| }, []) | ||
|
|
||
| useEffect(() => { | ||
| fetchDashboards() | ||
| }, [fetchDashboards]) | ||
|
|
||
| return { dashboards, isLoading, error, refetch: fetchDashboards } | ||
| } | ||
|
Comment on lines
+15
to
+41
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기서 환경변수 설정 여부를 파악하고 대시보드 목록을 조회해오는 구조군용!! |
||
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.
팀 ID 환경 변수 누락 시 잘못된 엔드포인트 호출 가능성
NEXT_PUBLIC_TEAM_ID가 정의되지 않은 경우"/undefined/dashboards"로 POST 요청이 전송됩니다.API 호출 전 유효성을 점검하여 사용자에게 경고하거나 모달을 닫는 등의 처리가 필요합니다.
📝 Committable suggestion
🤖 Prompt for AI Agents