-
Notifications
You must be signed in to change notification settings - Fork 1
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
Refactor/75: 코드래빗 리뷰 1차 반영 #76
Conversation
Walkthrough이 풀 리퀘스트는 API 요청을 처리하기 위한 새로운 비동기 함수 Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 4
🧹 Outside diff range and nitpick comments (4)
src/app/search/[id]/_components/transaction-form/trade/buy-form-buttons.tsx (1)
32-37
: 사용자 정의 버튼 스타일 적용 시 접근성 고려 제안
variant
를"custom"
으로 변경하고orderType
에 따라 버튼의 배경색을 동적으로 적용하여 UI의 일관성을 높였습니다. 다만, 설정한 배경색이 접근성 표준(예: WCAG 대비 비율)을 충족하는지 확인하여 사용자 경험을 향상시키는 것을 권장합니다.src/types/transaction/index.ts (1)
6-13
: 중복되는 속성들의 재사용을 위한 기본 인터페이스 추출을 제안드립니다.
LimitPriceOrderHistory
와TradeHistory
는 많은 공통 속성을 공유하고 있습니다. 다음과 같이 기본 인터페이스를 만들어 재사용하는 것을 고려해보세요:interface BaseTradeHistory { buyPrice: number; remainCount: number; stockCount: number; stockName: string; } interface LimitPriceOrderHistory extends BaseTradeHistory { OrderId: number; type: string; } interface TradeHistory extends BaseTradeHistory { id: number; buyOrder: string; }Also applies to: 15-22
src/app/search/[id]/_components/transaction-form/transaction-table.tsx (1)
18-18
: Props 타입에 대한 JSDoc 문서화가 필요합니다.TransactionTableProps 인터페이스에 대한 문서화를 추가하면 컴포넌트의 사용성이 향상될 것 같습니다.
다음과 같이 문서를 추가해보세요:
+/** + * @interface TransactionTableProps + * @property {('red' | 'green' | 'blue')} [color='red'] - 테이블 헤더와 버튼의 색상 + * @property {boolean} [isSubmit=true] - 제출 버튼 표시 여부 + * @property {Object} submittedData - 거래 데이터 + * @property {Function} [onClickGoBack] - 뒤로가기 버튼 클릭 핸들러 + * @property {Function} [onClickConfirm] - 확인 버튼 클릭 핸들러 + */src/app/search/[id]/_components/transaction-form/edit-cancel/index.tsx (1)
144-146
: 정렬 로직 최적화가 필요합니다매 렌더링마다 정렬이 수행되고 있습니다. 성능 최적화를 위해
useMemo
를 사용하는 것이 좋습니다.다음과 같이 수정하는 것을 제안합니다:
- [...limitOrderData] - .sort((a, b) => b.OrderId - a.OrderId) - .map((data) => ( + {useMemo(() => + [...limitOrderData] + .sort((a, b) => b.OrderId - a.OrderId) + .map((data) => ( + )), [limitOrderData])}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (15)
src/api/make-api-request.ts
(1 hunks)src/api/transaction/index.ts
(2 hunks)src/app/search/[id]/_components/transaction-form/edit-cancel/edit-table-body.tsx
(1 hunks)src/app/search/[id]/_components/transaction-form/edit-cancel/edit-table-header.tsx
(1 hunks)src/app/search/[id]/_components/transaction-form/edit-cancel/index.tsx
(1 hunks)src/app/search/[id]/_components/transaction-form/index.tsx
(1 hunks)src/app/search/[id]/_components/transaction-form/trade/buy-form-buttons.tsx
(1 hunks)src/app/search/[id]/_components/transaction-form/trade/index.tsx
(2 hunks)src/app/search/[id]/_components/transaction-form/trade/order-field.tsx
(1 hunks)src/app/search/[id]/_components/transaction-form/transaction-table.tsx
(2 hunks)src/app/search/[id]/types/index.ts
(0 hunks)src/components/common/button/index.tsx
(2 hunks)src/components/common/tabs/index.tsx
(2 hunks)src/types/transaction/index.ts
(1 hunks)src/validation/schema/transaction-form/index.tsx
(1 hunks)
💤 Files with no reviewable changes (1)
- src/app/search/[id]/types/index.ts
✅ Files skipped from review due to trivial changes (1)
- src/app/search/[id]/_components/transaction-form/edit-cancel/edit-table-header.tsx
🔇 Additional comments (13)
src/api/transaction/index.ts (4)
14-14
: API 요청 로직의 중앙 집중화로 코드 간결화 및 유지보수성 향상
makeApiRequest
함수를 도입하여 API 요청 로직을 중앙에서 관리함으로써 각 함수의 코드가 간결해졌습니다. 이는 유지보수성과 가독성을 높이는 좋은 접근입니다.
20-21
: 반환 타입 구체화로 타입 안정성 향상
기존에 Promise<string>
을 반환하던 것을 구체적인 응답 타입으로 변경하여 타입 안정성이 향상되었습니다. 이는 좋은 개선입니다.
Also applies to: 28-29, 36-37, 44-45
10-10
: 사용되지 않거나 제거된 타입의 재사용 여부 확인 필요
TradeHistory
타입이 다른 곳에서 제거되었거나 변경되었을 수 있습니다. 그러나 이 파일에서는 TradeHistory
를 반환 타입으로 사용하고 있습니다. 해당 타입이 유효한지 확인이 필요합니다.
다음 스크립트를 실행하여 TradeHistory
타입의 정의 및 사용 위치를 확인하세요:
Also applies to: 97-99
✅ Verification successful
Based on the results, I can generate the final response as the verification is complete. The TradeHistory
type is properly defined in src/types/transaction/index.ts
and is actively used in the codebase:
TradeHistory
타입이 정상적으로 정의되어 있고 올바르게 사용되고 있습니다
src/types/transaction/index.ts
에 인터페이스가 명확하게 정의되어 있습니다getTradeHistory
API 함수에서 반환 타입으로 사용되고 있습니다- 트랜잭션 히스토리 컴포넌트(
history.tsx
)에서 실제로 해당 API를 호출하여 사용하고 있습니다
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: TradeHistory 타입의 정의 및 사용 위치를 파악합니다.
# TradeHistory 타입 정의 검색
rg -A 5 'interface TradeHistory' --type ts
# TradeHistory 타입 사용 위치 검색
rg -A 2 'TradeHistory' --type ts
Length of output: 1734
52-55
: 함수 반환 타입 변경에 따른 코드베이스 영향 확인 필요
getHistory
및 getTrade
함수의 반환 타입이 변경되었습니다. 이로 인해 해당 함수를 호출하는 부분에서 타입 호환성 문제가 발생할 수 있으므로, 모든 호출부가 업데이트되었는지 확인해야 합니다.
다음 스크립트를 실행하여 해당 함수의 호출부를 확인하세요:
Also applies to: 62-65
src/validation/schema/transaction-form/index.tsx (1)
16-16
: 호가의 유효성 검사 강화
bidding
필드의 유효성 검사가 .min(0)
에서 .gt(0)
로 변경되어, 호가가 0보다 커야 함을 정확히 검증합니다. 올바른 수정입니다.
src/api/make-api-request.ts (1)
1-40
: API 요청 로직의 중앙 집중화를 통한 재사용성 향상
makeApiRequest
함수를 도입하여 API 요청 로직을 중앙에서 관리하고 재사용성을 높였습니다. 이는 코드의 일관성과 유지보수성에 큰 도움이 됩니다.
src/app/search/[id]/_components/transaction-form/edit-cancel/edit-table-body.tsx (1)
2-2
: 타입 변경이 적절하게 이루어졌습니다.
OrderHistory
에서 더 구체적인 LimitPriceOrderHistory
타입으로의 변경은 타입 안정성을 향상시킵니다.
Also applies to: 7-7
src/app/search/[id]/_components/transaction-form/trade/order-field.tsx (1)
66-69
:
numValue가 0인 경우에 대한 유효성 검사가 필요합니다.
0 값에 대한 검사가 제거되었습니다. 이는 주문 수량이나 입찰가가 0인 경우를 허용할 수 있어 비즈니스 로직에 문제가 될 수 있습니다.
다음 스크립트를 실행하여 관련 유효성 검사 스키마를 확인하겠습니다:
src/app/search/[id]/_components/transaction-form/index.tsx (1)
51-51
: 접근성 개선이 잘 이루어졌습니다!
Tabs 컴포넌트에 areaLabel을 추가하여 스크린 리더 사용자를 위한 접근성이 향상되었습니다.
src/app/search/[id]/_components/transaction-form/transaction-table.tsx (1)
103-108
: 버튼 스타일링이 개선되었습니다!
색상별 조건부 스타일링이 잘 구현되었고, hover 상태도 적절히 처리되었습니다.
src/app/search/[id]/_components/transaction-form/edit-cancel/index.tsx (2)
142-168
: 테이블 구조가 개선되었습니다
tbody
요소를 추가하여 테이블의 시맨틱 구조가 향상되었습니다.
174-184
: 버튼 스타일링이 일관되게 적용되었습니다
커스텀 variant를 사용하여 버튼 스타일링이 명확하게 구현되었습니다.
src/app/search/[id]/_components/transaction-form/trade/index.tsx (1)
18-21
: 타입 정의가 개선되었습니다
LimitPriceOrderHistory
와 ModifyTradeFormData
타입을 사용하여 타입 안정성이 향상되었습니다.
Also applies to: 38-39
@@ -3,7 +3,7 @@ import { ComponentProps, ReactNode } from "react"; | |||
import cn from "@/utils/cn"; | |||
|
|||
interface ButtonProps extends ComponentProps<"button"> { | |||
variant?: "primary" | "secondary" | "outline" | "outline-gray" | "red"; | |||
variant?: "primary" | "secondary" | "outline" | "outline-gray" | "custom"; |
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.
커스텀 버튼 스타일 정의가 불완전합니다.
custom
버튼 variant에 대한 스타일링에서 다음 사항을 확인해주세요:
- 배경색이 정의되어 있지 않습니다
- hover 상태에 대한 스타일이 누락되었습니다
다음과 같이 스타일을 보완하는 것을 제안드립니다:
- "text-white !rounded-4 px-24 py-9":
+ "bg-[#FF0000] text-white !rounded-4 px-24 py-9 hover:bg-[#DD0000]":
variant === "custom" && !isDisabled,
Also applies to: 34-35
export interface ModifyTradeFormData extends TradeAtLimitPriceFormDataType { | ||
orderId: string | number | undefined; | ||
} |
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.
🛠️ Refactor suggestion
ModifyTradeFormData의 orderId 타입을 더 명확하게 정의해주세요.
orderId
가 string | number | undefined
타입을 가지는 것은 타입 안정성을 저해할 수 있습니다. 가능하다면 단일 타입으로 통일하는 것이 좋습니다.
export interface ModifyTradeFormData extends TradeAtLimitPriceFormDataType {
orderId: string; // 또는 number로 통일
}
export interface TradeAtMarketPriceFormDataType { | ||
token: string | null; | ||
data: { | ||
stockName: string; | ||
quantity: number; | ||
}; | ||
} |
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.
💡 Codebase verification
token
타입에서 null
제거가 필요합니다.
makeApiRequest
함수의 구현을 보면 토큰이 없을 경우(!token
) "로그인이 필요합니다" 에러를 발생시킵니다. 따라서 TradeAtMarketPriceFormDataType
와 TradeAtLimitPriceFormDataType
인터페이스에서 token
이 null
을 허용하는 것은 실제 구현과 일치하지 않습니다. 아래 위치의 타입 정의를 수정해야 합니다:
src/types/transaction/index.ts
의TradeAtMarketPriceFormDataType
인터페이스src/types/transaction/index.ts
의TradeAtLimitPriceFormDataType
인터페이스
🔗 Analysis chain
토큰 타입에 대한 재검토가 필요합니다.
TradeAtMarketPriceFormDataType
와 TradeAtLimitPriceFormDataType
에서 token
이 null
을 허용하는 것이 의도된 것인지 확인해주세요. API 요청 시 토큰이 필수라면 null
을 제거하는 것이 안전합니다.
Also applies to: 64-71
Let me check how the token is actually used in API calls and form submissions.
Let me check how the makeApiRequest function handles the token to understand if null is actually allowed.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# API 호출에서 토큰 사용 패턴 확인
rg -A 2 "token: " src/api
Length of output: 1374
Script:
#!/bin/bash
# Check token usage in API calls and form submissions
rg -A 5 "TradeAtMarketPriceFormDataType|TradeAtLimitPriceFormDataType" src/
Length of output: 2858
Script:
#!/bin/bash
# Check makeApiRequest implementation
cat src/api/make-api-request.ts
Length of output: 977
@@ -31,9 +31,11 @@ const useTabsContext = () => { | |||
function Tabs({ | |||
children, | |||
defaultValue, | |||
areaLabel, |
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.
ARIA 레이블 속성명이 잘못되었습니다
area-label
속성은 올바른 HTML 접근성 속성이 아닙니다. 대신 aria-label
을 사용해야 합니다.
다음과 같이 수정해주세요:
- <TabsContext.Provider value={contextValue} area-label={areaLabel}>
+ <TabsContext.Provider value={contextValue} aria-label={areaLabel}>
Also applies to: 38-38, 48-48
#️⃣ 이슈
📝 작업 내용
이번 PR에서 작업한 내용을 간략히 설명해주세요.
📸 스크린샷
✅ 체크 리스트
👩💻 공유 포인트 및 논의 사항
Summary by CodeRabbit
새로운 기능
makeApiRequest
추가.makeApiRequest
를 사용하도록 리팩토링됨.Tabs
컴포넌트에 접근성을 위한areaLabel
속성 추가.버그 수정
문서화