Skip to content

[Refactor/#453] 예산 API 스펙 매핑 및 캠페인 목록 예산 열 제거 - #464

Merged
YermIm merged 6 commits into
developfrom
refactor/#453
Aug 13, 2026
Merged

YermIm merged 6 commits into
developfrom
refactor/#453

Conversation

@YermIm

@YermIm YermIm commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

🚨 관련 이슈

close #453

✨ 변경사항

  • 🐞 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.)

✏️ 작업 내용

  • 대시보드 예산 응답을 groups(TOTAL/DAILY) 스펙으로 타입·ViewModel 매핑
  • 캠페인 상세 platformBudgetsPlatformBudgetSummary 스펙에 맞게 수정
    • Naver: TOTAL 우선, 없으면 DAILY 표시
    • 예산 수정용 adCampaignId / naverBudgetTarget 매핑 (없으면 수정 버튼 disabled)
  • 예산 수정 불가 사유 안내 문구 제거
  • 캠페인 목록에서 예산 소진 열 제거 → [체크박스] [캠페인 명] [플랫폼] 구성

😅 미완성 작업

N/A

📢 논의 사항 및 참고 사항

예산 데이터가 아직 없어서 화면에서 안 보이거나 수정이 비활성화될 수 있습니다.

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

Summary by CodeRabbit

  • 새 기능

    • 플랫폼별 예산을 전체 예산·일일 예산 게이지로 확인하고, 편집 가능한 예산을 선택할 수 있습니다.
    • 플랫폼별 예산 편집 모달이 새로운 예산 유형과 대상 정보를 지원합니다.
    • 대시보드 예산 정보가 예산 유형별 그룹으로 표시됩니다.
  • 개선 사항

    • 캠페인 목록에서 예산 소진 현황 열을 제거하고 플랫폼 표시를 정렬했습니다.
    • 네이버는 전체 예산을 우선 표시합니다.
  • 버그 수정

    • 전체 예산 입력이 필요한 경우 누락 시 오류가 표시됩니다.

@YermIm
YermIm requested review from Seojegyeong and jjjsun August 12, 2026 18:14
@YermIm YermIm self-assigned this Aug 12, 2026
@YermIm YermIm added 🔨 Refactor 코드 리팩토링 📬 API 서버 API 통신 labels Aug 12, 2026
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

광고 플랫폼 예산을 단일 객체에서 IPlatformBudgetSummary[] 배열로 전환했습니다. 대시보드 예산 응답은 groups 구조를 사용합니다. 예산 게이지와 편집 흐름은 새 모델을 사용하며, 캠페인 목록에서는 예산 사용률 열을 제거했습니다.

Changes

예산 모델 전환

Layer / File(s) Summary
예산 데이터 계약
src/types/ads/budget.ts, src/types/ads/campaign.ts, src/types/dashboard/*.ts
플랫폼 예산 타입을 LIFETIME에서 TOTAL로 변경했습니다. 광고 예산 요약 모델과 대시보드 groups 응답 모델을 추가했습니다.
예산 요약 및 화면 변환
src/utils/ads/projectBudget.ts, src/utils/dashboard/budget.ts
플랫폼 예산 배열을 필터링하고 게이지로 변환합니다. 플랫폼별 예산을 그룹화합니다. 대시보드 groups를 예산 게이지 데이터로 변환하며, NAVER에서는 TOTAL 그룹만 사용합니다.
플랫폼 예산 편집 흐름
src/utils/ads/budgetEdit.ts, src/hooks/ads/useUpdatePlatformBudget.ts, src/pages/ads/list/CampaignDetail.tsx
새 요약 모델에서 편집 가능성, 폼 기본값, 업데이트 변수를 계산합니다. Meta·Google의 전체 예산 검증은 TOTAL 유형을 사용합니다. 캠페인 상세 화면은 플랫폼별 예산 배열을 전달하고 선택된 예산으로 모달을 엽니다.
캠페인 예산 화면 렌더링
src/components/ads/CampaignPlatformSection.tsx, src/components/ads/EditPlatformBudgetModal.tsx, src/components/ads/CampaignRow.tsx, src/components/ads/CampaignTable.tsx, src/components/ads/skeleton/AdsSkeleton.tsx
플랫폼별 게이지와 예산 편집 대상을 렌더링합니다. 편집 모달은 provider와 새 예산 타입을 사용합니다. 캠페인 목록의 예산 사용률 열을 제거하고 플랫폼 로고 정렬을 변경했습니다.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers: jjjsun, seojegyeong

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning 캠페인 상세 예산 모델 변경과 캠페인 목록 예산 열 제거는 연결 이슈 #453의 대시보드 어댑터 범위를 벗어납니다. 캠페인 관련 변경을 별도 이슈로 분리하거나, #453에 해당 요구 사항과 수용 기준을 추가해 변경 범위를 명확히 하세요.
Docstring Coverage ⚠️ Warning Docstring coverage is 55.17% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed 제목이 예산 API 매핑과 캠페인 목록 예산 열 제거라는 주요 변경 사항을 명확하게 요약합니다.
Description check ✅ Passed 관련 이슈, 변경 사항, 작업 내용, 미완성 작업, 참고 사항을 모두 포함해 템플릿을 충족합니다.
Linked Issues check ✅ Passed 대시보드 예산 응답을 groups 기반으로 변경하고 기존 gauges ViewModel 매핑을 유지해 #453의 요구 사항을 충족합니다.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/#453

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.

@github-actions

Copy link
Copy Markdown

📚 Storybook 배포 완료

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

@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: 3

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

1-1: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

import 경로를 @/ 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 win

NAVER에 TOTAL 그룹이 없으면 게이지가 모두 사라집니다.

filterBudgetGroups는 provider가 "NAVER"일 때 TOTAL 그룹만 남깁니다. 응답에 DAILY 그룹만 있으면 결과가 빈 배열이 되고, slices도 비어서 예산 게이지가 하나도 렌더링되지 않습니다.

같은 cohort의 src/utils/ads/projectBudget.tsfilterPlatformBudgetSummariesForDisplayTOTAL이 없을 때 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 win

mock placeholder가 프로덕션 화면에 노출될 수 있습니다.

resolvePlatformBudgetsplatformBudgets 필드가 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_LABELsrc/utils/dashboard/budget.ts Line 19-22에도 동일한 내용으로 존재합니다. 두 파일이 같은 라벨 문자열을 각각 관리하면 한쪽만 수정될 때 표시가 어긋납니다.

또한 여기서는 라벨 타입을 인라인 리터럴 유니온으로 다시 선언했습니다. src/types/dashboard/budget.tsTBudgetGaugeLabel을 사용하면 라벨 집합 변경이 타입으로 전파됩니다.

♻️ 제안 변경
-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: "일일 예산",
};

TPlatformBudgetTypeTDashboardBudgetType은 값 집합이 같습니다. 두 타입을 하나로 통합할지 함께 검토해 주세요.

🤖 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

📥 Commits

Reviewing files that changed from the base of the PR and between c87304d and 7e96534.

📒 Files selected for processing (14)
  • src/components/ads/CampaignPlatformSection.tsx
  • src/components/ads/CampaignRow.tsx
  • src/components/ads/CampaignTable.tsx
  • src/components/ads/EditPlatformBudgetModal.tsx
  • src/components/ads/skeleton/AdsSkeleton.tsx
  • src/hooks/ads/useUpdatePlatformBudget.ts
  • src/pages/ads/list/CampaignDetail.tsx
  • src/types/ads/budget.ts
  • src/types/ads/campaign.ts
  • src/types/dashboard/budget.ts
  • src/types/dashboard/common.ts
  • src/utils/ads/budgetEdit.ts
  • src/utils/ads/projectBudget.ts
  • src/utils/dashboard/budget.ts

Comment thread src/components/ads/CampaignPlatformSection.tsx
Comment thread src/components/ads/CampaignTable.tsx
Comment thread src/utils/ads/projectBudget.ts

@Seojegyeong Seojegyeong 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: 확인했습니다!

@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: 확인했습니다!

@YermIm
YermIm merged commit a2082a9 into develop Aug 13, 2026
3 checks passed
@YermIm
YermIm deleted the refactor/#453 branch August 13, 2026 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📬 API 서버 API 통신 🔨 Refactor 코드 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

♻️ [Refactor] 예산 API groups 스펙에 맞춰 대시보드 어댑터 정리

3 participants