diff --git a/packages/nextjs/app/_components/EcosystemGrants.tsx b/packages/nextjs/app/_components/EcosystemGrants.tsx index f0b7835..f261ef3 100644 --- a/packages/nextjs/app/_components/EcosystemGrants.tsx +++ b/packages/nextjs/app/_components/EcosystemGrants.tsx @@ -1,4 +1,5 @@ import Image from "next/image"; +import ecosystemGrants from "~~/services/database/ecosystemGrants.json"; const EcosystemGrantsCard = ({ title, @@ -16,7 +17,7 @@ const EcosystemGrantsCard = ({ return (
- {title} + {title}

{title}

@@ -27,7 +28,7 @@ const EcosystemGrantsCard = ({
Amount: - {amountGranted} + {amountGranted} ETH
Twitter @@ -48,30 +49,16 @@ export const EcosystemGrants = () => {
- {/* Jessy's Hacker House */} - - {/* Solidty By Example */} - - {/* Winter */} - + {ecosystemGrants.grants.map((grant, index) => ( + + ))}
diff --git a/packages/nextjs/app/_components/GrantsStats.tsx b/packages/nextjs/app/_components/GrantsStats.tsx index 0a19213..86eb251 100644 --- a/packages/nextjs/app/_components/GrantsStats.tsx +++ b/packages/nextjs/app/_components/GrantsStats.tsx @@ -1,40 +1,37 @@ import Image from "next/image"; +import ecosystemGrants from "~~/services/database/ecosystemGrants.json"; import { getGrantsStats } from "~~/services/database/grants"; +const Stat = ({ label, imgLink, value }: { label: string; imgLink: string; value: string | number }) => { + return ( +
+
+ {label} +

{value}

+
+

{label}

+
+ ); +}; + export const GrantsStats = async () => { const stats = await getGrantsStats(); + + const sum = ecosystemGrants.grants.reduce( + (acc, grant) => acc + parseFloat(grant.amountGranted), + stats.total_eth_granted, + ); + const totalEthGranted = Number.isInteger(sum) ? sum : sum.toFixed(2); + + const totalGrants = ecosystemGrants.grants.length + stats.total_grants; + return (
-
-
-
- diamon icon -

{stats.total_completed_grants}

-
-

Total Grants

-
-
-
- diamon icon -

{stats.total_grants}

-
-

Submissions

-
-
-
- diamon icon -

{stats.total_eth_granted}

-
-

ETH Granted

-
-
-
- diamon icon -

{stats.total_active_grants}

-
-

Active Grants

-
+
+ + +
diff --git a/packages/nextjs/public/assets/stats-active.png b/packages/nextjs/public/assets/stats-active.png new file mode 100644 index 0000000..86fcd06 Binary files /dev/null and b/packages/nextjs/public/assets/stats-active.png differ diff --git a/packages/nextjs/public/assets/stats-eth-granted.png b/packages/nextjs/public/assets/stats-eth-granted.png new file mode 100644 index 0000000..10c7add Binary files /dev/null and b/packages/nextjs/public/assets/stats-eth-granted.png differ diff --git a/packages/nextjs/public/assets/stats-total.png b/packages/nextjs/public/assets/stats-total.png new file mode 100644 index 0000000..bac46eb Binary files /dev/null and b/packages/nextjs/public/assets/stats-total.png differ diff --git a/packages/nextjs/services/database/ecosystemGrants.json b/packages/nextjs/services/database/ecosystemGrants.json new file mode 100644 index 0000000..55879ed --- /dev/null +++ b/packages/nextjs/services/database/ecosystemGrants.json @@ -0,0 +1,25 @@ +{ + "grants": [ + { + "name": "Jessy's Hacker House", + "description": "Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint cillum sint consectetur cupidatat.Lorem ipsum dolor sit amet, qui minim labore adipisicing.", + "amountGranted": "14", + "twitterLink": "https://twitter.com/wehack247", + "imgLink": "/assets/jessy-hacker-house.png" + }, + { + "name": "Solidity By Example", + "description": "Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint cillum sint consectetur cupidatat.Lorem ipsum dolor sit amet, qui minim labore adipisicing.", + "amountGranted": "1", + "twitterLink": "https://twitter.com/ProgrammerSmart", + "imgLink": "/assets/solidity-by-example.png" + }, + { + "name": "W1nt3r", + "description": "Lorem ipsum dolor sit amet, officia excepteur ex fugiat reprehenderit enim labore culpa sint ad nisi Lorem pariatur mollit ex esse exercitation amet.", + "amountGranted": "1", + "twitterLink": "https://x.com/w1nt3r_eth", + "imgLink": "/assets/winter.png" + } + ] +} diff --git a/packages/nextjs/services/database/grants.ts b/packages/nextjs/services/database/grants.ts index 4102253..de17fb4 100644 --- a/packages/nextjs/services/database/grants.ts +++ b/packages/nextjs/services/database/grants.ts @@ -99,25 +99,22 @@ export const reviewGrant = async (grantId: string, action: ProposalStatusType) = }; export const getGrantsStats = async () => { - // Summation of askAmount for completed grants: total_eth_granted - // Total number of completed grants : total_completed_grants - // Total number of submitted grants all grants : total_submitted_grants - // Total number of Active grants (approved): total_active_grants + // total_eth_granted is the summation of askAmount of all completed grants + // total_active_grants is the count of grants with status "approved" + // total_grants is the summation of completed and active grants try { - const copmltedGrants = await getAllCompletedGrants(); - const total_eth_granted = copmltedGrants.reduce((acc, grant) => acc + grant.askAmount, 0); - const total_completed_grants = copmltedGrants.length; - - const allGrantsSnapshot = await grantsCollection.get(); - const total_grants = allGrantsSnapshot.size; + const completedGrants = await getAllCompletedGrants(); + const total_eth_granted = completedGrants.reduce((acc, grant) => acc + grant.askAmount, 0); + const total_completed_grants = completedGrants.length; const approvedGrantsSnapshot = await grantsCollection.where("status", "==", PROPOSAL_STATUS.APPROVED).get(); const total_active_grants = approvedGrantsSnapshot.size; + const total_grants = total_completed_grants + total_active_grants; + return { total_grants, total_eth_granted, - total_completed_grants, total_active_grants, }; } catch (error) {