[Refactor/#229] Overview&Platform 중복 통합 - #245
Conversation
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 상수로 교체
📚 Storybook 배포 완료
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 Walkthrough워크스루대시보드 공통 타입( 변경 사항대시보드 타입/유틸/훅 통합 리팩터링
코드 리뷰 예상 시간🎯 3 (Moderate) | ⏱️ ~25 분 관련 이슈
관련 PR
추천 리뷰어
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (21)
src/api/dashboard/overview.tssrc/components/dashboard/charts/TrafficChart.tsxsrc/components/dashboard/platform/AllPlatformTrafficChart.tsxsrc/components/dashboard/platform/PlatformRoasTable.tsxsrc/components/dashboard/platform/PlatformTrafficChart.tsxsrc/components/dashboard/platform/SinglePlatformView.tsxsrc/components/dashboard/platform/TopPerformanceList.tsxsrc/constants/dashboard/platformLogos.tsxsrc/hooks/dashboard/useBudget.tssrc/hooks/dashboard/useOverviewMetrics.tssrc/hooks/dashboard/usePlatformBudget.tssrc/hooks/dashboard/usePlatformRoasRankings.tssrc/pages/dashboard/overview/OverviewDashboard.tsxsrc/pages/dashboard/overview/sections/OverviewBudgetSection.tsxsrc/pages/dashboard/platform/platformDashboard.mock.tssrc/types/dashboard/common.tssrc/types/dashboard/overview.tssrc/types/dashboard/platform.tssrc/types/dashboard/provider.tssrc/utils/dashboard/metricsToKpis.tssrc/utils/dashboard/parseMinuteToTimestamp.ts
💤 Files with no reviewable changes (1)
- src/hooks/dashboard/usePlatformBudget.ts
#229
🚨 관련 이슈
✨ 변경사항
✏️ 작업 내용
(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) useBudget 통합
- useOverviewBudget + usePlatformBudget → useBudget(provider?) 하나로
- provider 유무로 query key 분기해 캐시 네임스페이스 유지
- WARNING_THRESHOLD = 50, DANGER_THRESHOLD = 75 상수 중복 제거
- select 로직 중복 제거
(1) metricsToKpis 유틸
- useOverviewMetrics의 toKpis() + SinglePlatformView의 인라인 변환 → 공통 유틸
- 타이틀 문자열 통일 및 소수점 2자리로 통일
(2) parseMinuteToTimestamp 유틸
- YYYYMMDDHHmm → timestamp 변환 로직이 3개 파일에 중복
(1) PLATFORM_CIRCLE_LOGO_MAP 상수
- 각자 선언하던 circle 로고 맵 →platformLogos.tsx로 통합
(2) usePlatformRoasRankings 날짜 상수화
- 하드코딩 "2026-01-22" → OVERVIEW_DAILY_METRICS_RANGE 상수 사용
😅 미완성 작업
N/A
📢 논의 사항 및 참고 사항
N/A
Summary by CodeRabbit
Release Notes
개선 사항
스타일