Skip to content

Commit

Permalink
feat: Added Contributed Repos to profile page (#181)
Browse files Browse the repository at this point in the history
Co-authored-by: Brian Douglas <[email protected]>
Co-authored-by: Divyansh Singh <[email protected]>
  • Loading branch information
3 people authored Jun 14, 2023
1 parent 6289d59 commit 4901f7b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/popup/pages/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getUserData, getUserPRData, getUserHighlightsData } from "../../utils/f
import { emojify } from "node-emoji";
import { goBack, goTo } from "react-chrome-extension-router";
import { getRelativeDays } from "../../utils/dateUtils";
import { countUniqueRepos, PRResponse } from "../../utils/getContributedRepos";
import { getUserPRVelocity } from "../../utils/getUserPRVelocity";
import { BiExit } from "react-icons/bi";
import Start from "./start";
Expand Down Expand Up @@ -35,7 +36,7 @@ type InterestIconKeys = keyof typeof interestIcon;

export const Profile = ({ username }: { username: string }) => {
const [user, setUser] = useState<null | { id: string, user_name: string, bio: string, created_at: string, linkedin_url: string, twitter_username: string, blog: string, interests: string, open_issues: number }>(null);
const [userPR, setUserPR] = useState<null | { meta: { itemCount: number } }>(null);
const [userPR, setUserPR] = useState<PRResponse | null>(null);
const [userHighlights, setUserHighlights] = useState<null | { meta: { itemCount: number } }>(null);
const [userPRVelocity, setUserPRVelocity] = useState<number>(0);

Expand Down Expand Up @@ -82,7 +83,7 @@ export const Profile = ({ username }: { username: string }) => {
}}
>
<BiExit />
Log Out
Log Out
</button>
</header>

Expand Down Expand Up @@ -178,7 +179,9 @@ export const Profile = ({ username }: { username: string }) => {
<div className="flex flex-col items-center justify-center p-2 text-xs">
<p>Contributed Repos</p>

<p className="font-medium text-5xl">-</p>
<p className="font-medium text-5xl">
{countUniqueRepos(userPR)}
</p>
</div>
</div>

Expand Down
19 changes: 19 additions & 0 deletions src/utils/getContributedRepos.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export interface PRResponse {
data: {
full_name: string;
}[]
meta: {
itemCount: number;
};
}

export const countUniqueRepos = (response: PRResponse | null):number => {
if (!response?.data) {
return 0;
}

const { data } = response;
const uniqueRepos = new Set(data.map(obj => obj.full_name));

return uniqueRepos.size;
};

0 comments on commit 4901f7b

Please sign in to comment.