Skip to content

[Refactor/#229] Overview&Platform 중복 통합 - #245

Merged
Seojegyeong merged 14 commits into
developfrom
refactor/#229
Jun 18, 2026
Merged

[Refactor/#229] Overview&Platform 중복 통합#245
Seojegyeong merged 14 commits into
developfrom
refactor/#229

Conversation

@Seojegyeong

@Seojegyeong Seojegyeong commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

#229

🚨 관련 이슈

✨ 변경사항

  • 🐞 BugFix Something isn't working
  • 💻 CrossBrowsing Browser compatibility
  • 🌏 Deploy Deploy
  • 🎨 Design Markup & styling
  • 📃 Docs Documentation writing and editing (README.md, etc.)
  • ✨ Feature Feature
  • 🔨 Refactor Code refactoring
  • ⚙️ Setting Development environment setup
  • ✅ Test Test related (storybook, jest, etc.)

✏️ 작업 내용

  1. Types 정리

(1) IRoasRanking 하나로 통일
- overview.ts, platform.ts 양쪽에 동일하게 선언되어 있던 것을 provider.ts로 이동

(2) 공통 타입 common.ts
- IMetricsResponse - overview.ts에서 이동
- IRoasRanking - provider.ts에서 재이동
- IPlatformPerformance extends IMetricsResponse - 중복 필드 8개 제거

(3) IBudgetResponse 통합
- IBudgetsResponse (overview.ts) + IBudgetStatus (platform.ts)
→ IBudgetResponse 하나로 통합

  1. Hooks 정리

(1) useBudget 통합
- useOverviewBudget + usePlatformBudget → useBudget(provider?) 하나로
- provider 유무로 query key 분기해 캐시 네임스페이스 유지
- WARNING_THRESHOLD = 50, DANGER_THRESHOLD = 75 상수 중복 제거
- select 로직 중복 제거

  1. Utils 추출

(1) metricsToKpis 유틸
- useOverviewMetrics의 toKpis() + SinglePlatformView의 인라인 변환 → 공통 유틸
- 타이틀 문자열 통일 및 소수점 2자리로 통일

(2) parseMinuteToTimestamp 유틸
- YYYYMMDDHHmm → timestamp 변환 로직이 3개 파일에 중복

  1. Constants 추출

(1) PLATFORM_CIRCLE_LOGO_MAP 상수
- 각자 선언하던 circle 로고 맵 →platformLogos.tsx로 통합

(2) usePlatformRoasRankings 날짜 상수화
- 하드코딩 "2026-01-22" → OVERVIEW_DAILY_METRICS_RANGE 상수 사용

😅 미완성 작업

N/A

📢 논의 사항 및 참고 사항

N/A

💬 리뷰어 가이드 (P-Rules)
P1: 필수 반영 (Critical) - 버그 가능성, 컨벤션 위반. 해결 전 머지 불가.
P2: 적극 권장 (Recommended) - 더 나은 대안 제시. 가급적 반영 권장.
P3: 제안 (Suggestion) - 아이디어 공유. 반영 여부는 드라이버 자율.
P4: 단순 확인/칭찬 (Nit) - 사소한 오타, 칭찬 등 피드백.

Summary by CodeRabbit

Release Notes

  • 개선 사항

    • 대시보드 차트의 시간 데이터 변환 로직을 개선해 시계열 표기가 더 정확해졌습니다.
    • 플랫폼 로고 표시를 일관된 원형 로고 매핑 방식으로 개선하고, 로고 없는 경우 표시도 정돈했습니다.
    • 예산 조회가 통합되어 플랫폼별/개요 예산 흐름이 더 안정적으로 연동됩니다.
    • KPI 계산을 공통 변환 로직으로 정리해 표시 품질과 일관성을 높였습니다.
  • 스타일

    • 로딩/에러 카드의 라운딩 스타일을 조정했습니다.

overview.ts, platform.ts에 중복 선언되어 있던 IRoasRanking을
provider.ts 단일 출처로 이동하고 각 파일에서 re-export
IMetricsResponse, IRoasRanking을 common.ts 단일 출처로 이동
IPlatformPerformance는 IMetricsResponse를 extend해 중복 필드 제거
overview.ts, platform.ts는 common.ts에서 re-export
중복된 예산 타입 2개를 common.ts의 IBudgetResponse 단일 타입으로 통합
소비 파일(api, mock) import명 일괄 수정
provider 유무로 query key 분기해 캐시 네임스페이스 유지
중복된 상수(WARNING/DANGER_THRESHOLD)와 select 로직 단일화
useOverviewMetrics의 toKpis, SinglePlatformView의 인라인 변환 제거
타이틀 문자열과 소수점(2자리) 통일
PlatformRoasTable, TopPerformanceList의 중복 로고 선언 제거
각 컴포넌트는 공통 상수에서 컴포넌트 레퍼런스를 가져와 고유 className 적용
TrafficChart, PlatformTrafficChart의 YYYYMMDDHHmm → timestamp 변환 중복 제거
…ormRoasRankings 날짜 상수화

AllPlatformTrafficChart의 인라인 파싱 로직을 parseMinuteToTimestamp 유틸로 교체
usePlatformRoasRankings의 하드코딩 날짜를 OVERVIEW_DAILY_METRICS_RANGE 상수로 교체
@Seojegyeong Seojegyeong self-assigned this Jun 17, 2026
@Seojegyeong Seojegyeong added the 🔨 Refactor 코드 리팩토링 label Jun 17, 2026
@Seojegyeong Seojegyeong linked an issue Jun 17, 2026 that may be closed by this pull request
3 tasks
@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown

📚 Storybook 배포 완료

항목 링크
📖 Storybook https://69a147b60a56365d9e2185ef-qufxpqwxlf.chromatic.com/
🔍 Chromatic https://www.chromatic.com/build?appId=69a147b60a56365d9e2185ef&number=325

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 322dfd25-4c0a-469c-a06a-690008055465

📥 Commits

Reviewing files that changed from the base of the PR and between d5334cc and d9ed691.

📒 Files selected for processing (4)
  • src/components/dashboard/platform/PlatformRoasTable.tsx
  • src/components/dashboard/platform/TopPerformanceList.tsx
  • src/pages/dashboard/overview/sections/OverviewKpiSection.tsx
  • src/utils/dashboard/parseMinuteToTimestamp.ts
✅ Files skipped from review due to trivial changes (1)
  • src/pages/dashboard/overview/sections/OverviewKpiSection.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/utils/dashboard/parseMinuteToTimestamp.ts
  • src/components/dashboard/platform/TopPerformanceList.tsx
  • src/components/dashboard/platform/PlatformRoasTable.tsx

📝 Walkthrough

워크스루

대시보드 공통 타입(IMetricsResponse, IBudgetResponse, IRoasRanking)을 common.ts로 통합하고, parseMinuteToTimestampmetricsToKpis 유틸 함수를 새 파일로 추출했다. useOverviewBudgetusePlatformBudget을 옵셔널 provider 파라미터를 받는 useBudget으로 통합하고, 플랫폼 로고 렌더링을 PLATFORM_CIRCLE_LOGO_MAP 상수 기반으로 전환했다.

변경 사항

대시보드 타입/유틸/훅 통합 리팩터링

Layer / File(s) Summary
공통 타입 정의 및 재구성
src/types/dashboard/common.ts, src/types/dashboard/overview.ts, src/types/dashboard/platform.ts, src/types/dashboard/provider.ts
IMetricsResponse, IBudgetResponse, IRoasRankingcommon.ts에 신규 추가하고, overview.ts/platform.ts의 중복 로컬 선언 제거 후 re-export로 전환. IBudgetStatus 삭제, IPlatformPerformanceIMetricsResponse를 상속하도록 변경.
공통 유틸 함수 추출 및 API 타입 갱신
src/utils/dashboard/parseMinuteToTimestamp.ts, src/utils/dashboard/metricsToKpis.ts, src/api/dashboard/overview.ts
parseMinuteToTimestamp(분 문자열→타임스탬프)와 metricsToKpis(지표→KPI 카드 배열) 유틸을 신규 파일로 추출. getBudget API 반환 타입을 IBudgetResponse로 갱신.
예산 훅 통합 및 ROAS 범위 상수화
src/hooks/dashboard/useBudget.ts, src/hooks/dashboard/usePlatformBudget.ts, src/hooks/dashboard/usePlatformRoasRankings.ts
useOverviewBudgetprovider?: TProviderType를 받는 useBudget으로 교체하여 overview/platform 양쪽 재사용 가능하도록 통합. usePlatformBudget 훅 전체 삭제. ROAS 순위 조회 기간을 하드코딩에서 OVERVIEW_DAILY_METRICS_RANGE 상수로 교체.
PLATFORM_CIRCLE_LOGO_MAP 도입 및 로고 렌더링 전환
src/constants/dashboard/platformLogos.tsx, src/components/dashboard/platform/PlatformRoasTable.tsx, src/components/dashboard/platform/TopPerformanceList.tsx
PLATFORM_CIRCLE_LOGO_MAP 상수를 신규 추가하고, 개별 SVG import 및 로컬 매핑 대신 해당 상수 기반 키 조회로 로고 렌더링 방식 전환. 폴백 원형 크기 h-7 w-7h-8 w-8 조정.
metricsToKpis 훅/컴포넌트 연결 및 차트 타임스탬프 전환
src/hooks/dashboard/useOverviewMetrics.ts, src/components/dashboard/platform/SinglePlatformView.tsx, src/components/dashboard/charts/TrafficChart.tsx, src/components/dashboard/platform/AllPlatformTrafficChart.tsx, src/components/dashboard/platform/PlatformTrafficChart.tsx
useOverviewMetrics에서 로컬 KPI 변환 로직 제거 후 metricsToKpis로 교체. SinglePlatformView에서 내부 KPI useMemometricsToKpis 위임으로 단순화하고 useBudget(platform)으로 전환. 3개 차트 컴포넌트의 수동 Date 파싱을 parseMinuteToTimestamp 호출로 일괄 교체.
소비자 컴포넌트 연결 및 목 데이터 타입 갱신
src/pages/dashboard/overview/OverviewDashboard.tsx, src/pages/dashboard/overview/sections/OverviewBudgetSection.tsx, src/pages/dashboard/platform/platformDashboard.mock.ts, src/pages/dashboard/overview/sections/OverviewKpiSection.tsx
useOverviewBudgetuseBudget 호출 교체 및 props 타입 갱신. 목 데이터의 budgetStatusMock 타입을 IBudgetStatus[]IBudgetResponse[]로 변경. 에러 메시지 border-radius 스타일을 rounded-[24px]rounded-3xl로 조정.

코드 리뷰 예상 시간

🎯 3 (Moderate) | ⏱️ ~25 분

관련 이슈

관련 PR

  • WhereYouAd/WhereYouAd-Frontend#125: getBudget API 연동 및 useOverviewBudgetuseBudget 전환, IBudgetsResponseIBudgetResponse 타입 변경의 후속 작업으로 직접 연결됨.
  • WhereYouAd/WhereYouAd-Frontend#129: PlatformRoasTable.tsx에서 제공자 기준 로고/표시 처리가 동시에 수정되어, 메인 PR의 로고 매핑 적용과 코드 수준에서 맞물림.
  • WhereYouAd/WhereYouAd-Frontend#215: SinglePlatformViewusePlatformBudget 연동을 도입한 PR으로, 이번 PR에서 해당 훅을 useBudget으로 교체하는 변경과 직접 연관됨.

추천 리뷰어

  • jjjsun
  • YermIm
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 refactoring의 핵심 목표인 'Overview와 Platform 간 중복 통합'을 명확하게 요약하고 있습니다.
Description check ✅ Passed PR 설명이 template의 주요 섹션을 충실히 작성했으며, 4가지 주요 작업(Types 정리, Hooks 정리, Utils 추출, Constants 추출)과 구체적인 변경 사항을 상세히 기술하고 있습니다.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/#229

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
src/types/dashboard/common.ts (1)

15-15: ⚡ Quick win

provider 관련 필드를 string 대신 TProviderType으로 제한해 주세요.

Line [15], Line [25]가 string이면 공통 타입 경계에서 잘못된 provider 값이 통과될 수 있어요. provider.ts의 유니온 타입을 재사용하면 로고/색상/분기 매핑과 타입 계약이 일관됩니다.

제안 diff
+import type { TProviderType } from "./provider";
+
 export interface IBudgetResponse {
-  providerType: string;
+  providerType: TProviderType;
   usagePercentage: number;
   totalBudget: number;
   totalSpend: number;
   remainingBudget: number;
 }

 export interface IRoasRanking {
   rank: number;
-  provider: string;
+  provider: TProviderType;
   roas: number;
   diffRate: number | null;
   revenue: number;
   adSpend: number;
 }

As per coding guidelines src/**: 4. 타입 안정성: TypeScript 타입의 명확성 확인.

Also applies to: 25-25

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/types/dashboard/common.ts` at line 15, The providerType field in this
file is currently typed as a generic string, which allows invalid provider
values to pass through type checking. Replace the string type with TProviderType
(the union type from provider.ts) for both the providerType field at line 15 and
the related field at line 25 to ensure type safety and consistency across the
codebase. Make sure to import TProviderType from provider.ts if it is not
already imported in the file.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/dashboard/platform/PlatformRoasTable.tsx`:
- Around line 27-33: The Logo and fallback span elements in the return
statements are decorative elements that should not be announced by screen
readers since the platform name is already displayed as text. Add
aria-hidden="true" attribute to both the Logo component on line 27 and the span
element on line 30 to prevent duplicate reading and improve accessibility
compliance with semantic HTML and ARIA attribute requirements.

In `@src/components/dashboard/platform/TopPerformanceList.tsx`:
- Around line 34-35: The Logo component in TopPerformanceList.tsx is a
decorative element that duplicates information already provided by the adjacent
platform name text. To improve accessibility for screen reader users, add the
aria-hidden="true" attribute to the Logo component where it is conditionally
rendered (the Logo component with className "w-8 h-8"). This prevents screen
readers from announcing redundant visual decoration while keeping the semantic
platform name text available to assistive technologies.
- Around line 19-25: The code currently uses unsafe `as keyof` type casting for
the provider value when accessing PLATFORM_CIRCLE_LOGO_MAP and PLATFORM_MAP,
which can lead to display mismatches if the provider value doesn't match
expected keys. Add a normalization or guard function to validate and normalize
the provider value before using it as a key for both the Logo assignment and the
name assignment (which also applies to lines 34-37). Follow a similar pattern to
how PlatformRoasTable handles provider key mapping to ensure type safety and
prevent breakage when unexpected provider values are received.

In `@src/utils/dashboard/parseMinuteToTimestamp.ts`:
- Around line 2-8: The parseMinuteToTimestamp function lacks input validation,
allowing JavaScript's Date constructor to automatically normalize out-of-range
values (like month=12, day=32, hour=25), which causes invalid timestamps to be
silently generated instead of signaling errors. Add validation at the beginning
of the function to verify the minute parameter is a 12-character string in
YYYYMMDDHHmm format and ensure the parsed values fall within valid ranges (month
1-12, day 1-31, hour 0-23, minute 0-59). Return Number.NaN if any validation
fails, making the function's contract explicit about handling invalid input.

---

Nitpick comments:
In `@src/types/dashboard/common.ts`:
- Line 15: The providerType field in this file is currently typed as a generic
string, which allows invalid provider values to pass through type checking.
Replace the string type with TProviderType (the union type from provider.ts) for
both the providerType field at line 15 and the related field at line 25 to
ensure type safety and consistency across the codebase. Make sure to import
TProviderType from provider.ts if it is not already imported in the file.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0f1a5089-4271-4d4e-b9e5-8f62212b1ea3

📥 Commits

Reviewing files that changed from the base of the PR and between a321aee and d5334cc.

📒 Files selected for processing (21)
  • src/api/dashboard/overview.ts
  • src/components/dashboard/charts/TrafficChart.tsx
  • src/components/dashboard/platform/AllPlatformTrafficChart.tsx
  • src/components/dashboard/platform/PlatformRoasTable.tsx
  • src/components/dashboard/platform/PlatformTrafficChart.tsx
  • src/components/dashboard/platform/SinglePlatformView.tsx
  • src/components/dashboard/platform/TopPerformanceList.tsx
  • src/constants/dashboard/platformLogos.tsx
  • src/hooks/dashboard/useBudget.ts
  • src/hooks/dashboard/useOverviewMetrics.ts
  • src/hooks/dashboard/usePlatformBudget.ts
  • src/hooks/dashboard/usePlatformRoasRankings.ts
  • src/pages/dashboard/overview/OverviewDashboard.tsx
  • src/pages/dashboard/overview/sections/OverviewBudgetSection.tsx
  • src/pages/dashboard/platform/platformDashboard.mock.ts
  • src/types/dashboard/common.ts
  • src/types/dashboard/overview.ts
  • src/types/dashboard/platform.ts
  • src/types/dashboard/provider.ts
  • src/utils/dashboard/metricsToKpis.ts
  • src/utils/dashboard/parseMinuteToTimestamp.ts
💤 Files with no reviewable changes (1)
  • src/hooks/dashboard/usePlatformBudget.ts

Comment thread src/components/dashboard/platform/PlatformRoasTable.tsx Outdated
Comment thread src/components/dashboard/platform/TopPerformanceList.tsx Outdated
Comment thread src/components/dashboard/platform/TopPerformanceList.tsx
Comment thread src/utils/dashboard/parseMinuteToTimestamp.ts Outdated
@Seojegyeong
Seojegyeong requested review from YermIm and jjjsun June 17, 2026 07:54

@jjjsun jjjsun left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

P4: 확인했습니다! 고생하셨어요!

@Seojegyeong
Seojegyeong merged commit a7e59f1 into develop Jun 18, 2026
3 checks passed
@Seojegyeong
Seojegyeong deleted the refactor/#229 branch June 18, 2026 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 Refactor 코드 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

♻️ [Refactor] Overview & platform 공통 type 및 componenets 정리

2 participants