Skip to content

[Refactor] PrimaryButton 제거 및 각 기능별 Button 컴포넌트로 분리 #20

Description

@haewonwon

요약

  • 과도한 추상화 제거 및 실제 필요한 케이스만 컴포넌트화

상세

현재 문제점

  1. 과도한 추상화: 단순한 버튼인데 타입 체크가 복잡함

    • apply, navigate, submit 타입으로 분리되어 있음
    • 대부분의 케이스는 react95 Button으로 충분함
  2. 실제 특수 로직이 있는 케이스는 하나뿐

    • apply 타입: 도토리 응모 버튼 (도토리 개수 체크 로직)
    • 나머지는 단순 wrapper 역할만 함
  3. 확장성 문제

    • 범용 버튼을 위해 계속 타입 추가해야 함
    • props가 점점 복잡해짐
    • react95 Button의 모든 기능을 다시 구현해야 함

리팩토링 방향

  1. PrimaryButton 삭제

    • src/components/shared/PrimaryButton.tsx 파일 삭제
    • src/components/shared/index.ts에서 export 제거
  2. ApplyButton 컴포넌트 생성

    • src/components/features/user/ApplyButton.tsx 생성
    • 도토리 응모 전용 컴포넌트 (실제 로직 있음)
    • 도토리 개수 체크, requiredDotori, isPending 처리
  3. 나머지는 react95 Button 직접 사용하거나 컴포넌트 생성

예상 효과

  • 코드 간소화: 불필요한 타입 체크 제거
  • 가독성 향상: 명시적인 코드로 변경
  • 유지보수 용이: 실제 로직이 있는 컴포넌트만 관리

완료 조건

  • PrimaryButton.tsx 파일 삭제
  • src/components/shared/index.ts에서 PrimaryButton export 제거
  • ApplyButton.tsx 컴포넌트 생성 (도토리 응모 전용)
  • EntryButton.tsx에서 ApplyButton 사용하도록 변경
  • 다른 컴포넌트에서 PrimaryButton 사용하는 곳이 없는지 확인
  • 모든 테스트 통과 및 빌드 성공

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions