-
Notifications
You must be signed in to change notification settings - Fork 1
main 최신화 #342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
feat: 체크리스트 항목에 saveCount 및 isSaved 속성 추가, 기타 코드 개선
Walkthrough체크리스트 아이템과 투두 아이템에 saveCount/isSaved 필드를 추가·전파하고, UI에서 동적 카운트를 표시하도록 수정. OtherTodoList 페이지는 pathname 변경 시 태그 매니저 액션을 재실행하도록 의존성을 변경. 카드 컴포넌트에서 isSaved의 기본값 처리를 null 병합 연산자로 조정. Changes
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate unit tests
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 |
There was a problem hiding this 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
📒 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 오동작을 방지합니다.
🚀 풀 리퀘스트 제안
📋 작업 내용
📸 스크린샷 (선택 사항)
📄 기타
Summary by CodeRabbit