@@ -24,6 +24,7 @@ import { VideoRecommendation } from "@/types/video"
2424import { fetchRecommendedVideos , getYoutubeThumbnail } from "@/services/videos"
2525import { RecommendedArticle } from "@/types/article"
2626import { fetchRecommendedArticles } from "@/services/articles"
27+ import { fetchLearningStreak , LearningStats } from "@/services/learning"
2728
2829export default function FinancialLearningPlatform ( ) {
2930 const router = useRouter ( )
@@ -44,27 +45,18 @@ export default function FinancialLearningPlatform() {
4445 const [ articlesLoading , setArticlesLoading ] = useState ( false )
4546 const [ articlesError , setArticlesError ] = useState < string | null > ( null )
4647
47- // 사용자 통계
48- const userStats = {
49- articlesRead : 28 ,
50- badges : 8 ,
51- quizScore : 85 ,
52- streak : 15 ,
53- }
48+ // 학습 통계 상태
49+ const [ learningStats , setLearningStats ] = useState < LearningStats > ( {
50+ consecutiveDays : 0 ,
51+ quizCount : 0 ,
52+ articleCount : 0 ,
53+ } )
5454
5555 const userPreferences = {
5656 keywords : [ "ETF" , "배당주" , "부동산" , "경제지표" ] ,
5757 difficultyLevel : "intermediate" ,
5858 }
5959
60- const learningProgress = {
61- completedCourses : 12 ,
62- totalCourses : 20 ,
63- currentLevel : "Intermediate" ,
64- badges : 8 ,
65- streak : 15 ,
66- }
67-
6860 // 유튜브 영상 추천 API 호출
6961 useEffect ( ( ) => {
7062 const loadRecommendedVideos = async ( ) => {
@@ -117,6 +109,28 @@ export default function FinancialLearningPlatform() {
117109 loadRecommendedArticles ( )
118110 } , [ ] )
119111
112+ // 학습 통계 API 호출
113+ useEffect ( ( ) => {
114+ const loadLearningStats = async ( ) => {
115+ if ( ! isAuthenticated ) return
116+
117+ try {
118+ const response = await fetchLearningStreak ( )
119+ if ( response . success ) {
120+ setLearningStats ( {
121+ consecutiveDays : response . data . consecutiveDays ,
122+ quizCount : response . data . quizCount ,
123+ articleCount : response . data . articleCount ,
124+ } )
125+ }
126+ } catch ( error ) {
127+ console . error ( "Failed to load learning stats:" , error )
128+ }
129+ }
130+
131+ loadLearningStats ( )
132+ } , [ isAuthenticated ] )
133+
120134 const formatArticleDate = ( dateString : string ) => {
121135 const date = new Date ( dateString )
122136 const now = new Date ( )
@@ -163,7 +177,7 @@ export default function FinancialLearningPlatform() {
163177 </ div >
164178 < div className = "text-right" >
165179 < div className = "text-sm text-blue-200" > 연속 학습일</ div >
166- < div className = "text-3xl font-bold" > { learningProgress . streak } 일</ div >
180+ < div className = "text-3xl font-bold" > { learningStats . consecutiveDays } 일</ div >
167181 </ div >
168182 </ div >
169183 </ div >
@@ -175,8 +189,14 @@ export default function FinancialLearningPlatform() {
175189 < div className = "flex items-center justify-between" >
176190 < div >
177191 < p className = "text-sm text-gray-600" > 읽은 기사</ p >
178- < p className = "text-2xl font-bold" > { userStats . articlesRead } </ p >
179- < p className = "text-sm text-gray-500" > 개 완독</ p >
192+ { isAuthenticated ? (
193+ < >
194+ < p className = "text-2xl font-bold" > { learningStats . articleCount } </ p >
195+ < p className = "text-sm text-gray-500" > 개 완독</ p >
196+ </ >
197+ ) : (
198+ < p className = "text-sm text-gray-500 mt-2" > 로그인 후 EconoEasy와 함께 학습해봐요</ p >
199+ ) }
180200 </ div >
181201 < div className = "w-12 h-12 bg-blue-100 rounded-lg flex items-center justify-center" >
182202 < Newspaper className = "w-6 h-6 text-blue-600" />
@@ -189,9 +209,15 @@ export default function FinancialLearningPlatform() {
189209 < CardContent className = "p-6" >
190210 < div className = "flex items-center justify-between" >
191211 < div >
192- < p className = "text-sm text-gray-600" > 퀴즈 점수</ p >
193- < p className = "text-2xl font-bold" > { userStats . quizScore } 점</ p >
194- < p className = "text-sm text-gray-500" > 평균 점수</ p >
212+ < p className = "text-sm text-gray-600" > 푼 퀴즈</ p >
213+ { isAuthenticated ? (
214+ < >
215+ < p className = "text-2xl font-bold" > { learningStats . quizCount } </ p >
216+ < p className = "text-sm text-gray-500" > 개 완료</ p >
217+ </ >
218+ ) : (
219+ < p className = "text-sm text-gray-500 mt-2" > 로그인 후 EconoEasy와 함께 학습해봐요</ p >
220+ ) }
195221 </ div >
196222 < div className = "w-12 h-12 bg-orange-100 rounded-lg flex items-center justify-center" >
197223 < Target className = "w-6 h-6 text-orange-600" />
@@ -205,8 +231,14 @@ export default function FinancialLearningPlatform() {
205231 < div className = "flex items-center justify-between" >
206232 < div >
207233 < p className = "text-sm text-gray-600" > 연속 학습일</ p >
208- < p className = "text-2xl font-bold" > { learningProgress . streak } 일</ p >
209- < p className = "text-sm text-gray-500" > 학습 중</ p >
234+ { isAuthenticated ? (
235+ < >
236+ < p className = "text-2xl font-bold" > { learningStats . consecutiveDays } 일</ p >
237+ < p className = "text-sm text-gray-500" > 학습 중</ p >
238+ </ >
239+ ) : (
240+ < p className = "text-sm text-gray-500 mt-2" > 로그인 후 EconoEasy와 함께 학습해봐요</ p >
241+ ) }
210242 </ div >
211243 < div className = "w-12 h-12 bg-purple-100 rounded-lg flex items-center justify-center" >
212244 < Target className = "w-6 h-6 text-purple-600" />
0 commit comments