Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough예약/주문 탭과 관련된 새로운 UI와 로직이 추가되었습니다. 타입 정의, 유틸리티, 모의 데이터, 카드·리스트·모달 컴포넌트, 및 페이지(state 관리·모달 흐름·수락/거절 처리 포함)가 도입되었습니다. 변경 사항
시퀀스 다이어그램sequenceDiagram
actor User
participant OrderPage as "OrderStatusPage"
participant OrderList as "OrderList"
participant ReservationCard as "ReservationCard"
participant Modal as "Accept/Reject Modal"
participant State as "Local Orders State"
User->>ReservationCard: 수락/거절 버튼 클릭
ReservationCard->>OrderPage: open accept/reject (orderId)
OrderPage->>Modal: 모달 열기 (isOpen = true, orderId)
Modal-->>User: 확인/입력 UI 표시
alt 수락 흐름
User->>Modal: "수락하기" 클릭
Modal->>OrderPage: onConfirm()
OrderPage->>State: set status = "completed", set processedAt
else 거절 흐름
User->>Modal: 사유 입력 후 "거절하기" 클릭
Modal->>OrderPage: onConfirm(reason)
OrderPage->>State: set status = "cancelled", set processedAt
end
OrderPage->>OrderList: 업데이트된 orders 전달
OrderList->>ReservationCard: UI 리렌더링 / OrderHistoryCard로 이동 가능
OrderPage->>Modal: 모달 닫기 (isOpen = false)
예상 코드 리뷰 노력🎯 4 (Complex) | ⏱️ ~50 분 시
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
🧹 Nitpick comments (3)
apps/owner/src/app/(tabs)/order/_utils/orderStatus.ts (1)
3-27: switch문 대신 객체 맵 패턴 고려현재 구현도 정상 동작하지만, 두 함수 모두 동일한 상태 값에 대해 매핑하므로 객체 맵 패턴을 사용하면 중복을 줄이고 가독성을 높일 수 있습니다.
♻️ 객체 맵 패턴으로 리팩토링 제안
-export const getStatusLabel = (status: ReservationStatus) => { - switch (status) { - case "pending": - return "확인 대기중"; - case "completed": - return "거래완료"; - case "cancelled": - return "거래취소"; - default: - return ""; - } -}; - -export const getStatusClassName = (status: ReservationStatus) => { - switch (status) { - case "pending": - return "body1-m text-secondary"; - case "completed": - return "body1-m text-primary"; - case "cancelled": - return "body1-m text-gray-500"; - default: - return ""; - } -}; +const STATUS_CONFIG: Record<ReservationStatus, { label: string; className: string }> = { + pending: { label: "확인 대기중", className: "body1-m text-secondary" }, + completed: { label: "거래완료", className: "body1-m text-primary" }, + cancelled: { label: "거래취소", className: "body1-m text-gray-500" }, +}; + +export const getStatusLabel = (status: ReservationStatus): string => + STATUS_CONFIG[status]?.label ?? ""; + +export const getStatusClassName = (status: ReservationStatus): string => + STATUS_CONFIG[status]?.className ?? "";🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/owner/src/app/`(tabs)/order/_utils/orderStatus.ts around lines 3 - 27, Replace the repetitive switch statements in getStatusLabel and getStatusClassName with object maps: create const STATUS_LABEL_MAP and STATUS_CLASS_MAP keyed by ReservationStatus and return STATUS_LABEL_MAP[status] ?? "" and STATUS_CLASS_MAP[status] ?? "" from the respective functions; keep the same function names (getStatusLabel, getStatusClassName) and types (ReservationStatus) so behavior is unchanged while reducing duplication and improving readability.apps/owner/src/app/(tabs)/order/_types/order.ts (1)
15-23: 모달 상태 타입은 공통 타입으로 합쳐 중복을 줄여주세요.동일 구조를 별도 인터페이스로 유지하면 나중에 필드 변경 시 불일치가 생기기 쉽습니다.
♻️ 제안 코드
+ export interface OrderActionModalState { + isOpen: boolean; + orderId: number | null; + } - export interface AcceptModalState { - isOpen: boolean; - orderId: number | null; - } - - export interface RejectModalState { - isOpen: boolean; - orderId: number | null; - } + export type AcceptModalState = OrderActionModalState; + export type RejectModalState = OrderActionModalState;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/owner/src/app/`(tabs)/order/_types/order.ts around lines 15 - 23, The two identical interfaces AcceptModalState and RejectModalState should be consolidated into a single shared type (e.g., ModalState or GenericModalState) to remove duplication; replace both declarations with one interface (with properties isOpen: boolean and orderId: number | null) and update any usages or imports that reference AcceptModalState or RejectModalState to use the new shared type (or create typed aliases if you need semantic names) so future field changes remain centralized.apps/owner/src/app/(tabs)/order/page.tsx (1)
44-70: 모달 open/close 핸들러 중복은 공통화해도 좋겠습니다.accept/reject가 동일한 패턴이라 공통 헬퍼로 묶으면 수정 포인트를 줄일 수 있습니다.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/owner/src/app/`(tabs)/order/page.tsx around lines 44 - 70, The four near-identical modal handlers (openAcceptModal, closeAcceptModal, openRejectModal, closeRejectModal) should be consolidated into a generic modal helper: replace them with a single openModal(type: "accept" | "reject", orderId?: number) and closeModal(type: "accept" | "reject") (or a toggleModal that accepts {type, isOpen, orderId}) and have these call setAcceptModal / setRejectModal based on the type; update usages to call openModal("accept", id) / closeModal("reject") and remove the duplicate functions to reduce maintenance points.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/owner/src/app/`(tabs)/order/page.tsx:
- Around line 117-124: The current onTabChange handler casts the incoming key to
OrderTabKey unsafely; replace the cast with a type guard that validates the key
before calling setActiveTab. Implement or use a predicate like
isOrderTabKey(key) that checks key against the allowed OrderTabKey values (e.g.,
the items' keys or an OrderTabKey union), then call setActiveTab(key) only when
the predicate returns true and optionally handle invalid keys (ignore or log).
Update the TopTabBar onTabChange handler in page.tsx to perform this check
instead of using "as OrderTabKey", referencing TopTabBar, onTabChange,
OrderTabKey, activeTab, and setActiveTab.
---
Nitpick comments:
In `@apps/owner/src/app/`(tabs)/order/_types/order.ts:
- Around line 15-23: The two identical interfaces AcceptModalState and
RejectModalState should be consolidated into a single shared type (e.g.,
ModalState or GenericModalState) to remove duplication; replace both
declarations with one interface (with properties isOpen: boolean and orderId:
number | null) and update any usages or imports that reference AcceptModalState
or RejectModalState to use the new shared type (or create typed aliases if you
need semantic names) so future field changes remain centralized.
In `@apps/owner/src/app/`(tabs)/order/_utils/orderStatus.ts:
- Around line 3-27: Replace the repetitive switch statements in getStatusLabel
and getStatusClassName with object maps: create const STATUS_LABEL_MAP and
STATUS_CLASS_MAP keyed by ReservationStatus and return STATUS_LABEL_MAP[status]
?? "" and STATUS_CLASS_MAP[status] ?? "" from the respective functions; keep the
same function names (getStatusLabel, getStatusClassName) and types
(ReservationStatus) so behavior is unchanged while reducing duplication and
improving readability.
In `@apps/owner/src/app/`(tabs)/order/page.tsx:
- Around line 44-70: The four near-identical modal handlers (openAcceptModal,
closeAcceptModal, openRejectModal, closeRejectModal) should be consolidated into
a generic modal helper: replace them with a single openModal(type: "accept" |
"reject", orderId?: number) and closeModal(type: "accept" | "reject") (or a
toggleModal that accepts {type, isOpen, orderId}) and have these call
setAcceptModal / setRejectModal based on the type; update usages to call
openModal("accept", id) / closeModal("reject") and remove the duplicate
functions to reduce maintenance points.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 524e33f8-c909-4f4e-b856-d5ebce83f203
📒 Files selected for processing (10)
apps/owner/src/app/(tabs)/order/_components/OrderHistoryCard.tsxapps/owner/src/app/(tabs)/order/_components/OrderList.tsxapps/owner/src/app/(tabs)/order/_components/ReservationCard.tsxapps/owner/src/app/(tabs)/order/_components/modal/AcceptOrderModal.tsxapps/owner/src/app/(tabs)/order/_components/modal/RejectOrderModal.tsxapps/owner/src/app/(tabs)/order/_constants/mockOrders.tsapps/owner/src/app/(tabs)/order/_types/order.tsapps/owner/src/app/(tabs)/order/_utils/formatProcessAt.tsapps/owner/src/app/(tabs)/order/_utils/orderStatus.tsapps/owner/src/app/(tabs)/order/page.tsx
✅ 작업 내용
📝 Description
🚀 설계 의도 및 개선점
📸 스크린샷 (선택)
📎 기타 참고사항
Fixes #55
Summary by CodeRabbit