Skip to content

Comments

20260114 #128 장바구니 메뉴 수량 조절 컴포넌트 개발#130

Merged
Chuseok22 merged 6 commits intomainfrom
20260114_#128_장바구니_메뉴_수량_조절_컴포넌트_개발
Jan 15, 2026

Hidden character warning

The head ref may contain hidden characters: "20260114_#128_\uc7a5\ubc14\uad6c\ub2c8_\uba54\ub274_\uc218\ub7c9_\uc870\uc808_\ucef4\ud3ec\ub10c\ud2b8_\uac1c\ubc1c"
Merged

20260114 #128 장바구니 메뉴 수량 조절 컴포넌트 개발#130
Chuseok22 merged 6 commits intomainfrom
20260114_#128_장바구니_메뉴_수량_조절_컴포넌트_개발

Conversation

@Chuseok22
Copy link
Member

@Chuseok22 Chuseok22 commented Jan 15, 2026

✨ 변경 사항


✅ 테스트


  • 수동 테스트 완료
  • 테스트 코드 완료

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능

    • 장바구니 수량 조절 컨트롤 추가(증가/감소/삭제 버튼, 1에서 삭제 아이콘 표시, 최대 9개 제한 및 비활성 아이콘)
    • 장바구니에서 항목을 직접 제거하는 기능 추가
  • UI 개선

    • 수량 스태퍼 및 라운디드 숫자 최소 크기/스타일 조정
    • 장바구니 버튼 레이아웃 단순화
    • 아이콘 이름/표시 개선(쇼핑백 등)
  • 기타

    • 원격 이미지 호스트 설정 업데이트 (이미지 로딩 개선)

✏️ Tip: You can customize this high-level summary in your review settings.

@Chuseok22 Chuseok22 self-assigned this Jan 15, 2026
@Chuseok22 Chuseok22 added the feat 새로운 기능 추가 (Feature) label Jan 15, 2026
@Chuseok22
Copy link
Member Author

@CodeRabbit full review

@coderabbitai
Copy link

coderabbitai bot commented Jan 15, 2026

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link

coderabbitai bot commented Jan 15, 2026

Caution

Review failed

The pull request is closed.

Walkthrough

QuantityStepper 컴포넌트와 스타일을 추가하고, useCart 훅에 removeFromCart를 도입했으며 아이콘 수출명 변경 및 CartButton/숫자 컴포넌트 스타일·마크업을 조정하고, next.config.ts의 원격 이미지 호스트명을 수정했습니다.

Changes

코호트 / 파일(s) 변경 요약
설정
next.config.ts
images.remotePatterns의 hostname 수정: campustable-s3.s3.ap-northeast-2.amazonaws.comcampus-table-s3.s3.ap-northeast-2.amazonaws.com
아이콘 관리
src/assets/icons/index.ts
MinusIcon, PlusIcon, PlusDisableIcon, ShoppingBagIcon, TrashIcon 신규 내보내기 추가; 기존 ShoppingBag 내보내기명이 ShoppingBagIcon으로 교체
수량 조절 컴포넌트 신규
src/features/cart/components/button/QuantityStepper.tsx, src/features/cart/components/button/QuantityStepper.module.css
QuantityStepper 컴포넌트 및 CSS 추가: 증감 버튼, 9개 상한 로직, 1에서 감소 시 TrashIcon 노출, 토스트 에러 핸들링 연결
장바구니 훅 확장
src/features/cart/hooks/useCart.ts
removeFromCart(menuId, callbacks?) 공개 메서드 추가: 중복 요청 방지, 수량 감소(quantity-1) 요청, 성공/오류 콜백 지원
CartButton 레이아웃 및 스타일 변경
src/features/menu/components/button/CartButton.tsx, src/features/menu/components/button/CartButton.module.css
.icon 래퍼 요소 제거(마크업 변경) 및 .icon의 고정 너비/높이 스타일 삭제(스타일 변경)
숫자 표시 컴포넌트 스타일 조정
src/shared/components/number/RoundedNumber.module.css
.containermin-widthmin-height(1.25rem) 추가
헤더 아이콘 사용 변경
src/shared/components/header/Header.tsx
ShoppingBagShoppingBagIcon로 임포트 및 사용명 변경

Sequence Diagram

sequenceDiagram
    actor User
    participant QS as QuantityStepper
    participant CH as useCart Hook
    participant API as Cart API
    participant Toast as Toast Handler

    User->>QS: 증가 클릭 (add)
    QS->>CH: addToCart(menuId)
    CH->>CH: 중복 요청 확인
    CH->>API: 수량 업데이트 요청
    API-->>CH: 응답
    alt 성공 & 새 수량 > 9
        CH->>Toast: onError("최대 수량(9) 도달")
        Toast-->>User: 토스트 표시
    else 성공
        CH-->>QS: 성공 콜백
        QS-->>User: UI 갱신
    else 오류
        CH->>Toast: onError(오류 메시지)
        Toast-->>User: 토스트 표시
    end

    User->>QS: 감소 클릭 (remove)
    QS->>CH: removeFromCart(menuId)
    CH->>CH: 중복 요청 확인
    CH->>API: 수량 감소 요청 (quantity-1)
    API-->>CH: 응답
    alt 성공
        CH-->>QS: 성공 콜백
        QS-->>User: UI 갱신 (0이면 아이템 제거/TrashIcon)
    else 오류
        CH->>Toast: onError(오류 메시지)
        Toast-->>User: 토스트 표시
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 버튼 톡톡, 숫자 춤추네,
플러스는 빛나고 마이너스는 조용히,
아홉 개 선을 지키며 툭 떨어지는 쓰레기통,
장바구니는 깔끔히 정리되었네. ✨🛒

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 주요 변경사항인 장바구니 메뉴 수량 조절 컴포넌트 개발을 명확하게 요약하고 있습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings


📜 Recent 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 ebc1ef8 and 0233210.

📒 Files selected for processing (3)
  • src/assets/icons/index.ts
  • src/features/cart/components/button/QuantityStepper.tsx
  • src/shared/components/header/Header.tsx

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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.

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: 2

🤖 Fix all issues with AI agents
In `@src/assets/icons/index.ts`:
- Around line 13-19: Rename the inconsistent export ShoppingBag to
ShoppingBagIcon to match the Icon suffix convention used by other exports (e.g.,
MinusIcon, PlusIcon, TrashIcon); update the export line to export { default as
ShoppingBagIcon } from "./shopping-bag.svg" and then update any imports/usages
referencing ShoppingBag throughout the codebase to use ShoppingBagIcon instead
so names remain consistent.

In `@src/features/cart/components/button/QuantityStepper.tsx`:
- Line 42: In QuantityStepper, add the missing semicolon to the const
declaration isPlusDisabled (change "const isPlusDisabled = quantity >= 9" to
terminate with a semicolon) to match the project's consistent code style; update
the line where isPlusDisabled is defined so the statement ends with a semicolon.
🧹 Nitpick comments (4)
src/features/cart/components/button/QuantityStepper.module.css (1)

1-12: align-content 대신 align-items 사용을 권장합니다.

align-content는 여러 줄의 flex 아이템이 있을 때 사용됩니다. 단일 줄 flex 컨테이너에서는 align-items가 더 적절합니다.

♻️ 수정 제안
 .container {
   display: flex;
   justify-content: center;
-  align-content: center;
+  align-items: center;

   padding-block: 0.44rem;
   padding-inline: 0.5rem;

   border-radius: 0.25rem;
   border: 1px solid var(--color-gray-200);
   background-color: var(--color-white);
 }
src/features/cart/hooks/useCart.ts (1)

105-151: removeFromCart 구현이 잘 되었습니다.

addToCart와 동일한 패턴을 따르고 있어 코드 일관성이 좋습니다:

  • 중복 요청 방지 로직
  • 수량 검증 (0일 때 조기 반환)
  • 콜백 처리

참고: requestPromise가 생성되지만 반환되거나 await되지 않아 reject(error) 호출 시 unhandled promise rejection이 발생할 수 있습니다. 이는 addToCart에도 동일하게 존재하는 패턴이므로, 향후 리팩토링 시 함께 개선하면 좋겠습니다.

♻️ Promise 반환 또는 void 처리 제안 (선택사항)
-  const requestPromise = new Promise<void>((resolve, reject) => {
+  const requestPromise = new Promise<void>((resolve) => {
     upsertCartMutation.mutate(
       { menuId, quantity: newMenuQuantity },
       {
         onSuccess: () => {
           pendingRequests.current.delete(menuId);
           callbacks?.onSuccess?.();
           resolve();
         },
         onError: (error) => {
           pendingRequests.current.delete(menuId);
           callbacks?.onError?.("장바구니 수정에 실패했어요. 잠시 후 다시 시도해주세요.");
-          reject(error);
+          resolve(); // 에러는 콜백으로 처리되므로 resolve로 종료
         },
       }
     );
   });
src/features/cart/components/button/QuantityStepper.tsx (2)

17-18: isAddingToCart는 전역 mutation 상태입니다.

useCart에서 반환되는 isAddingToCartupsertCartMutation.isPending으로, 특정 menuId가 아닌 전체 mutation의 pending 상태를 나타냅니다. 따라서 다른 메뉴 아이템의 수량 변경 중에도 이 컴포넌트의 버튼이 비활성화될 수 있습니다.

현재 구현에서는 감소 버튼만 isAddingToCart로 비활성화하고 있어 동작에 불일치가 있을 수 있습니다. 필요하다면 useCart에서 메뉴별 pending 상태를 노출하는 것을 고려해 주세요.


47-61: 버튼 비활성화 상태 불일치.

감소 버튼은 isAddingToCart로 비활성화되지만, 증가 버튼은 isPlusDisabled(수량 >= 9)로만 비활성화됩니다. 장바구니 작업 진행 중에도 증가 버튼을 클릭할 수 있습니다.

useCart.addToCart 내부에서 pendingRequests로 중복 요청을 방지하므로 기능적으로는 문제가 없지만, 일관된 UX를 위해 두 버튼 모두 동일하게 비활성화하는 것이 좋습니다.

♻️ 수정 제안
         <button
           onClick={handleIncrement}
-          disabled={isPlusDisabled}
+          disabled={isPlusDisabled || isAddingToCart}
         >
           {incrementIcon}
         </button>
📜 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 4463fad and ebc1ef8.

⛔ Files ignored due to path filters (4)
  • src/assets/icons/minus.svg is excluded by !**/*.svg
  • src/assets/icons/plus-disable.svg is excluded by !**/*.svg
  • src/assets/icons/plus.svg is excluded by !**/*.svg
  • src/assets/icons/trash.svg is excluded by !**/*.svg
📒 Files selected for processing (8)
  • next.config.ts
  • src/assets/icons/index.ts
  • src/features/cart/components/button/QuantityStepper.module.css
  • src/features/cart/components/button/QuantityStepper.tsx
  • src/features/cart/hooks/useCart.ts
  • src/features/menu/components/button/CartButton.module.css
  • src/features/menu/components/button/CartButton.tsx
  • src/shared/components/number/RoundedNumber.module.css
💤 Files with no reviewable changes (2)
  • src/features/menu/components/button/CartButton.module.css
  • src/features/menu/components/button/CartButton.tsx
🧰 Additional context used
🧬 Code graph analysis (1)
src/features/cart/components/button/QuantityStepper.tsx (2)
src/features/cart/hooks/useCart.ts (1)
  • useCart (24-162)
src/shared/hooks/useToast.ts (1)
  • useToast (16-83)
🔇 Additional comments (7)
next.config.ts (1)

39-39: LGTM!

S3 버킷 호스트명 변경이 올바르게 적용되었습니다. 기존 campustable-s3에서 campus-table-s3로 변경되었으며, 나머지 설정은 그대로 유지됩니다.

배포 전 새로운 S3 버킷에서 이미지가 정상적으로 로드되는지 확인해 주세요.

src/features/cart/components/button/QuantityStepper.module.css (1)

14-27: LGTM!

.wrapper.label 스타일이 프로젝트의 CSS 변수를 일관되게 사용하고 있습니다.

src/features/cart/hooks/useCart.ts (1)

17-21: LGTM!

removeFromCart 메서드의 인터페이스가 addToCart와 일관된 패턴으로 정의되었습니다.

src/shared/components/number/RoundedNumber.module.css (1)

6-8: LGTM!

최소 크기 설정(min-width, min-height: 1.25rem)이 추가되어 컨테이너가 내용물 크기에 관계없이 일관된 최소 크기를 유지합니다. 장바구니 수량 표시의 시각적 안정성을 보장하는 좋은 변경입니다.

src/features/cart/components/button/QuantityStepper.tsx (3)

1-11: LGTM!

클라이언트 컴포넌트 선언과 필요한 의존성 import가 적절하게 구성되어 있습니다. QuantityStepperProps 인터페이스도 명확합니다.


20-28: LGTM!

최대 수량(9개) 체크와 에러 처리가 적절하게 구현되어 있습니다. useCart의 내부 검증과 별개로 UI 레벨에서의 방어적 체크는 즉각적인 피드백을 위해 좋은 패턴입니다.


30-38: LGTM!

수량이 0 이하일 때의 방어 로직과 removeFromCart 에러 처리가 적절합니다.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@Chuseok22 Chuseok22 merged commit 2055b7d into main Jan 15, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat 새로운 기능 추가 (Feature)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

⚙️ [기능추가][컴포넌트] 장바구니 메뉴 수량 조절 컴포넌트 개발

1 participant