Skip to content

[Refactor/#268] 워크스페이스·캠페인 그룹 useCoreQuery/useCoreMutation 패턴 통일 - #275

Merged
YermIm merged 3 commits into
developfrom
refactor/#268
Jul 3, 2026
Merged

[Refactor/#268] 워크스페이스·캠페인 그룹 useCoreQuery/useCoreMutation 패턴 통일#275
YermIm merged 3 commits into
developfrom
refactor/#268

Conversation

@YermIm

@YermIm YermIm commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

🚨 관련 이슈

close #268

✨ 변경사항

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

✏️ 작업 내용

팀 공통 추상화 훅(useCoreQuery, useCoreMutation) 도입에 따라 담당 파일의 raw useQuery / useMutation을 교체했습니다.

WorkspaceSwitcher.tsx

  • saveWorkspace mutation → useCoreMutation(saveSelectedWorkspace, …) 적용
  • invalidateQueries 수동 호출 → invalidateKeys로 이전
  • Zustand 상태 업데이트·드롭다운 닫기 → userOnSuccess로 이전
  • 불필요한 useQueryClient import 제거

useCampaignGroup.ts

  • Google / Naver / Meta 플랫폼 캠페인 목록 useQuery 3개 → useCoreQuery 교체
  • createGroup mutation → useCoreMutation<void, void> 교체
  • 캠페인 목록 invalidate → invalidateKeys: [QUERY_KEYS.campaign.list(orgId)]
  • 성공 모달·에러 toast → userOnSuccess / userOnError로 이전
  • 불필요한 useQueryClient, IApiErrorResponse import 제거

😅 미완성 작업

N/A

📢 논의 사항 및 참고 사항

N/A

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

Summary by CodeRabbit

  • 기능 개선
    • 워크스페이스 전환/저장 흐름이 개선되어, 저장 중 상태 반영이 더 안정적으로 동작합니다.
    • 캠페인 그룹 목록 조회 및 그룹 생성 후 성공 안내와 데이터 갱신이 더 정확히 처리됩니다.
  • 버그 수정
    • 요청 응답 경합 상황에서 최신 결과만 반영되도록 하여, 잘못된 선택 정보나 UI 갱신 오류를 줄였습니다.
    • 캐시 갱신이 정리되어 생성/저장 후 관련 정보가 즉시 반영됩니다.
  • UI 개선
    • 워크스페이스 저장 중 선택 버튼이 비활성화됩니다.

@YermIm
YermIm requested review from Seojegyeong and jjjsun June 29, 2026 14:36
@YermIm YermIm self-assigned this Jun 29, 2026
@YermIm YermIm added the 🔨 Refactor 코드 리팩토링 label Jun 29, 2026
@coderabbitai

coderabbitai Bot commented Jun 29, 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: 298c7f02-38ff-4abd-8ca1-53caa6002d65

📥 Commits

Reviewing files that changed from the base of the PR and between be491cc and 42ea258.

📒 Files selected for processing (1)
  • src/components/sidebar/WorkspaceSwitcher.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/sidebar/WorkspaceSwitcher.tsx

📝 Walkthrough

Walkthrough

WorkspaceSwitcheruseCampaignGroup에서 TanStack React Query 직접 사용을 제거하고 useCoreQuery/useCoreMutation으로 전환했습니다. 캐시 무효화는 invalidateKeys로 옮겼고, 워크스페이스 저장은 최신 요청만 후속 상태를 반영하도록 바뀌었습니다.

Changes

useCoreQuery/useCoreMutation 마이그레이션

Layer / File(s) Summary
WorkspaceSwitcher import 및 상태 준비
src/components/sidebar/WorkspaceSwitcher.tsx
TanStack React Query import를 제거하고 useCoreQuery/useCoreMutation과 저장 응답 경합 제어용 ref를 추가했습니다.
WorkspaceSwitcher 저장 흐름
src/components/sidebar/WorkspaceSwitcher.tsx
워크스페이스 저장 뮤테이션을 useCoreMutation 기반으로 바꾸고, 최신 orgId만 후속 상태를 반영하도록 선택 처리와 에러 처리를 조정했습니다.
useCampaignGroup 조회 훅
src/hooks/ads/useCampaignGroup.ts
플랫폼별 캠페인 조회를 useQuery에서 useCoreQuery로 교체하고 orgId 조건과 기본값 처리를 유지했습니다.
useCampaignGroup 생성 뮤테이션
src/hooks/ads/useCampaignGroup.ts
그룹 생성 뮤테이션을 useCoreMutation으로 전환하고, invalidateKeysuserOnSuccess/userOnError로 성공 모달 및 오류 토스트를 처리했습니다.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • WhereYouAd/WhereYouAd-Frontend#150: WorkspaceSwitcher.tsx의 워크스페이스 선택/저장 흐름을 직접 다뤘던 변경으로, 이번 PR과 같은 코드 경로를 수정했습니다.
  • WhereYouAd/WhereYouAd-Frontend#248: WorkspaceSwitcher.tsxuseCampaignGroup.ts의 쿼리 키 및 캐시 무효화 연결을 조정한 변경이라 이번 수정과 맞닿아 있습니다.
  • WhereYouAd/WhereYouAd-Frontend#260: WorkspaceSwitcher 저장 후 상태 반영과 무효화 흐름을 수정한 PR로, 이번 경합 제어 변경과 직접 연관됩니다.

Suggested reviewers: jjjsun

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 제목이 워크스페이스·캠페인 그룹의 useCoreQuery/useCoreMutation 통일이라는 핵심 변경을 정확히 요약합니다.
Description check ✅ Passed 관련 이슈, 변경사항, 작업 내용, 미완성 작업, 참고 사항이 템플릿 구조에 맞게 채워져 있습니다.
Linked Issues check ✅ Passed 직접 이슈 #268의 요구사항대로 raw react-query 훅을 공통 훅으로 교체하고 기존 캐시 무효화 동작도 유지했습니다.
Out of Scope Changes check ✅ Passed 변경 범위가 워크스페이스와 캠페인 그룹 리팩터링에만 맞춰져 있어, 눈에 띄는 범위 이탈은 없습니다.
✨ 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/#268

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

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown

📚 Storybook 배포 완료

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

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

🤖 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/sidebar/WorkspaceSwitcher.tsx`:
- Around line 58-66: Prevent duplicate workspace switch requests while a save is
in flight in WorkspaceSwitcher by disabling or ignoring additional clicks until
saveSelectedWorkspace finishes. Update the useCoreMutation flow around
saveWorkspace so userOnSuccess/onError only apply the latest requested orgId,
and ensure the dropdown is closed or interactions are blocked before any
invalidateKeys-driven delay can allow another selection.
🪄 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: 610510e0-a196-472f-90e7-bd2eeb6640b4

📥 Commits

Reviewing files that changed from the base of the PR and between a83179a and be491cc.

📒 Files selected for processing (2)
  • src/components/sidebar/WorkspaceSwitcher.tsx
  • src/hooks/ads/useCampaignGroup.ts

Comment thread src/components/sidebar/WorkspaceSwitcher.tsx Outdated

@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 ae8e171 into develop Jul 3, 2026
3 checks passed
@YermIm
YermIm deleted the refactor/#268 branch July 3, 2026 05:54
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] useCoreQuery / useCoreMutation 패턴 통일 (워크스페이스·캠페인 그룹)

3 participants