Skip to content

Conversation

@cindycho0423
Copy link
Collaborator

@cindycho0423 cindycho0423 commented Dec 9, 2024

#️⃣ 이슈

📝 작업 내용

이번 PR에서 작업한 내용을 간략히 설명해주세요.

  • Input Error 처리

📸 스크린샷

✅ 체크 리스트

  • 적절한 Title 작성
  • 적절한 Label 지정
  • Assignee 및 Reviewer 지정
  • 로컬 작동 확인
  • Merge 되는 브랜치 확인

👩‍💻 공유 포인트 및 논의 사항

Summary by CodeRabbit

  • New Features

    • OrderField 컴포넌트에서 입력 값 검증 로직이 추가되었습니다.
  • Bug Fixes

    • TotalAmount 컴포넌트에서 총 금액 표시의 최대 너비와 스크롤 속성이 개선되었습니다.
  • Style

    • 여러 컴포넌트의 스타일 클래스 이름이 조정되어 UI의 일관성이 향상되었습니다.
  • Chores

    • 코드의 타입 명시가 개선되어 가독성이 높아졌습니다.

@cindycho0423 cindycho0423 requested a review from Han-wo December 9, 2024 15:57
@cindycho0423 cindycho0423 self-assigned this Dec 9, 2024
@cindycho0423 cindycho0423 linked an issue Dec 9, 2024 that may be closed by this pull request
1 task
@coderabbitai
Copy link

coderabbitai bot commented Dec 9, 2024

Walkthrough

이 변경 사항은 EditCancel 컴포넌트의 useQuery 훅에서 queryKey를 업데이트하여 특정 주식 이름을 포함하도록 하여 캐싱 및 데이터 검색의 정확성을 높입니다. OrderField 컴포넌트에서는 입력 값 검증을 위한 정규 표현식과 입력 변경 핸들러가 추가되었습니다. TotalAmount, Dropdown, Input 컴포넌트에서는 클래스 이름 변경이 이루어졌으며, calculateBuyableQuantity 함수의 반환 타입이 명시적으로 설정되었습니다. 전반적으로 기능적인 변경은 없으며, 주로 코드의 가독성과 유지보수성을 향상시키는 방향으로 진행되었습니다.

Changes

파일 경로 변경 요약
src/app/search/[id]/_components/transaction-form/edit-cancel/index.tsx useQueryqueryKey["limitOrder", ${stockName}]으로 수정. 버튼의 클래스 이름 변경.
src/app/search/[id]/_components/transaction-form/trade/order-field.tsx 새로운 정규 표현식 numberRegex 추가 및 입력 변경 핸들러 handleInputChange 정의. onChange 핸들러 업데이트.
src/app/search/[id]/_components/transaction-form/trade/total-amount.tsx div의 클래스 이름을 max-w-167overflow-scroll 속성 추가로 변경.
src/components/common/dropdown/index.tsx Item 컴포넌트의 버튼 클래스 이름에서 수평 패딩을 py-10 px-8로 변경.
src/components/common/input/index.tsx 외부 <div>의 클래스 이름 로직 수정 및 inputtype 속성을 상태에 따라 동적으로 설정.
src/utils/price.ts calculateBuyableQuantity 함수의 반환 타입을 number로 명시적으로 설정.

Assessment against linked issues

Objective Addressed Explanation
입력 직접 입력 시 NaN 문제 수정 (#69)

Possibly related PRs

Suggested labels

✨ FEAT, 우선순위: HIGH

Suggested reviewers

  • Han-wo

🐰 변화의 길을 달려가며,
새로운 입력을 맞이하네,
에디트와 캔슬, 거래의 꿈,
모두 함께 춤을 추네!
🥕✨


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Han-wo Han-wo added 🛠️ FIX Something isn't working 우선순위: HIGH This issue or pull request already exists labels Dec 9, 2024
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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 41c744b and b80b3e1.

📒 Files selected for processing (6)
  • src/app/search/[id]/_components/transaction-form/edit-cancel/index.tsx (2 hunks)
  • src/app/search/[id]/_components/transaction-form/trade/order-field.tsx (2 hunks)
  • src/app/search/[id]/_components/transaction-form/trade/total-amount.tsx (1 hunks)
  • src/components/common/dropdown/index.tsx (1 hunks)
  • src/components/common/input/index.tsx (1 hunks)
  • src/utils/price.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • src/utils/price.ts
✅ Files skipped from review due to trivial changes (1)
  • src/app/search/[id]/_components/transaction-form/trade/total-amount.tsx
🔇 Additional comments (6)
src/app/search/[id]/_components/transaction-form/trade/order-field.tsx (2)

39-71: 입력값 검증 로직이 잘 구현되었습니다.

숫자 입력 검증과 에러 처리가 체계적으로 구현되었습니다:

  • 정규식을 통한 숫자와 쉼표만 허용
  • 빈 값 처리
  • NaN과 Infinity 같은 엣지 케이스 처리
  • 음수 값 방지

입력값 검증이 실제로 NaN 에러를 방지하는지 확인하기 위해 다음 테스트 케이스들을 검증해보세요:

const testCases = [
  "",           // 빈 문자열
  "123",        // 유효한 숫자
  "1,234",      // 쉼표가 있는 숫자
  "-123",       // 음수
  "abc",        // 문자
  "123.45",     // 소수점
  "Infinity",   // Infinity
  "NaN"         // NaN
];

// 각 테스트 케이스에 대해 handleInputChange 함수 실행

90-91: 입력값 표시 방식이 개선되었습니다.

  • undefined 처리가 추가되어 초기 상태에서 "undefined" 텍스트가 표시되는 문제가 해결되었습니다
  • 한국식 가격 표시 형식이 적용되어 사용자 경험이 향상되었습니다
src/components/common/input/index.tsx (1)

46-46: 스타일링 로직이 개선되었습니다.

relative 클래스가 항상 적용되도록 수정되어 입력 필드의 위치 지정이 일관되게 동작합니다.

src/components/common/dropdown/index.tsx (1)

161-161: 드롭다운 아이템의 여백이 개선되었습니다.

수평 패딩(px-8)이 추가되어 드롭다운 아이템의 좌우 여백이 더 일관되고 보기 좋아졌습니다.

src/app/search/[id]/_components/transaction-form/edit-cancel/index.tsx (2)

173-173: 클래스 순서 변경이 적절합니다.

스타일 속성의 순서만 변경되었으며, 기능상의 변화는 없습니다.


Line range hint 1-183: 입력 오류 수정과 관련된 추가 컨텍스트가 필요합니다.

이 컴포넌트는 직접적인 입력 처리를 하지 않지만, PR의 주요 목적인 NaN 입력 오류 수정과 관련이 있을 수 있습니다. 전체적인 수정 사항이 어떻게 입력 오류 해결에 기여하는지 설명이 필요합니다.

✅ Verification successful

입력 오류 처리가 적절히 구현되어 있음을 확인했습니다.

이 컴포넌트는 Trade 컴포넌트를 통해 주문 수정 기능을 제공하며, OrderField 컴포넌트에서 NaN 검사를 포함한 적절한 입력 유효성 검사가 이루어지고 있습니다. 특히:

  • 숫자 입력값에 대해 Number.isNaN() 검사
  • 무한대 값 체크 (Number.isFinite())
  • 0 이하 값 검사
  • 콤마 처리 등 문자열 정제

따라서 PR의 입력 오류 수정 목적에 부합하는 안전한 구현이 확인되었습니다.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: 입력 처리 관련 컴포넌트 검색

# Input 관련 컴포넌트 검색
rg -l "handleInputChange|onChange.*input" --type ts --type tsx

# NaN 관련 로직 검색
rg "NaN|isNaN" --type ts --type tsx

Length of output: 158


Script:

#!/bin/bash
# Let's try without file type restrictions and focus on specific patterns

# Search for input handling patterns
rg -l "handleInputChange|onChange.*input"

# Search for NaN-related logic
rg "NaN|isNaN"

# Search for form-related components that might handle input
rg -l "form.*component|input.*validation"

Length of output: 337


Script:

#!/bin/bash
# Let's examine the order-field.tsx component that contains both input handling and NaN checks

# Show the content of order-field.tsx with context
rg -A 10 -B 10 "isNaN" src/app/search/[id]/_components/transaction-form/trade/order-field.tsx

# Check if this component is used in the edit-cancel component
rg -l "order-field|OrderField" src/app/search/[id]/_components/transaction-form/trade/index.tsx

Length of output: 685


Script:

#!/bin/bash
# Let's check the Trade component to understand how OrderField is used in the edit flow

# Show the Trade component content
cat src/app/search/[id]/_components/transaction-form/trade/index.tsx

# Check how EditCancel uses Trade component
rg -A 5 -B 5 "<Trade" src/app/search/[id]/_components/transaction-form/edit-cancel/index.tsx

Length of output: 7435

isPending,
} = useQuery({
queryKey: ["limitOrder"],
queryKey: ["limitOrder", `${stockName}`],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

queryKey 변경이 안전하지 않습니다

limitOrder 쿼리키 사용을 분석한 결과, 다음과 같은 불일치가 발견되었습니다:

  • edit-cancel/index.tsx에서는 ["limitOrder", stockName]을 사용
  • trade/index.tsx에서는 ["limitOrder"]만을 사용하여 invalidate 수행

이로 인해:

  • 거래 완료/수정/취소 시 캐시 무효화가 제대로 동작하지 않을 수 있음
  • 데이터 일관성 문제가 발생할 수 있음

다음 중 하나의 방식으로 수정이 필요합니다:

  • 모든 invalidateQueries 호출에 stockName을 포함
  • 또는 edit-cancel/index.tsxqueryKey에서 stockName 제거
🔗 Analysis chain

캐시 키 변경이 다른 컴포넌트에 영향을 주지 않는지 확인이 필요합니다.

stockName을 queryKey에 추가한 변경이 적절해 보이나, 다른 컴포넌트에서 이 캐시를 참조하는 부분이 있는지 확인이 필요합니다.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: 다른 컴포넌트에서 limitOrder queryKey 사용 여부 확인

# limitOrder queryKey 사용 검색
rg -l "queryKey.*limitOrder" --type ts --type tsx

Length of output: 79


Script:

#!/bin/bash
# Search for limitOrder queryKey usage with proper file extensions
rg -l "queryKey.*limitOrder" -t ts -t typescript -t jsx -t tsx

# Also search for any limitOrder related cache operations
rg -l "useQuery.*limitOrder|invalidateQueries.*limitOrder" -t ts -t typescript -t jsx -t tsx

Length of output: 229


Script:

#!/bin/bash
# Find all TypeScript/React files first
fd "\.(ts|tsx)$" 

# Then search for limitOrder query usage in those files
fd "\.(ts|tsx)$" --exec rg -l "queryKey.*limitOrder|useQuery.*limitOrder|invalidateQueries.*limitOrder" {}

Length of output: 5027


Script:

#!/bin/bash
# Check the actual usage of limitOrder query in the found files
rg "queryKey.*limitOrder|useQuery.*limitOrder|invalidateQueries.*limitOrder" -A 2 -B 2 ./src/app/search/\[id\]/_components/transaction-form/edit-cancel/index.tsx ./src/app/search/\[id\]/_components/transaction-form/trade/index.tsx

Length of output: 2865

@github-actions
Copy link

github-actions bot commented Dec 9, 2024

@cindycho0423 cindycho0423 merged commit 5af892d into develop Dec 9, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🛠️ FIX Something isn't working 우선순위: HIGH This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚑️ Fix: input 직접 입력시 nan 뜨는 것 고치기

3 participants