Skip to content

Commit cbe49a7

Browse files
committed
add Statistics component
1 parent 789bc14 commit cbe49a7

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/components/LeetCode.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import React, { useEffect, useState } from 'react';
22
import { getProfile, getStatistics } from '../services/leetcode';
33
import { LeetCodeProfile, LeetCodeStatistics } from '../types/leetcode';
44
import Profile from './Profile';
5+
import Statistics from './Statistics';
56

67
const LeetCode = () => {
78
const [profile, setProfile] = useState<LeetCodeProfile | null>(null);
8-
const [_statistics, setStatistics] = useState<LeetCodeStatistics | null>(null);
9+
const [statistics, setStatistics] = useState<LeetCodeStatistics | null>(null);
910

1011
useEffect(() => {
1112
getProfile().then(profile => {
@@ -26,7 +27,12 @@ const LeetCode = () => {
2627
});
2728
}, [profile]);
2829

29-
return profile ? <Profile profile={profile} /> : null;
30+
return profile ? (
31+
<div>
32+
<Profile profile={profile} />
33+
{statistics ? <Statistics statisitcs={statistics} /> : null}
34+
</div>
35+
) : null;
3036
};
3137

3238
export default LeetCode;

src/components/Statistics.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
import { LeetCodeStatistics } from '../types/leetcode';
3+
4+
const Statistics = ({ statisitcs }: { statisitcs: LeetCodeStatistics }) => {
5+
return (
6+
<div>
7+
<p>rank: {statisitcs.userPublicProfile.matchedUser.profile.ranking}</p>
8+
</div>
9+
);
10+
};
11+
12+
export default Statistics;

0 commit comments

Comments
 (0)