백로그
0할 일
0진행 중
0리뷰
1메인 대시보드 — DashboardController + LEARN/BUILD 요약 위젯 + 스트릭/XP + 테스트
## 목표 로그인 후 메인 대시보드 (/dashboard). LEARN 진행률 요약, BUILD 프로젝트 요약, 스트릭/XP 표시. ## 현재 상태 - DashboardController 스텁 존재 (빈 index 액션) - 라우트: `get "/dashboard", to: "dashboard#index"` - User: streak_days, total_xp 필드 존재 - 학습 진행 데이터: UserLessonProgress (completed, completed_at) - 프로젝트 데이터: Current.user.projects ## 구현 사항 ### 1. DashboardController ```ruby class DashboardController < ApplicationController def index # LEARN 요약 @total_lessons = Lesson.published.count @completed_lessons = Current.user.user_lesson_progresses.where(completed: true).count @learn_progress = @total_lessons.zero? ? 0 : (@completed_lessons.to_f / @total_lessons * 100).round # BUILD 요약 @projects = Current.user.projects.order(updated_at: :desc).limit(3) @project_count = Current.user.projects.count # 스트릭/XP @streak_days = Current.user.streak_days @total_xp = Current.user.total_xp end end ``` ### 2. 뷰 (app/views/dashboard/index.html.erb) - **다크 테마** (bg-bg, bg-surface, text-text-primary, bg-accent) - 기존 Partial 활용 (_card, _button) **레이아웃**: 그리드 (모바일 1열, md 2열) - **환영 메시지**: "안녕하세요, {이름}님!" + 날짜 - **스트릭/XP 카드**: streak_days 일 연속, total_xp XP - **LEARN 위젯**: 진행률 바 + "N/M 레슨 완료" + "학습 계속하기" 링크 (→ /learn) - **BUILD 위젯**: 최근 프로젝트 카드 (최대 3개) + "새 프로젝트 시작" 버튼 (→ /build/projects/new) - 프로젝트 없으면 "첫 프로젝트를 시작해보세요" CTA - 각 프로젝트: title, status badge, completion_percentage ### 3. 온보딩 후 리다이렉트 - ApplicationController의 check_onboarding에서 온보딩 완료 시 /dashboard로 이동하는 로직이 이미 있는지 확인 - 없으면 온보딩 complete 후 redirect_to dashboard_path 추가 (Onboarding::StepsController의 complete 액션에서) ### ⚠️ 주의 - dashboard/ 범위만 수정 (developer-2는 build/blueprints/ 작업 중) - 모델 수정 불필요 - N+1 방지 - 한국어 텍스트 ### 테스트 - DashboardController: index 접근, 인증 필요, LEARN/BUILD 데이터 표시 - 프로젝트 없을 때 빈 상태 처리 ### 완료 기준 - /dashboard LEARN 진행률 위젯 - BUILD 프로젝트 카드 - 스트릭/XP 표시 - bin/rails test 전체 통과