-
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
Changes from 3 commits
7f234c8
db3ea0d
74527cf
77df61c
f65a301
4a1b2cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -42,7 +42,7 @@ export default function CreateDashboardModal() { | |||||||||||||||||||
| try { | ||||||||||||||||||||
| setIsSubmitting(true) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const response = await api.post(`/dashboards`, formData) | ||||||||||||||||||||
| const response = await api.post(`/${process.env.NEXT_PUBLIC_TEAM_ID}/dashboards`, formData) | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
Comment on lines
+49
to
50
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. 팀 ID 환경 변수 누락 시 잘못된 엔드포인트 호출 가능성
- const response = await api.post(`/${process.env.NEXT_PUBLIC_TEAM_ID}/dashboards`, formData)
+ if (!process.env.NEXT_PUBLIC_TEAM_ID) {
+ alert('팀 정보가 설정되지 않았습니다.')
+ return
+ }
+ const response = await api.post(
+ `/${process.env.NEXT_PUBLIC_TEAM_ID}/dashboards`,
+ formData,
+ )📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
| const data = response.data | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| 'use client' | ||
|
|
||
| import { 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 = async () => { | ||
| try { | ||
| setIsLoading(true) | ||
| setError(null) | ||
|
|
||
| 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() | ||
| }, []) | ||
|
|
||
| return { dashboards, isLoading, error, refetch: fetchDashboards } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.