Skip to content

Commit 5d5e4d5

Browse files
CopilotAdez017
andcommitted
Add mock data for testing PR list modal functionality
Co-authored-by: Adez017 <[email protected]>
1 parent 588893b commit 5d5e4d5

File tree

2 files changed

+122
-5
lines changed

2 files changed

+122
-5
lines changed

src/components/dashboard/LeaderBoard/leaderboard.tsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { ChevronRight, ChevronLeft } from "lucide-react";
1313
import { useColorMode } from "@docusaurus/theme-common";
1414
import { useCommunityStatsContext } from "@site/src/lib/statsProvider";
1515
import PRListModal from "./PRListModal";
16+
import { mockContributors } from "./mockData";
1617
import "./leaderboard.css";
1718

1819
const GITHUB_ORG = "recodehive";
@@ -150,8 +151,11 @@ export default function LeaderBoard(): JSX.Element {
150151
setSelectedContributor(null);
151152
};
152153

154+
// Use mock data when there's an error or no contributors
155+
const displayContributors = error || contributors.length === 0 ? mockContributors : contributors;
156+
153157
// Filter out excluded users and then apply search filter
154-
const filteredContributors = contributors
158+
const filteredContributors = displayContributors
155159
.filter((contributor) =>
156160
!EXCLUDED_USERS.some(excludedUser =>
157161
contributor.username.toLowerCase() === excludedUser.toLowerCase()
@@ -282,7 +286,7 @@ export default function LeaderBoard(): JSX.Element {
282286
</motion.div>
283287

284288
{/* Top 3 Performers Section */}
285-
{!loading && !error && filteredContributors.length > 2 && (
289+
{!loading && filteredContributors.length > 2 && (
286290
<div className="top-performers-container">
287291
<h2 className={`top-performers-title ${isDark ? "dark" : "light"}`}>RecodeHive Top Performers</h2>
288292
<div className="top-performers-grid">
@@ -372,20 +376,33 @@ export default function LeaderBoard(): JSX.Element {
372376
</div>
373377
)}
374378

375-
{error && (
379+
{error && displayContributors.length === 0 && (
376380
<div className="no-contributors">
377381
<p>Error: {error}</p>
378382
</div>
379383
)}
380384

381-
{!loading && !error && filteredContributors.length === 0 && (
385+
{!loading && filteredContributors.length === 0 && (
382386
<div className="no-contributors">
383387
<p>No contributors found.</p>
384388
</div>
385389
)}
386390

387-
{!loading && !error && filteredContributors.length > 0 && (
391+
{!loading && filteredContributors.length > 0 && (
388392
<div className={`contributors-container ${isDark ? "dark" : "light"}`}>
393+
{error && (
394+
<div className="error-banner" style={{
395+
padding: '12px',
396+
backgroundColor: isDark ? '#fee8e7' : '#fee8e7',
397+
color: '#dc2626',
398+
borderRadius: '8px',
399+
marginBottom: '16px',
400+
fontSize: '14px',
401+
textAlign: 'center'
402+
}}>
403+
Demo Mode: Showing sample data due to API configuration issue
404+
</div>
405+
)}
389406
<div className="contributors-header">
390407
<div className="contributor-cell rank">Rank</div>
391408
<div className="contributor-cell avatar-cell">Avatar</div>
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// Temporary mock data for testing the PR list modal functionality
2+
export const mockContributors = [
3+
{
4+
username: "testuser1",
5+
avatar: "https://github.com/testuser1.png",
6+
profile: "https://github.com/testuser1",
7+
points: 50,
8+
prs: 5,
9+
prDetails: [
10+
{
11+
title: "Add new feature: user authentication system",
12+
url: "https://github.com/recodehive/repo1/pull/123",
13+
mergedAt: "2024-01-15T10:30:00Z",
14+
repoName: "auth-service",
15+
number: 123
16+
},
17+
{
18+
title: "Fix: resolve security vulnerability in login flow",
19+
url: "https://github.com/recodehive/repo1/pull/124",
20+
mergedAt: "2024-01-14T14:22:00Z",
21+
repoName: "auth-service",
22+
number: 124
23+
},
24+
{
25+
title: "Update documentation for API endpoints",
26+
url: "https://github.com/recodehive/repo2/pull/45",
27+
mergedAt: "2024-01-13T09:15:00Z",
28+
repoName: "api-docs",
29+
number: 45
30+
},
31+
{
32+
title: "Implement dark mode toggle component",
33+
url: "https://github.com/recodehive/repo3/pull/67",
34+
mergedAt: "2024-01-12T16:45:00Z",
35+
repoName: "ui-components",
36+
number: 67
37+
},
38+
{
39+
title: "Optimize database queries for better performance",
40+
url: "https://github.com/recodehive/repo1/pull/125",
41+
mergedAt: "2024-01-11T11:30:00Z",
42+
repoName: "backend-core",
43+
number: 125
44+
}
45+
]
46+
},
47+
{
48+
username: "testuser2",
49+
avatar: "https://github.com/testuser2.png",
50+
profile: "https://github.com/testuser2",
51+
points: 30,
52+
prs: 3,
53+
prDetails: [
54+
{
55+
title: "Add responsive design to landing page",
56+
url: "https://github.com/recodehive/repo4/pull/89",
57+
mergedAt: "2024-01-10T13:20:00Z",
58+
repoName: "frontend-website",
59+
number: 89
60+
},
61+
{
62+
title: "Fix mobile navigation menu issue",
63+
url: "https://github.com/recodehive/repo4/pull/90",
64+
mergedAt: "2024-01-09T08:45:00Z",
65+
repoName: "frontend-website",
66+
number: 90
67+
},
68+
{
69+
title: "Add unit tests for utility functions",
70+
url: "https://github.com/recodehive/repo5/pull/12",
71+
mergedAt: "2024-01-08T15:30:00Z",
72+
repoName: "utils-library",
73+
number: 12
74+
}
75+
]
76+
},
77+
{
78+
username: "testuser3",
79+
avatar: "https://github.com/testuser3.png",
80+
profile: "https://github.com/testuser3",
81+
points: 20,
82+
prs: 2,
83+
prDetails: [
84+
{
85+
title: "Update README with installation instructions",
86+
url: "https://github.com/recodehive/repo6/pull/23",
87+
mergedAt: "2024-01-07T12:15:00Z",
88+
repoName: "documentation",
89+
number: 23
90+
},
91+
{
92+
title: "Add error handling for API failures",
93+
url: "https://github.com/recodehive/repo7/pull/34",
94+
mergedAt: "2024-01-06T10:00:00Z",
95+
repoName: "error-handling",
96+
number: 34
97+
}
98+
]
99+
}
100+
];

0 commit comments

Comments
 (0)