Skip to content

Commit ece9f5c

Browse files
committed
feat: add name and avatarUrl fields to GitHubUserData and UserResult types
1 parent 120d04c commit ece9f5c

7 files changed

Lines changed: 3118 additions & 3733 deletions

File tree

app/api/compare/route.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export async function GET(request: Request) {
2323

2424
return {
2525
username,
26+
name: data.name,
27+
avatarUrl: data.avatarUrl,
2628
repoScore: Math.round(score.repoScore),
2729
prScore: Math.round(score.prScore),
2830
contributionScore: Math.round(score.contributionScore),

components/comparison-table.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Image from "next/image";
12
import { UserResult } from "@/types/user-result";
23
import { Card, CardContent, CardHeader, CardTitle } from "./ui/card";
34

@@ -24,9 +25,18 @@ export function ComparisonTable({ user1, user2 }: ComparisonTableProps) {
2425
<div className="grid md:grid-cols-2 gap-6">
2526
{[user1, user2].map((user, idx) => (
2627
<Card key={user.username} className="overflow-hidden transition-all hover:shadow-lg">
27-
<CardHeader className={user.isWinner ? "border-b-2 border-primary/30" : "border-b-2 border-muted"}>
28+
<CardHeader className={`pb-4 ${user.isWinner ? "border-b-2 border-primary/30" : "border-b-2 border-muted"}`}>
2829
<CardTitle className="flex items-center justify-between">
29-
<span>{user.username}</span>
30+
<div className="flex items-center gap-3">
31+
<Image
32+
src={user.avatarUrl}
33+
alt={user.username}
34+
width={40}
35+
height={40}
36+
className="rounded-full ring-2 ring-border"
37+
/>
38+
<span>{user.name || user.username}</span>
39+
</div>
3040
{user.isWinner && (
3141
<span className="text-xs bg-primary/20 text-primary px-2 py-1 rounded-full">Winner</span>
3242
)}

lib/github.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ const client = graphql.defaults({
1515
const QUERY = /* GraphQL */ `
1616
query FetchUserData($login: String!, $repoCount: Int = 100, $prCount: Int = 100) {
1717
user(login: $login) {
18+
name
19+
avatarUrl
1820
repositories(
1921
first: $repoCount
2022
privacy: PUBLIC
@@ -67,6 +69,8 @@ export async function fetchGitHubUserData(
6769
}
6870

6971
return {
72+
name: user.name as string | null,
73+
avatarUrl: user.avatarUrl as string,
7074
repos: user.repositories.nodes as RepoNode[],
7175
pullRequests: user.pullRequests.nodes as PullRequestNode[],
7276
contributions: user.contributionsCollection as ContributionTotals,

next.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
const nextConfig = {
33
reactStrictMode: true,
44
typedRoutes: true,
5+
images: {
6+
remotePatterns: [
7+
{
8+
protocol: "https",
9+
hostname: "avatars.githubusercontent.com",
10+
},
11+
],
12+
},
513
};
614

715
module.exports = nextConfig;

0 commit comments

Comments
 (0)