Skip to content

Fix(client): category edit query string sync#141

Merged
constantly-dev merged 1 commit intodevelopfrom
fix/#140/category-params-sync
Sep 21, 2025
Merged

Fix(client): category edit query string sync#141
constantly-dev merged 1 commit intodevelopfrom
fix/#140/category-params-sync

Conversation

@constantly-dev
Copy link
Member

@constantly-dev constantly-dev commented Sep 21, 2025

📌 Related Issues

관련된 Issue를 태그해주세요. (e.g. - close #25)

📄 Tasks

  • category params sync

⭐ PR Point (To Reviewer)

이전에 사이드바에서 카테고리를 수정하면 대시보드와 쿼리 스트링에 해당 수정된 카테고리가 바로 반영이 안된다는 문제가 있었어요.
사이드바에 있는 카테고리는 invalidate 처리가 되어 있어서 바로 반영이 되지만, 이외 UI나 쿼리 스트링에는 따로 해당 처리가 안되어 있었기 때문에 로직을 추가했어요.

 const moveNewCategory = (id: number) => {
    navigate(`/my-bookmarks?id=${id}&category=${newCategoryName}`);
    setActiveTab('mybookmark');
    setSelectedCategoryId(id);
  };

이와 같이 새로운 카테고리를 담은 쿼리 스트링을 포함한 주소로 라우팅을 해주고, tab과 카테고리 설정도 해주었어요.
사실 위 문제에 대한 직접적인 해결은 navigate만 해주면 되지만, 카테고리를 수정하면 그 카테고리로 이동되는게 UX적으로 자연스럽다고 생각해서 아래 2줄을 추가해줬어요.

이를 수정하는 mutate 함수의 onSuccess에 아래와 같이 추가해서 문제를 해결했어요.

 onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: ['dashboardCategories'] });
      setNewCategoryName('');
      close();
      moveNewCategory(id);
    },

Summary by CodeRabbit

  • New Features

    • 새 카테고리 생성·수정 후 자동으로 해당 카테고리로 이동하고 ‘내 북마크’ 탭을 활성화합니다.
    • 사이드바에서 새로 이동한 카테고리를 즉시 선택하여 상태를 동기화합니다.
    • 대시보드 카테고리 목록이 자동으로 갱신됩니다.
  • Bug Fixes

    • 팝업 전환 시 토스트 메시지가 올바르게 초기화되도록 타이밍을 조정해 중복/잔류 표시를 방지했습니다.
  • Refactor

    • 사이드바 내 내비게이션 상태 연동을 정리해 전환 흐름을 일관되게 개선했습니다.

@vercel
Copy link

vercel bot commented Sep 21, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
pinback-client-client Ready Ready Preview Comment Sep 21, 2025 2:07am
pinback-client-landing Ready Ready Preview Comment Sep 21, 2025 2:07am

@coderabbitai
Copy link

coderabbitai bot commented Sep 21, 2025

Walkthrough

Sidebar에 react-router-dom 네비게이션을 도입하고, 카테고리 생성/수정 성공 시 대시보드 카테고리 캐시 무효화, 팝업 닫기, 탭 전환 및 해당 카테고리로 이동을 수행하는 내부 흐름을 추가/정비했습니다. 토스트 리셋 useEffect의 위치를 재배치하고, useSidebarNav의 setActiveTab을 통합했습니다.

Changes

Cohort / File(s) Summary
Sidebar navigation and category flow
apps/client/src/shared/components/sidebar/Sidebar.tsx
- useNavigate 도입 및 navigate 인스턴스 사용
- moveNewCategory(id) 헬퍼 추가: my-bookmarks로 이동, activeTab을 mybookmark로 설정, 카테고리 선택
- 카테고리 생성/수정 성공 시: 대시보드 카테고리 무효화 → 팝업 닫기 → moveNewCategory 호출
- useSidebarNav에서 setActiveTab 사용 통합
- 토스트 리셋 useEffect 재구성 및 위치 조정
- 렌더 로직은 유지하며 네비게이션 관련 부수효과 연결

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant SB as Sidebar
  participant MQ as React Query (mutations)
  participant RN as Router (useNavigate)
  participant SN as SidebarNav State

  rect rgb(240,248,255)
    Note over U,SB: 카테고리 생성/수정 트리거
    U->>SB: Create/Patch category
    SB->>MQ: mutate (create/patch)
    MQ-->>SB: onSuccess(id)
  end

  rect rgb(245,255,245)
    SB->>MQ: invalidateQueries(dashboardCategories)
    SB->>SB: close popup / clear inputs
    SB->>SN: setActiveTab("mybookmark")
    SB->>SB: selectCategory(id)
    SB->>RN: navigate(/my-bookmarks?categoryId=id)
  end

  rect rgb(255,250,240)
    Note right of SB: popup 상태 변화 시<br/>toast 상태 리셋(useEffect)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

feat, frontend

Suggested reviewers

  • jllee000
  • jjangminii

Poem

새 카테고리로 총총- 뛰어가네, 내 발걸음
탭은 착, 토스트는 싹— 깔끔한 리듬
캐시 털고 팝업 닫고 길을 틔워
북마크 숲에 길표를 세워
오늘도 토끼는 라우팅에 귀를 세워 🐇✨

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title Check ✅ Passed 작성하신 제목 "Fix(client): category edit query string sync"은 본 PR의 핵심 변경점인 카테고리 파라미터/쿼리스트링 동기화 및 편집 관련 동작을 잘 요약하여 간결하고 관련성이 높습니다. 다만 PR 요약에서 사용된 표현(예: "category params sync") 및 접두사(Feat vs Fix)와 어휘("query string" vs "params")가 일관되지 않아 이력 검색 시 혼동을 줄 수 있습니다.
Linked Issues Check ✅ Passed 제공된 변경사항은 대시보드 카테고리 UI 파라미터 동기화 요구사항([#140])에 직접 부합합니다; Sidebar에서 useNavigate와 moveNewCategory를 도입하고 생성/수정 성공 시 카테고리 선택, 탭 전환(setActiveTab), 쿼리스트링 이동 및 대시보드 카테고리 무효화 로직을 포함해 목표를 충족합니다. 연결된 이슈 [#25]는 디자인 시스템의 Progress 컴포넌트 작업으로 본 PR의 스코프와 무관하며 변경사항에 포함되어 있지 않습니다.
Out of Scope Changes Check ✅ Passed raw_summary에 따르면 변경은 apps/client/src/shared/components/sidebar/Sidebar.tsx에 집중되어 있으며 네비게이션(쿼리/탭 동기화), 팝업/토스트 처리, 카테고리 캐시 무효화 등은 모두 이 PR의 목적(#140)과 관련된 변경으로 보입니다. 별도의 unrelated 파일 변경이나 #25와 같은 다른 이슈 구현 흔적은 발견되지 않아 범위를 벗어난 변경은 없습니다.
Description Check ✅ Passed PR 설명은 저장소 템플릿 구조를 잘 따르고 있으며 'Related Issues'에 close #140이 기재되어 있고 'Tasks'와 'PR Point (To Reviewer)' 섹션에 변경 목적, 구현 요지(쿼리 스트링을 포함한 navigate 호출, setActiveTab 및 selectedCategory 설정)와 코드 스니펫이 포함되어 있어 의도와 동작이 명확하게 전달됩니다. 비필수 항목인 스크린샷은 포함되어 있지 않지만 이는 치명적이지 않아 전체적으로 설명은 충분합니다. 다만 Tasks 섹션이 매우 간결하므로 테스트 방법이나 영향 범위(연관 컴포넌트, 쿼리 키 등)를 추가하면 리뷰에 도움이 됩니다.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/#140/category-params-sync

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.

@github-actions github-actions bot added the fix 버그 수정하라 러브버그 label Sep 21, 2025
@constantly-dev constantly-dev changed the title Feat(client): category params sync Feat(client): category edit query string sync Sep 21, 2025
@constantly-dev constantly-dev changed the title Feat(client): category edit query string sync Fix(client): category edit query string sync Sep 21, 2025
@github-actions
Copy link

✅ Storybook chromatic 배포 확인:
🐿️ storybook

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
apps/client/src/shared/components/sidebar/Sidebar.tsx (3)

45-46: 탭 키 문자열 상수화/타입 유니온 권장

'mybookmark' 등 문자열 리터럴 오타 리스크가 있습니다. Nav 탭 값을 공용 상수 또는 타입 유니온(예: type NavTab = 'remind' | 'mybookmark' | 'level')으로 강제하는 것을 권장합니다.


66-70: URL 쿼리 인코딩 및 상태 의존성 제거(이동 함수 개선 제안)

  • 현재 newCategoryName을 직접 문자열 보간하여 URL에 넣습니다. 공백/특수문자 인코딩 이슈가 있으므로 createSearchParams로 안전하게 구성하세요.
  • moveNewCategory가 외부 상태(newCategoryName)에 의존합니다. 호출 시점에 값이 비어 있으면 잘못된 URL이 생성될 수 있으므로, 이름을 인자로 받아 사용하거나 내부에서 안전하게 fallback 하도록 바꾸는 것을 권장합니다.

적용 예시:

-const moveNewCategory = (id: number) => {
-  navigate(`/my-bookmarks?id=${id}&category=${newCategoryName}`);
-  setActiveTab('mybookmark');
-  setSelectedCategoryId(id);
-};
+const moveNewCategory = (id: number, name?: string) => {
+  const category = (name ?? newCategoryName) || '';
+  navigate({
+    pathname: '/my-bookmarks',
+    search: createSearchParams({
+      id: String(id),
+      ...(category ? { category } : {}),
+    }).toString(),
+  });
+  setActiveTab('mybookmark');
+  setSelectedCategoryId(id);
+};

추가로, 상단 import도 다음과 같이 보완해주세요:

-import { useNavigate } from 'react-router-dom';
+import { useNavigate, createSearchParams } from 'react-router-dom';

66-70: 카테고리 생성 성공 시에도 동일 내비게이션 필요 여부 확인

생성 플로우(handleCreateCategory)에서는 현재 moveNewCategory가 호출되지 않습니다. 생성 직후 해당 카테고리로 이동해야 한다면, onSuccess에서 API 응답의 id/name을 받아 moveNewCategory(created.id, created.name)로 호출하도록 쿼리 훅 반환 타입을 확인해주세요.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e634da5 and 097269f.

📒 Files selected for processing (1)
  • apps/client/src/shared/components/sidebar/Sidebar.tsx (5 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: constantly-dev
PR: Pinback-Team/pinback-client#2
File: pnpm-workspace.yaml:3-3
Timestamp: 2025-08-18T13:48:59.065Z
Learning: constantly-dev는 docs 디렉터리를 컨벤션 문서 추가용으로 사용할 예정이라고 명시했습니다.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: storybook
🔇 Additional comments (2)
apps/client/src/shared/components/sidebar/Sidebar.tsx (2)

22-29: Router 컨텍스트 보장 필요

useNavigate 도입으로 Sidebar는 반드시 <Router> 컨텍스트 하에서만 렌더되어야 합니다. 스토리북/테스트에서도 MemoryRouter 등으로 감싸는지 확인해주세요.


119-122: 토스트 리셋 useEffect 배치/의존성 적절합니다

팝업 상태 변화에 맞춘 토스트 리셋으로 UX 플리커를 줄입니다. LGTM.

Comment on lines 89 to 94
onSuccess: () => {
setNewCategoryName('');
queryClient.invalidateQueries({ queryKey: ['dashboardCategories'] });
setNewCategoryName('');
close();
moveNewCategory(id);
},
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

버그: newCategoryName을 비운 뒤 이동하여 category 파라미터가 사라집니다

onSuccess에서 setNewCategoryName('') 호출 후 moveNewCategory(id)를 호출하고 있어 URL의 category가 빈 문자열이 됩니다. 순서 변경 또는 이름 인자 전달이 필요합니다.

- onSuccess: () => {
-   queryClient.invalidateQueries({ queryKey: ['dashboardCategories'] });
-   setNewCategoryName('');
-   close();
-   moveNewCategory(id);
- },
+ onSuccess: () => {
+   queryClient.invalidateQueries({ queryKey: ['dashboardCategories'] });
+   // URL 파라미터 보존을 위해 먼저 이동(이름 전달)
+   moveNewCategory(id, newCategoryName);
+   setNewCategoryName('');
+   close();
+ },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
onSuccess: () => {
setNewCategoryName('');
queryClient.invalidateQueries({ queryKey: ['dashboardCategories'] });
setNewCategoryName('');
close();
moveNewCategory(id);
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['dashboardCategories'] });
// URL 파라미터 보존을 위해 먼저 이동(이름 전달)
moveNewCategory(id, newCategoryName);
setNewCategoryName('');
close();
},
🤖 Prompt for AI Agents
In apps/client/src/shared/components/sidebar/Sidebar.tsx around lines 89 to 94,
calling setNewCategoryName('') before moveNewCategory(id) clears the name used
to build the URL/category param and results in an empty category; either call
moveNewCategory(id) before clearing newCategoryName, or change moveNewCategory
to accept an explicit name argument and pass the new category name (not the
state) so you can safely clear state afterwards.

@constantly-dev constantly-dev merged commit 9f38993 into develop Sep 21, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix 버그 수정하라 러브버그

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Fix] 대시보드 카테고리 UI params와 sync 맞추기

1 participant