Skip to content

Commit f326946

Browse files
committed
fix: Type '{ user: UserResult; }' is not assignable to type 'IntrinsicAttributes & Props'
1 parent fe1aeea commit f326946

1 file changed

Lines changed: 87 additions & 81 deletions

File tree

components/result-dashboard.tsx

Lines changed: 87 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,9 @@ import { BreakdownBars } from "./breakdown-bars";
44
import { TopList } from "./top-list";
55
import { InsightsList } from "./insights-list";
66
import { ScoreCard } from "./score-card";
7-
8-
type UserResult = {
9-
username: string;
10-
repoScore: number;
11-
prScore: number;
12-
contributionScore: number;
13-
finalScore: number;
14-
topRepos: { name?: string; stars?: number; forks?: number; score?: number }[];
15-
topPullRequests: { repo?: string; stars?: number; score?: number }[];
16-
insights?: string[];
17-
};
7+
import { Card, CardContent } from "./ui/card";
8+
import { Trophy } from "lucide-react";
9+
import { UserResult } from "@/types/user-result";
1810

1911
type Props = {
2012
user1: UserResult;
@@ -30,98 +22,112 @@ export function ResultDashboard({ user1, user2 }: Props) {
3022
: user2;
3123
const loser = winner === user1 ? user2 : user1;
3224
const diffPct = winner
33-
? Math.round(((winner.finalScore - loser.finalScore) / loser.finalScore) * 100)
25+
? Math.round(
26+
((winner.finalScore - loser.finalScore) / loser.finalScore) * 100,
27+
)
3428
: 0;
3529

30+
const getInsights = () => {
31+
const insights = [];
32+
if (user1.repoScore > user2.repoScore) {
33+
insights.push(
34+
`${user1.username} has stronger repository portfolio with ${user1.repoScore} vs ${user2.repoScore}`,
35+
);
36+
} else if (user2.repoScore > user1.repoScore) {
37+
insights.push(
38+
`${user2.username} has stronger repository portfolio with ${user2.repoScore} vs ${user1.repoScore}`,
39+
);
40+
} else {
41+
insights.push(`Both developers have equal repository strength`);
42+
}
43+
44+
if (user1.prScore > user2.prScore) {
45+
insights.push(
46+
`${user1.username} leads in pull request impact (${user1.prScore} vs ${user2.prScore})`,
47+
);
48+
} else if (user2.prScore > user1.prScore) {
49+
insights.push(
50+
`${user2.username} leads in pull request impact (${user2.prScore} vs ${user1.prScore})`,
51+
);
52+
} else {
53+
insights.push(`Both developers have equal pull request impact`);
54+
}
55+
56+
if (user1.contributionScore > user2.contributionScore) {
57+
insights.push(`${user1.username} shows higher contribution activity`);
58+
} else if (user2.contributionScore > user1.contributionScore) {
59+
insights.push(`${user2.username} shows higher contribution activity`);
60+
} else {
61+
insights.push(`Both developers have similar contribution levels`);
62+
}
63+
64+
return insights;
65+
};
66+
67+
const repoDiff =
68+
Math.max(user1.repoScore, user2.repoScore) -
69+
Math.min(user1.repoScore, user2.repoScore);
70+
const prDiff =
71+
Math.max(user1.prScore, user2.prScore) -
72+
Math.min(user1.prScore, user2.prScore);
73+
3674
return (
3775
<div className="space-y-6 animate-fadeIn">
38-
{/* Winner banner */}
39-
<div className="card p-6 flex flex-col gap-2 bg-gradient-to-r from-blue-500 via-indigo-500 to-purple-500 text-white shadow-lg">
40-
{winner ? (
41-
<>
42-
<p className="text-sm text-white/80">Metric</p>
43-
<h2 className="text-2xl font-semibold">
44-
🏆 {winner.username} wins
45-
</h2>
46-
<p className="text-sm text-white/80">
47-
{diffPct}%
48-
higher final score than
49-
{
50-
loser.username
51-
}
52-
</p>
53-
</>
54-
) : (
55-
<>
56-
<p className="text-sm text-white/80">Metric</p>
57-
<h2 className="text-xl font-semibold">It's a tie — both developers are evenly matched.</h2>
58-
</>
59-
)}
60-
</div>
76+
<Card className="border-2 border-primary/20 bg-gradient-to-r from-primary/10 via-primary/5 to-transparent">
77+
<CardContent className="flex items-center justify-between p-6">
78+
{winner ? (
79+
<>
80+
<div className="flex items-center gap-4">
81+
<div className="rounded-full bg-primary/20 p-3">
82+
<Trophy className="h-8 w-8 text-primary" />
83+
</div>
84+
<div>
85+
<p className="text-sm text-muted-foreground">Winner</p>
86+
<p className="text-3xl font-bold">{winner.username}</p>
87+
</div>
88+
</div>
89+
<div className="text-right">
90+
<p className="text-sm text-muted-foreground">Lead by</p>
91+
<p className="text-2xl font-bold text-primary">{diffPct}%</p>
92+
</div>
93+
</>
94+
) : (
95+
<>
96+
<p className="text-sm text-white/80">
97+
Metric
98+
</p>
99+
<h2 className="text-xl font-semibold">
100+
It's a tie — both developers are evenly matched.
101+
</h2>
102+
</>
103+
)}
104+
</CardContent>
105+
</Card>
61106

62-
{/* Score cards */}
63107
<div className="grid gap-4 md:grid-cols-4">
64108
<ScoreCard
65109
title={user1.username}
66110
value={user1.finalScore}
67-
highlight={winner?.username === user1.username}
111+
highlight={user1.isWinner}
68112
subtitle="Final score"
69113
/>
70114
<ScoreCard
71115
title={user2.username}
72116
value={user2.finalScore}
73-
highlight={winner?.username === user2.username}
117+
highlight={user2.isWinner}
74118
subtitle="Final score"
75119
/>
76-
<ScoreCard title="Repo diff" value={user1.repoScore - user2.repoScore} />
77-
<ScoreCard title="PR diff" value={user1.prScore - user2.prScore} />
120+
<ScoreCard title="Repo diff" value={repoDiff} />
121+
<ScoreCard title="PR diff" value={prDiff} />
78122
</div>
79123

80124
<ComparisonTable user1={user1} user2={user2} />
81-
82125
<ComparisonChart user1={user1} user2={user2} />
126+
<BreakdownBars user1={user1} user2={user2} />
83127

84-
<div className="grid gap-4 md:grid-cols-2">
85-
<BreakdownBars user={user1} />
86-
<BreakdownBars user={user2} />
87-
</div>
128+
<TopList userResults={[user1, user2]} />
88129

89-
<div className="grid gap-4 md:grid-cols-2">
90-
<TopList
91-
title={`${user1.username} — Top repos`}
92-
items={user1.topRepos || []}
93-
variant="repo"
94-
/>
95-
<TopList
96-
title={`${user2.username} — Top repos`}
97-
items={user2.topRepos || []}
98-
variant="repo"
99-
/>
100-
</div>
101-
102-
<div className="grid gap-4 md:grid-cols-2">
103-
<TopList
104-
title={`${user1.username} — Top PRs`}
105-
items={user1.topPullRequests || []}
106-
variant="pr"
107-
/>
108-
<TopList
109-
title={`${user2.username} — Top PRs`}
110-
items={user2.topPullRequests || []}
111-
variant="pr"
112-
/>
113-
</div>
114-
115-
<div className="grid gap-4 md:grid-cols-2">
116-
<InsightsList
117-
title={`${user1.username} insights`}
118-
insights={user1.insights || []}
119-
/>
120-
<InsightsList
121-
title={`${user2.username} insights`}
122-
insights={user2.insights || []}
123-
/>
124-
</div>
130+
<InsightsList insights={getInsights()} />
125131
</div>
126132
);
127133
}

0 commit comments

Comments
 (0)