Skip to content

Conversation

@cywin1018
Copy link
Contributor

@cywin1018 cywin1018 commented Sep 7, 2025

🚀 풀 리퀘스트 제안

  • 기능 추가
  • 기능 삭제
  • 버그 수정
  • 스타일링
  • 의존성, 환경 변수, 빌드 관련 코드 업데이트
  • 기타

✈️ 관련 이슈

📋 작업 내용

📸 스크린샷 (선택 사항)

📄 기타

Summary by CodeRabbit

  • 신규 기능
    • 체크리스트 항목에 저장 수 표시를 추가하고, 문자열 항목은 기본 저장 수 0으로 표시됩니다.
    • 다른 투두 리스트에 saveCount와 isSaved 필드를 전달하여 카드에서 상태가 반영됩니다.
  • 버그 수정
    • isSaved 평가에 null 병합 연산을 사용해 false 값이 올바르게 유지되도록 개선했습니다.
    • 경로 변경 시에도 트래킹이 실행되도록 의존성을 수정했습니다.

cywin1018 and others added 2 commits September 8, 2025 00:36
@cywin1018 cywin1018 requested a review from Chasyuss September 7, 2025 15:39
@coderabbitai
Copy link

coderabbitai bot commented Sep 7, 2025

Walkthrough

체크리스트 아이템과 투두 아이템에 saveCount/isSaved 필드를 추가·전파하고, UI에서 동적 카운트를 표시하도록 수정. OtherTodoList 페이지는 pathname 변경 시 태그 매니저 액션을 재실행하도록 의존성을 변경. 카드 컴포넌트에서 isSaved의 기본값 처리를 null 병합 연산자로 조정.

Changes

Cohort / File(s) Summary
Checklist 타입/렌더링 확장
src/common/CheckList.tsx
ChecklistItemsaveCount?: number 추가, 문자열 아이템 정규화 시 { text, saveCount: 0 }로 변경, 표시값을 하드코드 999 → item.saveCount ?? 0로 교체. CheckListPropssaveCount?: number 필드 추가.
Todo 데이터 모델 확장
src/hook/useJobQuery.ts
EachTodossaveCount?: number, isSaved?: boolean 필드 추가.
OtherTodoList 렌더/트래킹
src/pages/otherTodoList/OtherTodoListPage.tsx
useEffect 의존성 [][location.pathname]로 변경하여 경로 변경 시 ReactTagManager.action 재호출. OtherTodoCard로 전달하는 todo에 saveCount, isSaved 포함.
OtherTodoCard 기본값 로직
src/pages/otherTodoList/components/OtherTodoCard.tsx
isAdded 계산에서 `item.isSaved

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor User as User
    participant Router as Router
    participant Page as OtherTodoListPage
    participant RTM as ReactTagManager
    participant Hook as useJobQuery
    participant Card as OtherTodoCard

    User->>Router: Navigate / change pathname
    Router->>Page: Render with new location.pathname
    Page->>Hook: Fetch/use todos
    Hook-->>Page: todos[{ saveCount?, isSaved?, ... }]
    Note right of Page: todos에 saveCount/isSaved 포함
    Page->>RTM: action() on pathname change
    Page->>Card: props(todo with saveCount, isSaved)
    Card->>Card: isAdded = added[todoId] ?:<br/>(item.isSaved ?? false)
    Card-->>User: Render list with save/saveCount UI
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

✨Feature

Suggested reviewers

  • Chasyuss

Poem

토끼는 체크를 톡톡톡,
저장 수 카운트 콩콩콩,
경로 바뀌면 태그가 쿵짝쾅,
isSaved는 살포시 ??로 착,
할 일 카드 반짝반짝—오늘도 깔끔히 정리 끝! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch develop

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.

@cywin1018 cywin1018 merged commit 45cc65e into main Sep 7, 2025
1 check was pending
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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/hook/useJobQuery.ts (1)

202-213: todos 타입이 튜플로 선언되어 있습니다 (런타임은 배열).

현재 선언은 단일 원소 튜플로 해석됩니다. 배열로 명확히 바꿔 주세요.

다음과 같이 수정 제안:

-  todos: [
-    {
-      todoId: number;
-      title: string;
-      completed: boolean;
-      isMemoExist: boolean;
-      isPublic: boolean;
-      saveCount?: number;
-      isSaved?: boolean;
-    },
-  ];
+  todos: {
+    todoId: number;
+    title: string;
+    completed: boolean;
+    isMemoExist: boolean;
+    isPublic: boolean;
+    saveCount?: number;
+    isSaved?: boolean;
+  }[];
🧹 Nitpick comments (5)
src/pages/otherTodoList/components/OtherTodoCard.tsx (2)

141-144: saveCount도 null 병합으로 일관성 유지 제안.

0을 유효값으로 인정하려면 || 대신 ?? 가 안전합니다.

-                    {item.saveCount || 0}
+                    {item.saveCount ?? 0}

113-116: 리스트 key는 index 대신 안정적인 식별자 사용 권장.

렌더링 최적화 및 버그 예방을 위해 todoId 사용 제안.

-              key={index}
+              key={item.todoId}
src/pages/otherTodoList/OtherTodoListPage.tsx (1)

24-31: route 파라미터 가드 추가를 고려해 주세요.

todoGroupId가 없거나 NaN인 경우 쿼리 호출을 건너뛰면 UX가 좋아집니다.

-  const { todoGroupId } = useParams<{ todoGroupId: string }>();
-  const {
+  const { todoGroupId } = useParams<{ todoGroupId: string }>();
+  const parsedTodoGroupId = Number(todoGroupId);
+  if (!todoGroupId || Number.isNaN(parsedTodoGroupId)) {
+    return (
+      <div className="flex h-full items-center justify-center text-gray-900">
+        잘못된 경로입니다.
+      </div>
+    );
+  }
+  const {
     data: eachTodos,
     isLoading,
     isError,
-  } = useEachTodosQuery(Number(todoGroupId));
+  } = useEachTodosQuery(parsedTodoGroupId);
src/common/CheckList.tsx (2)

24-25: Props의 saveCount는 미사용으로 보입니다.

혼동을 줄이기 위해 제거 권장합니다.

   showAddButton?: boolean;
-  saveCount?: number;
 }

37-39: normalized의 명시적 타입 지정으로 타입 안정성 개선 제안.

현재 유니온으로 추론될 수 있어 .id/.text 접근에 취약합니다.

-  const normalized = lists.map((item) =>
+  const normalized: { id?: number; text: string; saveCount?: number }[] = lists.map((item) =>
     typeof item === 'string' ? { text: item, saveCount: 0 } : item
   );
📜 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 ec56c66 and 457cc8a.

📒 Files selected for processing (4)
  • src/common/CheckList.tsx (3 hunks)
  • src/hook/useJobQuery.ts (1 hunks)
  • src/pages/otherTodoList/OtherTodoListPage.tsx (2 hunks)
  • src/pages/otherTodoList/components/OtherTodoCard.tsx (1 hunks)
🔇 Additional comments (6)
src/hook/useJobQuery.ts (1)

209-210: saveCount/isSaved 타입 추가 좋습니다.

서버 응답 변화에 맞춘 확장으로 보이며, 하위 컴포넌트들과 일관됩니다.

src/pages/otherTodoList/components/OtherTodoCard.tsx (1)

106-111: null 병합 연산자 적용이 올바릅니다.

isSaved가 false인 경우를 보존하므로 이전의 || 보다 정확합니다.

src/pages/otherTodoList/OtherTodoListPage.tsx (2)

22-22: GTM 이벤트 의존성 갱신 적절합니다.

pathname 변화에만 반응하도록 한 점이 명확합니다.


101-108: saveCount/isSaved 전달 OK.

타입 확장과 렌더링이 정합적입니다.

src/common/CheckList.tsx (2)

16-16: ChecklistItem에 saveCount 추가 적절.

UI 카운트 표시 요구와 부합합니다.


268-270: 북마크 카운트에 ?? 적용 좋습니다.

0 보존 및 일관된 처리로 UI 오동작을 방지합니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants