File tree Expand file tree Collapse file tree 2 files changed +22
-12
lines changed
Expand file tree Collapse file tree 2 files changed +22
-12
lines changed Original file line number Diff line number Diff line change 11import React , { useEffect , useState } from 'react' ;
22import { getProfile , getStatistics } from '../services/leetcode' ;
3- import { LeetCodeProfile } from '../types/leetcode' ;
3+ import { LeetCodeProfile , LeetCodeStatistics } from '../types/leetcode' ;
4+ import Profile from './Profile' ;
45
56const LeetCode = ( ) => {
67 const [ profile , setProfile ] = useState < LeetCodeProfile | null > ( null ) ;
8+ const [ _statistics , setStatistics ] = useState < LeetCodeStatistics | null > ( null ) ;
79
810 useEffect ( ( ) => {
911 getProfile ( ) . then ( profile => {
@@ -20,20 +22,11 @@ const LeetCode = () => {
2022 return ;
2123 }
2224 getStatistics ( profile . username ) . then ( d => {
23- console . log ( 'LeetCode Statistics:' , d ) ;
25+ setStatistics ( d ) ;
2426 } ) ;
2527 } , [ profile ] ) ;
2628
27- return profile ? (
28- < div >
29- < p > Welcome { profile . username } </ p >
30- < img
31- src = { profile . avatar }
32- alt = "Avatar"
33- style = { { width : '100px' , height : '100px' } }
34- />
35- </ div >
36- ) : null ;
29+ return profile ? < Profile profile = { profile } /> : null ;
3730} ;
3831
3932export default LeetCode ;
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import { LeetCodeProfile } from '../types/leetcode' ;
3+
4+ const Profile = ( { profile } : { profile : LeetCodeProfile } ) => {
5+ return (
6+ < div >
7+ < p > Welcome { profile . username } </ p >
8+ < img
9+ src = { profile . avatar }
10+ alt = "Avatar"
11+ style = { { width : '100px' , height : '100px' } }
12+ />
13+ </ div >
14+ ) ;
15+ } ;
16+
17+ export default Profile ;
You can’t perform that action at this time.
0 commit comments