Skip to content

Conversation

@MyungJiwoo
Copy link
Contributor

@MyungJiwoo MyungJiwoo commented Aug 4, 2025

🧩 관련 이슈 번호

📌 작업 내용

  • 가격 Input에 문자가 적히는 오류 해결 했습니다.
  • 가격 입력시 천 단위로 쉼표를 추가합니다.

✅ 체크리스트

  • PR 하기 전에 이슈에서 빼먹은건 없는지 확인했습니다
    • 라벨 및 마일스톤을 사이드 탭에서 등록했습니다.
  • PR을 보내는 브랜치가 올바른지 확인했습니다.
  • 팀원들이 리뷰하기 쉽도록 설명을 자세하게 작성했습니다.
  • 변경사항을 충분히 테스트 했습니다.
  • (함수를 구현 했을 때) JSDoc을 양식에 맞춰서 작성했습니다.
  • 컨벤션에 맞게 구현했습니다.

📷 UI 변경 사항 (선택)

default.mov

❓무슨 문제가 발생했나요? (선택)

💬 기타 참고 사항 (선택)

Summary by CodeRabbit

  • Refactor
    • 가격 입력란이 이제 천 단위 구분 기호(콤마)가 자동으로 적용되는 형식으로 개선되었습니다.
    • 가격 입력란이 숫자 입력을 더 정확하게 처리하도록 동작 방식이 변경되었습니다.
    • 폼에서 가격 입력란이 보다 일관된 방식으로 상태를 관리하도록 개선되었습니다.

@MyungJiwoo MyungJiwoo added this to the 프로젝트 마감 milestone Aug 4, 2025
@MyungJiwoo MyungJiwoo self-assigned this Aug 4, 2025
@MyungJiwoo MyungJiwoo added ♻️ Refactor 코드 리팩토링 🐞 Bug 버그 관련 labels Aug 4, 2025
@coderabbitai
Copy link

coderabbitai bot commented Aug 4, 2025

📝 Walkthrough

Walkthrough

PriceInput 컴포넌트가 완전히 제어 컴포넌트로 리팩토링되어, 명시적 value 및 onChange props를 사용하도록 변경되었습니다. 이에 따라 가격 입력 필드는 react-hook-form의 register에서 Controller로 관리 방식이 전환되었으며, PriceInput과의 연동이 명확해졌습니다.

Changes

Cohort / File(s) Change Summary
PriceInput 컴포넌트 리팩토링
apps/what-today/src/components/experiences/PriceInput.tsx
PriceInput이 value/onChange를 명시적으로 받는 제어 컴포넌트로 변경. 숫자 포맷팅 로직 추가, InputProps 확장, 불필요한 props 제거.
가격 입력 필드 폼 연동 변경
apps/what-today/src/pages/experiences/index.tsx
price 필드가 react-hook-form의 register에서 Controller로 전환, PriceInput과의 연동을 위해 value/onChange 명시적 전달.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PriceInput
    participant Controller
    participant Form

    User->>PriceInput: 입력값 변경 (숫자/텍스트)
    PriceInput->>PriceInput: 입력값 포맷팅, 숫자 변환
    PriceInput->>Controller: onChange(숫자 값)
    Controller->>Form: 폼 상태 업데이트
    Form->>Controller: price 값 변경 감지
    Controller->>PriceInput: value prop 업데이트
    PriceInput->>PriceInput: display 값 재포맷팅
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🥕
숫자 콤마 춤추는 입력창,
컨트롤러 품에 안긴 값 한 상,
토끼는 폼을 뛰어넘어
깔끔한 가격을 노래해요.
오늘도 코드밭에서
리팩토링 당근을 씹으며
깡총깡총, 리뷰를 향해!

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/mongdiwoo/241

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
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
  • 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 explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this 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 or @coderabbitai 요약 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.

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.

@github-actions
Copy link

github-actions bot commented Aug 4, 2025

🚀 오늘뭐해 Preview Deploy 완료!
👉 미리보기 링크

@MyungJiwoo MyungJiwoo linked an issue Aug 4, 2025 that may be closed by this pull request
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: 0

🧹 Nitpick comments (1)
apps/what-today/src/components/experiences/PriceInput.tsx (1)

25-36: 입력 처리 로직에서 개선 가능한 부분이 있습니다.

현재 구현에서 유효하지 않은 입력 시 onChange(0)을 호출하는데, 이는 사용자가 입력 필드를 지울 때도 0으로 설정됩니다. 빈 문자열 입력 시에는 별도 처리를 고려해보세요.

다음과 같이 개선할 수 있습니다:

  const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
    const raw = unformatNumber(e.target.value);
+   
+   // 빈 입력의 경우 별도 처리
+   if (raw === '') {
+     setDisplay('');
+     onChange(0); // 또는 필요에 따라 다른 기본값
+     return;
+   }
+   
    const numeric = Number(raw);

    if (!isNaN(numeric)) {
      setDisplay(formatNumber(numeric));
      onChange(numeric);
    } else {
      setDisplay('');
      onChange(0);
    }
  };
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 02b28b1 and 668a27f.

📒 Files selected for processing (2)
  • apps/what-today/src/components/experiences/PriceInput.tsx (1 hunks)
  • apps/what-today/src/pages/experiences/index.tsx (1 hunks)
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: MyungJiwoo
PR: What-Today-FE/What-Today#119
File: apps/what-today/src/pages/mypage/edit-profile/index.tsx:63-92
Timestamp: 2025-07-24T08:30:12.556Z
Learning: MyungJiwoo indicated they will implement validation checks for the edit profile page (password confirmation validation) immediately after PR #119 is merged, following their incremental development approach.
Learnt from: MyungJiwoo
PR: What-Today-FE/What-Today#57
File: packages/design-system/src/components/select/SelectRoot.tsx:37-38
Timestamp: 2025-07-17T01:20:26.915Z
Learning: In the SelectRoot component (packages/design-system/src/components/select/SelectRoot.tsx), MyungJiwoo questioned the need for implementing controlled component pattern. The current implementation only handles internal→external state changes via onChangeValue callback, but doesn't handle external→internal changes when the value prop is updated, which breaks the typical React controlled component contract.
Learnt from: MyungJiwoo
PR: What-Today-FE/What-Today#79
File: packages/design-system/src/components/ProfileImageInput.tsx:44-45
Timestamp: 2025-07-19T17:03:39.193Z
Learning: ProfileImageInput 컴포넌트(packages/design-system/src/components/ProfileImageInput.tsx)에서 previewUrl은 의도적으로 내부 상태로 관리됩니다. 이는 미리보기 이미지 관리와 API로 받아온 원본 이미지와의 비교를 위한 용도로, 외부에서 제어할 필요가 없는 uncontrolled 컴포넌트 + 콜백 패턴입니다.
Learnt from: MyungJiwoo
PR: What-Today-FE/What-Today#63
File: packages/design-system/src/pages/NoResultDoc.tsx:8-8
Timestamp: 2025-07-17T11:29:24.913Z
Learning: MyungJiwoo indicated that code duplication in documentation files (like design system documentation) is acceptable and doesn't need to be fixed, as it's not actual service code but rather demo/documentation code with different standards.
📚 Learning: in the selectroot component (packages/design-system/src/components/select/selectroot.tsx), myungjiwo...
Learnt from: MyungJiwoo
PR: What-Today-FE/What-Today#57
File: packages/design-system/src/components/select/SelectRoot.tsx:37-38
Timestamp: 2025-07-17T01:20:26.915Z
Learning: In the SelectRoot component (packages/design-system/src/components/select/SelectRoot.tsx), MyungJiwoo questioned the need for implementing controlled component pattern. The current implementation only handles internal→external state changes via onChangeValue callback, but doesn't handle external→internal changes when the value prop is updated, which breaks the typical React controlled component contract.

Applied to files:

  • apps/what-today/src/components/experiences/PriceInput.tsx
  • apps/what-today/src/pages/experiences/index.tsx
📚 Learning: in the radiogroup component (packages/design-system/src/components/radiogroup.tsx), the input type s...
Learnt from: Taeil08
PR: What-Today-FE/What-Today#35
File: packages/design-system/src/components/RadioGroup.tsx:0-0
Timestamp: 2025-07-13T13:18:33.545Z
Learning: In the RadioGroup component (packages/design-system/src/components/RadioGroup.tsx), the input type should be 'checkbox' rather than 'radio' to support the intended toggle behavior where users can click a selected option again to deselect it. The handleChange function already implements this toggle logic with `onSelect?.(isSelected ? '' : value);`.

Applied to files:

  • apps/what-today/src/components/experiences/PriceInput.tsx
  • apps/what-today/src/pages/experiences/index.tsx
📚 Learning: the mainpage component in apps/what-today/src/pages/main/index.tsx contains placeholder/example code...
Learnt from: MyungJiwoo
PR: What-Today-FE/What-Today#43
File: apps/what-today/src/pages/main/index.tsx:7-7
Timestamp: 2025-07-14T13:36:17.941Z
Learning: The MainPage component in apps/what-today/src/pages/main/index.tsx contains placeholder/example code that will be modified later, including the fixed height class 'h-1400' which the user indicated is temporary.

Applied to files:

  • apps/what-today/src/components/experiences/PriceInput.tsx
  • apps/what-today/src/pages/experiences/index.tsx
📚 Learning: profileimageinput 컴포넌트(packages/design-system/src/components/profileimageinput.tsx)에서 previewurl은 의도...
Learnt from: MyungJiwoo
PR: What-Today-FE/What-Today#79
File: packages/design-system/src/components/ProfileImageInput.tsx:44-45
Timestamp: 2025-07-19T17:03:39.193Z
Learning: ProfileImageInput 컴포넌트(packages/design-system/src/components/ProfileImageInput.tsx)에서 previewUrl은 의도적으로 내부 상태로 관리됩니다. 이는 미리보기 이미지 관리와 API로 받아온 원본 이미지와의 비교를 위한 용도로, 외부에서 제어할 필요가 없는 uncontrolled 컴포넌트 + 콜백 패턴입니다.

Applied to files:

  • apps/what-today/src/components/experiences/PriceInput.tsx
📚 Learning: myungjiwoo plans to implement form validation using zod and react-hook-form in a future iteration ra...
Learnt from: MyungJiwoo
PR: What-Today-FE/What-Today#90
File: apps/what-today/src/pages/signup/index.tsx:67-71
Timestamp: 2025-07-21T05:32:48.443Z
Learning: MyungJiwoo plans to implement form validation using zod and react-hook-form in a future iteration rather than adding quick validation checks in the current signup page implementation in apps/what-today/src/pages/signup/index.tsx.

Applied to files:

  • apps/what-today/src/pages/experiences/index.tsx
📚 Learning: taeil08이 what-today 프로젝트의 체험 등록 페이지(apps/what-today/src/pages/experiences/iindex.tsx)에서 주소 입력 컴포넌트가 ...
Learnt from: Taeil08
PR: What-Today-FE/What-Today#134
File: apps/what-today/src/pages/experiences/iindex.tsx:11-16
Timestamp: 2025-07-25T03:14:08.579Z
Learning: Taeil08이 What-Today 프로젝트의 체험 등록 페이지(apps/what-today/src/pages/experiences/iindex.tsx)에서 주소 입력 컴포넌트가 아직 만들어지지 않아서 상태 관리를 나중에 추가할 예정이라고 언급함. 이는 프로젝트의 점진적 개발 접근법에 따른 것임.

Applied to files:

  • apps/what-today/src/pages/experiences/index.tsx
🧬 Code Graph Analysis (1)
apps/what-today/src/components/experiences/PriceInput.tsx (1)
packages/design-system/src/components/input/index.ts (1)
  • Input (37-46)
🔇 Additional comments (6)
apps/what-today/src/components/experiences/PriceInput.tsx (5)

6-9: 인터페이스 정의가 올바르게 구현되었습니다.

PriceInputProps 인터페이스가 InputProps를 확장하여 제어 컴포넌트에 필요한 valueonChange 속성을 명확히 정의했습니다. 타입 안전성이 보장되어 있습니다.


12-13: 숫자 포맷팅 함수들이 적절히 구현되었습니다.

천 단위 구분 기호 추가/제거 로직이 정규식을 사용하여 효율적으로 구현되어 있습니다. replaceAll 메서드 사용도 적절합니다.


17-23: useEffect에서 value 변경 처리가 적절합니다.

외부에서 전달받은 value prop이 변경될 때 내부 display 상태를 올바르게 동기화하고 있으며, NaN 체크도 포함되어 있어 안전합니다.


38-43: onBlur 처리가 잘 구현되었습니다.

포커스를 잃을 때 포맷팅을 다시 적용하여 일관된 표시를 유지하는 로직이 적절합니다.


49-56: Input.Field 속성들이 올바르게 설정되었습니다.

type='text'inputMode='numeric'의 조합으로 모바일에서 숫자 키보드를 표시하면서 커스텀 포맷팅을 지원합니다. 제어 컴포넌트 패턴도 올바르게 구현되어 있습니다.

apps/what-today/src/pages/experiences/index.tsx (1)

294-300: Controller를 사용한 가격 입력 필드 통합이 올바르게 구현되었습니다.

PriceInput 컴포넌트가 제어 컴포넌트로 변경됨에 따라 register 대신 Controller를 사용하여 올바르게 통합했습니다. field.valuefield.onChange를 통한 양방향 데이터 바인딩과 에러 처리가 적절히 구현되어 있습니다.

Copy link
Member

@HarrySeop HarrySeop left a comment

Choose a reason for hiding this comment

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

바로 반영됐군요! 고생하셨습니다!

@MyungJiwoo MyungJiwoo merged commit 02a36de into develop Aug 4, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 Bug 버그 관련 ♻️ Refactor 코드 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

체험 등록시 가격에서 문자가 입력되는 이슈 해결

3 participants