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 1
1
import React , { useEffect , useState } from 'react' ;
2
2
import { getProfile , getStatistics } from '../services/leetcode' ;
3
- import { LeetCodeProfile } from '../types/leetcode' ;
3
+ import { LeetCodeProfile , LeetCodeStatistics } from '../types/leetcode' ;
4
+ import Profile from './Profile' ;
4
5
5
6
const LeetCode = ( ) => {
6
7
const [ profile , setProfile ] = useState < LeetCodeProfile | null > ( null ) ;
8
+ const [ _statistics , setStatistics ] = useState < LeetCodeStatistics | null > ( null ) ;
7
9
8
10
useEffect ( ( ) => {
9
11
getProfile ( ) . then ( profile => {
@@ -20,20 +22,11 @@ const LeetCode = () => {
20
22
return ;
21
23
}
22
24
getStatistics ( profile . username ) . then ( d => {
23
- console . log ( 'LeetCode Statistics:' , d ) ;
25
+ setStatistics ( d ) ;
24
26
} ) ;
25
27
} , [ profile ] ) ;
26
28
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 ;
37
30
} ;
38
31
39
32
export 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