Skip to content

[Feat/#210] 인사이트 API 연동 및 관련 훅/컴포넌트 리팩터링#314

Merged
00kang merged 11 commits intodevelopfrom
feat/210-insights-api
Oct 27, 2025
Merged

[Feat/#210] 인사이트 API 연동 및 관련 훅/컴포넌트 리팩터링#314
00kang merged 11 commits intodevelopfrom
feat/210-insights-api

Conversation

@00kang
Copy link
Contributor

@00kang 00kang commented Oct 23, 2025

🔗 관련 이슈 번호 (Related Issue Number)

이 Pull Request가 해결하고자 하는 이슈의 번호를 기재합니다. 이슈 연결을 통해 작업의 배경과 목적을 쉽게 파악할 수 있습니다. (예: Closes #123)


✨ PR 세부 내용 (PR Details)

이번 PR에서 어떤 작업을 했는지 상세하게 설명합니다. 코드 변경의 이유, 구현 방식, 주요 로직 등을 중심으로 작성하면 리뷰어가 이해하는 데 도움이 됩니다.

작업 개요

  • 인사이트 데이터 구조를 API 기반으로 통합
  • 관련 훅(useInsight, useHeatmapSection), 컴포넌트(InsightCard, HeatmapSection) 및 목(mock) 데이터를 리팩터링

주요 변경사항

  • src/api/insightApi.ts 에 API 도입
    • getWeeklyInsight(date)
    • getMonthlyInsight(yearMonth)
  • src/hooks/useInsight.ts 의 훅 정리
    • 기존 fetch 로직 제거 → insightApi 호출로 전환
    • opts?: { enabled?: boolean } 추가, enabled: !!param && (opts?.enabled ?? true)로 조건 실행
  • src/hooks/useHeatmapsSection.ts
    • useWeeklyInsight(getCurrentDate(), { enabled: isWeek }), useMonthlyInsight(getCurrentMonth(), { enabled: !isWeek })로 탭 상태에 따라 활성화

@00kang 00kang self-assigned this Oct 23, 2025
export const useWeeklyInsight = (date: string) => {
return useQuery<ApiWeeklyInsightResponse>({
queryKey: ['weeklyInsight', date],
queryFn: async () => getWeeklyInsight(date),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

queryFn에 getWeeklyInsight 함수가 이미 promise를 반환해주기 때문에 async를 제거해주는 것이 좋을 것 같습니다.

Copy link
Contributor

@seohyun06 seohyun06 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인했습니다

@00kang 00kang merged commit b5b7fdd into develop Oct 27, 2025
4 checks passed
@00kang 00kang deleted the feat/210-insights-api branch October 27, 2025 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] 인사이트 영역 실제 API 연동 작업을 진행한다.

3 participants