-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6049fb
commit 100dce5
Showing
5 changed files
with
187 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ yarn-error.log* | |
|
||
# local env files | ||
.env*.local | ||
.env | ||
|
||
# vercel | ||
.vercel | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { promises as fs } from 'fs'; | ||
import path from 'path'; | ||
|
||
export async function GET() { | ||
try { | ||
const csvFilePath = path.join(process.cwd(), 'public', 'module_rewards.csv'); | ||
const data = await fs.readFile(csvFilePath, 'utf8'); | ||
const lines = data.trim().split('\n'); | ||
const headers = lines[0].split(','); | ||
const contributors = lines.slice(1).map((line) => { | ||
const values = line.split(','); | ||
const contributor = {}; | ||
headers.forEach((header, index) => { | ||
contributor[header.trim()] = values[index] ? values[index].trim() : null; | ||
}); | ||
|
||
// Map to unified structure | ||
return { | ||
username: contributor.username, | ||
avatar: null, | ||
wallet_address: contributor.wallet_address, | ||
rewards: contributor.rewards, | ||
contributions: contributor.contributions, | ||
}; | ||
}); | ||
|
||
return new Response(JSON.stringify(contributors), { | ||
status: 200, | ||
headers: { 'Content-Type': 'application/json' } | ||
}); | ||
} catch (error) { | ||
console.error('Error reading CSV file:', error); | ||
return new Response('Error reading CSV file', { status: 500 }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { useState, useEffect } from "react"; | ||
|
||
const ContributionList = ({ contributions }) => { | ||
const [titles, setTitles] = useState([]); | ||
|
||
useEffect(() => { | ||
const fetchTitles = async () => { | ||
const fetchedTitles = await Promise.all( | ||
contributions.split(";").map(async (contribution) => { | ||
try { | ||
const apiUrl = contribution | ||
.replace('https://github.com/', 'https://api.github.com/repos/') | ||
.replace('/pull/', '/pulls/'); | ||
|
||
|
||
const res = await fetch(apiUrl); | ||
if (!res.ok) { | ||
throw new Error(`Error ${res.status}: ${res.statusText}`); | ||
} | ||
const data = await res.json(); | ||
return data.title || "Unknown Title"; | ||
} catch (error) { | ||
console.error(`Error fetching title for ${contribution}:`, error); | ||
return "Error Loading Title"; | ||
} | ||
}) | ||
); | ||
setTitles(fetchedTitles); | ||
}; | ||
|
||
|
||
fetchTitles(); | ||
}, [contributions]); | ||
|
||
return ( | ||
<ul> | ||
{contributions && contributions.split(";").map((contribution, index) => ( | ||
<li key={index}> | ||
<a href={contribution} target="_blank" rel="noopener noreferrer"> | ||
{titles[index] !== undefined | ||
? `${index + 1}. ${titles[index]}` | ||
: "Loading..."} | ||
</a> | ||
</li> | ||
))} | ||
</ul> | ||
); | ||
}; | ||
|
||
export default ContributionList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
username,github,wallet_address,rewards,contributions |