[Refactor/#453] 예산 API 스펙 매핑 및 캠페인 목록 예산 열 제거 - #464
Conversation
📝 WalkthroughWalkthrough광고 플랫폼 예산을 단일 객체에서 Changes예산 모델 전환
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 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 |
📚 Storybook 배포 완료
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (4)
src/types/dashboard/common.ts (1)
1-1: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueimport 경로를
@/alias로 맞춰 주세요.코딩 가이드라인은 모든 import에
@/alias를 사용하도록 규정합니다. 상대 경로./provider를 alias 경로로 변경해 주세요.♻️ 제안 변경
-import type { TProviderType } from "./provider"; +import type { TProviderType } from "`@/types/dashboard/provider`";코딩 가이드라인의 "Use
@/alias for all imports" 규칙을 기준으로 작성했습니다.🤖 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 1, Update the TProviderType import in common.ts to use the project’s `@/` alias instead of the relative ./provider path, preserving the existing type-only import.Source: Coding guidelines
src/utils/dashboard/budget.ts (1)
63-72: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winNAVER에
TOTAL그룹이 없으면 게이지가 모두 사라집니다.
filterBudgetGroups는 provider가"NAVER"일 때TOTAL그룹만 남깁니다. 응답에DAILY그룹만 있으면 결과가 빈 배열이 되고,slices도 비어서 예산 게이지가 하나도 렌더링되지 않습니다.같은 cohort의
src/utils/ads/projectBudget.ts의filterPlatformBudgetSummariesForDisplay는TOTAL이 없을 때DAILY를 표시합니다. 두 화면의 NAVER 표시 규칙을 같게 맞추면 빈 화면을 방지할 수 있습니다.♻️ 제안 변경
function filterBudgetGroups( groups: IBudgetGroup[], provider?: TProviderType, ): IBudgetGroup[] { if (provider === "NAVER") { - return groups.filter((group) => group.budgetType === "TOTAL"); + const totals = groups.filter((group) => group.budgetType === "TOTAL"); + // TOTAL이 없으면 DAILY로 대체 (ads 상세와 동일 규칙) + return totals.length > 0 ? totals : groups; } return groups; }🤖 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/utils/dashboard/budget.ts` around lines 63 - 72, Update filterBudgetGroups so NAVER retains the TOTAL group when present, but falls back to retaining DAILY groups when no TOTAL group exists, matching filterPlatformBudgetSummariesForDisplay. Preserve the current behavior for non-NAVER providers.src/utils/ads/projectBudget.ts (2)
95-158: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winmock placeholder가 프로덕션 화면에 노출될 수 있습니다.
resolvePlatformBudgets는platformBudgets필드가undefined일 때buildPlaceholderPlatformBudgets를 사용합니다. 서버 응답에서 해당 필드가 누락되면 사용자에게"... 매체 캠페인 (mock)"문자열과 가짜 금액이 그대로 표시됩니다.주석은 dev 용도라고 설명하지만 코드에는 환경 가드가 없습니다.
import.meta.env.DEV기준으로 가드하고, 프로덕션에서는 빈 배열을 반환해예산 정보가 없습니다.안내가 표시되게 해주세요.♻️ 제안 변경
export function resolvePlatformBudgets(input: { providers: TPlatform[]; platformBudgets?: IPlatformBudgetSummary[]; }): IPlatformBudgetSummary[] { if (input.platformBudgets !== undefined) return input.platformBudgets; if (input.providers.length === 0) return []; + if (!import.meta.env.DEV) return []; return buildPlaceholderPlatformBudgets(input.providers); }코딩 가이드라인의 "Environment variables: use only
import.meta.env.VITE_*pattern" 규칙에 따라 환경 판별은 Vite 환경 객체를 사용했습니다.🤖 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/utils/ads/projectBudget.ts` around lines 95 - 158, Update resolvePlatformBudgets to guard the undefined platformBudgets fallback with import.meta.env.DEV: keep returning buildPlaceholderPlatformBudgets(input.providers) only in development, and return an empty array in production. Preserve the existing behavior for explicitly provided platformBudgets, including an empty array.Source: Coding guidelines
14-20: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win라벨 상수를 한 곳에서 공유해 주세요.
BUDGET_TYPE_LABEL이src/utils/dashboard/budget.tsLine 19-22에도 동일한 내용으로 존재합니다. 두 파일이 같은 라벨 문자열을 각각 관리하면 한쪽만 수정될 때 표시가 어긋납니다.또한 여기서는 라벨 타입을 인라인 리터럴 유니온으로 다시 선언했습니다.
src/types/dashboard/budget.ts의TBudgetGaugeLabel을 사용하면 라벨 집합 변경이 타입으로 전파됩니다.♻️ 제안 변경
-import type { IBudgetGaugeProps } from "`@/types/dashboard/budget`"; +import type { + IBudgetGaugeProps, + TBudgetGaugeLabel, +} from "`@/types/dashboard/budget`"; import { + BUDGET_TYPE_LABEL, buildBudgetGaugesFromSlices, supportsDailyBudget, } from "`@/utils/dashboard/budget`"; - -const BUDGET_TYPE_LABEL: Record< - TPlatformBudgetType, - "전체 예산" | "일일 예산" -> = { - TOTAL: "전체 예산", - DAILY: "일일 예산", -};
src/utils/dashboard/budget.ts에서 상수를 export 하고 키 타입을 공유해 주세요.export const BUDGET_TYPE_LABEL: Record< TDashboardBudgetType, TBudgetGaugeLabel > = { TOTAL: "전체 예산", DAILY: "일일 예산", };
TPlatformBudgetType과TDashboardBudgetType은 값 집합이 같습니다. 두 타입을 하나로 통합할지 함께 검토해 주세요.🤖 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/utils/ads/projectBudget.ts` around lines 14 - 20, 공유 라벨 정의를 `src/utils/dashboard/budget.ts`의 `BUDGET_TYPE_LABEL`로 통합하고 이를 export하여 `projectBudget.ts`에서 재사용하세요. 해당 상수의 키 타입은 `TDashboardBudgetType`, 값 타입은 `TBudgetGaugeLabel`을 사용해 인라인 리터럴 유니온을 제거하고, 동일한 값 집합인 `TPlatformBudgetType`과 `TDashboardBudgetType`은 가능한 경우 하나의 공통 타입으로 통합하세요.
🤖 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/ads/CampaignPlatformSection.tsx`:
- Around line 52-68: Update the budgetEditAction button to expose the disabled
reason from editCheck’s reason result when isBudgetEditDisabled is true. Add the
appropriate title and aria-label attributes to the “예산 수정” button, preserving
its existing disabled behavior and editTarget/onEditBudget handling.
In `@src/components/ads/CampaignTable.tsx`:
- Line 6: Update the CampaignRow import in CampaignTable.tsx to use the `@/`
alias, changing the relative path to `@/components/ads/CampaignRow` while
preserving the imported symbols.
In `@src/utils/ads/projectBudget.ts`:
- Around line 73-93: Update pickEditablePlatformBudget in
src/utils/ads/projectBudget.ts:73-93 to return the selected budget together with
a stable index or identifier that can be matched against the displayed
summaries. Update headerAction in
src/components/ads/CampaignPlatformSection.tsx:105-113 to render on the gauge
matching that selected row instead of only when index === 0; preserve the
existing budgetType selection priority.
---
Nitpick comments:
In `@src/types/dashboard/common.ts`:
- Line 1: Update the TProviderType import in common.ts to use the project’s `@/`
alias instead of the relative ./provider path, preserving the existing type-only
import.
In `@src/utils/ads/projectBudget.ts`:
- Around line 95-158: Update resolvePlatformBudgets to guard the undefined
platformBudgets fallback with import.meta.env.DEV: keep returning
buildPlaceholderPlatformBudgets(input.providers) only in development, and return
an empty array in production. Preserve the existing behavior for explicitly
provided platformBudgets, including an empty array.
- Around line 14-20: 공유 라벨 정의를 `src/utils/dashboard/budget.ts`의
`BUDGET_TYPE_LABEL`로 통합하고 이를 export하여 `projectBudget.ts`에서 재사용하세요. 해당 상수의 키 타입은
`TDashboardBudgetType`, 값 타입은 `TBudgetGaugeLabel`을 사용해 인라인 리터럴 유니온을 제거하고, 동일한 값
집합인 `TPlatformBudgetType`과 `TDashboardBudgetType`은 가능한 경우 하나의 공통 타입으로 통합하세요.
In `@src/utils/dashboard/budget.ts`:
- Around line 63-72: Update filterBudgetGroups so NAVER retains the TOTAL group
when present, but falls back to retaining DAILY groups when no TOTAL group
exists, matching filterPlatformBudgetSummariesForDisplay. Preserve the current
behavior for non-NAVER providers.
🪄 Autofix
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 Plus
Run ID: 5bbb19e4-3d72-4438-9176-3cea1fe2d234
📒 Files selected for processing (14)
src/components/ads/CampaignPlatformSection.tsxsrc/components/ads/CampaignRow.tsxsrc/components/ads/CampaignTable.tsxsrc/components/ads/EditPlatformBudgetModal.tsxsrc/components/ads/skeleton/AdsSkeleton.tsxsrc/hooks/ads/useUpdatePlatformBudget.tssrc/pages/ads/list/CampaignDetail.tsxsrc/types/ads/budget.tssrc/types/ads/campaign.tssrc/types/dashboard/budget.tssrc/types/dashboard/common.tssrc/utils/ads/budgetEdit.tssrc/utils/ads/projectBudget.tssrc/utils/dashboard/budget.ts
🚨 관련 이슈
close #453
✨ 변경사항
✏️ 작업 내용
groups(TOTAL/DAILY) 스펙으로 타입·ViewModel 매핑platformBudgets를PlatformBudgetSummary스펙에 맞게 수정adCampaignId/naverBudgetTarget매핑 (없으면 수정 버튼 disabled)[체크박스] [캠페인 명] [플랫폼]구성😅 미완성 작업
N/A
📢 논의 사항 및 참고 사항
예산 데이터가 아직 없어서 화면에서 안 보이거나 수정이 비활성화될 수 있습니다.
Summary by CodeRabbit
새 기능
개선 사항
버그 수정