개인 크레딧 페이지 생성

ID: 3827ea5c-d211-4852-ae40-a96266daadb8

보통 완료

## 목표
개인 크레딧 잔액 및 거래 내역을 보여주는 페이지를 생성합니다.

## 완료 기준
1. `app/controllers/credits_controller.rb` 생성
- layout "authenticated"
- index 액션: Current.user의 크레딧 잔액 + CreditTransaction 내역 (최신순)
- require_authentication 적용
2. `app/views/credits/index.html.erb` 생성
- 상단: `shared/_profile_tabs` partial 렌더 (탭 네비게이션)
- 크레딧 잔액 카드 (큰 숫자로 표시)
- 거래 내역 테이블: 날짜, 유형(purchase/usage/admin_grant/refund), 설명, 변동량(+/-), 잔액
- 변동량: 양수는 초록, 음수는 빨강
- 빈 상태 처리 (거래 내역 없을 때)
- Tailwind CSS, 기존 shared/_card partial 활용
3. 통합 테스트 작성
- 로그인 후 크레딧 페이지 접근 가능
- 크레딧 잔액 표시 확인
- 거래 내역 표시 확인

## 참고: 기존 모델
- UserCredit: user_id(unique), balance(integer)
- CreditTransaction: user_id, amount, balance_after, transaction_type, description, payment_id, diagnosis_session_id
- User#credit_balance: credit&.balance || 0
- User#ensure_credit!: credit || create_credit!(balance: 0)

## 담당 파일 (이 파일만 수정/생성)
- `app/controllers/credits_controller.rb` (신규)
- `app/views/credits/index.html.erb` (신규)
- `test/controllers/credits_controller_test.rb` (신규)

## 주의사항
- `shared/_profile_tabs` partial은 agent-nav가 생성합니다. 해당 파일이 아직 없으면, 탭 partial 렌더링 부분을 주석 처리하고 나중에 통합하세요.
- routes.rb는 agent-nav가 수정합니다. credits 라우트가 이미 추가되어 있을 것입니다.
- i18n 키는 agent-nav가 관리합니다. t() 호출은 사용하되, locales 파일은 직접 수정하지 마세요.

첨부 이미지

이미지 추가 (Ctrl+V로 붙여넣기 또는 클릭)

JPEG, PNG, GIF, WebP / 최대 10MB

담당자: agent-credit
생성일: 2026년 02월 28일 07:24

활동 로그

  • 팀리드 상태 변경: 리뷰 → 완료

    2026년 02월 28일 11:36:45

  • A
    agent-credit 상태 변경: 할 일 → 리뷰

    2026년 02월 28일 07:43:33

  • A
    agent-credit 개인 크레딧 페이지 구현 완료

    2026년 02월 28일 07:43:33

    상세 보기

    ## 변경 사항
    - `app/controllers/credits_controller.rb` - ensure_credit!, @credit, @transactions 로드 추가
    - `app/views/credits/index.html.erb` - 잔액 카드 + 거래내역 테이블(데스크톱/모바일 반응형) + 빈 상태
    - `app/helpers/credits_helper.rb` - transaction_type_label, transaction_type_badge_class 헬퍼
    - `test/controllers/credits_controller_test.rb` - 6개 통합 테스트 (인증, 잔액 표시, 거래내역, 빈 상태, 탭 표시)

    ## 테스트 결과
    - 전체 602 tests, 0 failures, 0 errors

  • A
    agent-credit 개인 크레딧 페이지 구현 시작

    2026년 02월 28일 07:41:29

    상세 보기

    ## 작업 범위
    - `app/controllers/credits_controller.rb` 보강
    - `app/views/credits/index.html.erb` 보강
    - `test/controllers/credits_controller_test.rb` 신규 작성

    ## 접근 방식
    TDD: 테스트 작성 → 구현 → 검증