From ae489f4b5fdc5bd96ab52904be867024eb00cf7b Mon Sep 17 00:00:00 2001 From: d3v1l0n Date: Wed, 25 Dec 2024 09:59:26 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20donation=20monthly=20to?= =?UTF-8?q?=20one=20time?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/donate/KeySponsors.tsx | 145 ++++++++++++++++----- src/components/donate/SponsorshipStats.tsx | 12 +- src/components/donate/SponsorshipTiers.tsx | 26 ++-- 3 files changed, 135 insertions(+), 48 deletions(-) diff --git a/src/components/donate/KeySponsors.tsx b/src/components/donate/KeySponsors.tsx index 2fd4d203..cce34375 100644 --- a/src/components/donate/KeySponsors.tsx +++ b/src/components/donate/KeySponsors.tsx @@ -13,8 +13,30 @@ const keySponsors = [ description: 'Strategic Development Partner', amount: '₹54,399.36', // Example of amount, could be fetched or hardcoded }, + { + username: 'SkullSync', // GitHub username + description: 'Strategic Development Partner', + amount: '₹12,181.36', // Example of amount, could be fetched or hardcoded + }, ]; +// Dummy list of individual donors with GitHub usernames +const individualDonors = [ + { + username: 'd3v1l0n', // GitHub username + amount: '₹4,183.00', // Example of donation amount + }, + { + username: 'myself-meghna', // GitHub username + amount: '₹8,554', // Example of donation amount + }, + { + username: 'lawrencecracker', // GitHub username + amount: '₹3,220', // Example of donation amount + }, +]; + +// Fetch GitHub user data async function fetchGitHubUser(username: string) { const response = await fetch(`https://api.github.com/users/${username}`); const data = await response.json(); @@ -23,58 +45,113 @@ async function fetchGitHubUser(username: string) { export function KeySponsors() { const [sponsorsData, setSponsorsData] = useState([]); + const [donorsData, setDonorsData] = useState([]); + // Fetch sponsor and donor data from GitHub useEffect(() => { - const fetchSponsorsData = async () => { + const fetchSponsorsAndDonorsData = async () => { + // Fetching data for sponsors const sponsorsWithData = await Promise.all( keySponsors.map(async (sponsor) => { const user = await fetchGitHubUser(sponsor.username); return { ...sponsor, - name: user.name || sponsor.username, // Use GitHub name or fallback to username - avatar_url: user.avatar_url, // Fetch the GitHub profile picture + name: user.name || sponsor.username, + avatar_url: user.avatar_url, // Fetch GitHub profile picture }; }) ); setSponsorsData(sponsorsWithData); + + // Fetching data for donors + const donorsWithData = await Promise.all( + individualDonors.map(async (donor) => { + const user = await fetchGitHubUser(donor.username); + return { + ...donor, + name: user.name || donor.username, + avatar_url: user.avatar_url, // Fetch GitHub profile picture + }; + }) + ); + setDonorsData(donorsWithData); }; - fetchSponsorsData(); + fetchSponsorsAndDonorsData(); }, []); return ( -
-

- Key Sponsors -

-
- {sponsorsData.map((sponsor, index) => ( - -
-
- {/* Displaying the profile picture */} - {sponsor.name} +
+ {/* Key Sponsors Section */} +
+

+ Key Sponsors +

+
+ {sponsorsData.map((sponsor, index) => ( + +
+
+ {/* Displaying the profile picture */} + {sponsor.name} +
+
+

{sponsor.name}

+

{sponsor.description}

+

+ Amount: {sponsor.amount} +

+
-
-

{sponsor.name}

-

{sponsor.description}

-

- Amount: {sponsor.amount} -

+ + ))} +
+
+ + {/* Individual Donors Section */} +
+

+ Individual Donors +

+
+ {donorsData.map((donor, index) => ( + +
+
+ {/* Displaying the profile picture */} + {donor.name} +
+
+

{donor.name}

+

Generous Individual Donor

+

+ Amount: {donor.amount} +

+
-
- - ))} + + ))} +
); diff --git a/src/components/donate/SponsorshipStats.tsx b/src/components/donate/SponsorshipStats.tsx index be10f1df..c9031ae3 100644 --- a/src/components/donate/SponsorshipStats.tsx +++ b/src/components/donate/SponsorshipStats.tsx @@ -1,23 +1,23 @@ import { motion } from 'framer-motion'; import { Users, Star, Heart } from 'lucide-react'; -import { formatINR } from '@/lib/currency'; +import { formatINR } from '../../lib/currency'; const stats = [ { - label: 'Current Sponsors', - value: '50+', + label: 'Total Sponsors', + value: '6+', icon: Users, color: 'text-blue-500' }, { - label: 'Monthly Support', - value: formatINR(200000), + label: 'Total Support', + value: formatINR(164563.08), icon: Heart, color: 'text-red-500' }, { label: 'GitHub Stars', - value: '1.2K+', + value: '200+', icon: Star, color: 'text-yellow-500' } diff --git a/src/components/donate/SponsorshipTiers.tsx b/src/components/donate/SponsorshipTiers.tsx index 9c58027b..a35e5cb3 100644 --- a/src/components/donate/SponsorshipTiers.tsx +++ b/src/components/donate/SponsorshipTiers.tsx @@ -1,11 +1,14 @@ import { motion } from 'framer-motion'; import { Check } from 'lucide-react'; -import { formatINR } from '@/lib/currency'; +import { formatINR } from '../../lib/currency'; + +// Hardcoded conversion rate (you can replace this with dynamic data) +const INR_TO_USD_CONVERSION_RATE = 0.012; const tiers = [ { name: 'Community Hero', - amount: 399, + amount: 999, description: 'Support the ongoing development of Snigdha OS', benefits: [ 'Special recognition on our GitHub repository', @@ -15,7 +18,7 @@ const tiers = [ }, { name: 'Security Champion', - amount: 799, + amount: 2999, description: 'Help shape the future of security testing', benefits: [ 'All Community Hero benefits', @@ -27,7 +30,7 @@ const tiers = [ }, { name: 'Enterprise Partner', - amount: 1999, + amount: 5999, description: 'Perfect for organizations using Snigdha OS', benefits: [ 'All Security Champion benefits', @@ -39,6 +42,11 @@ const tiers = [ } ]; +// Function to convert INR to USD +const convertINRToUSD = (inrAmount: number) => { + return (inrAmount * INR_TO_USD_CONVERSION_RATE).toFixed(2); // Convert INR to USD with 2 decimal places +}; + export function SponsorshipTiers() { return (
@@ -65,7 +73,9 @@ export function SponsorshipTiers() {

{tier.name}

{formatINR(tier.amount)} - /month + / ₹ + ${convertINRToUSD(tier.amount)} + / USD

{tier.description}

@@ -80,7 +90,7 @@ export function SponsorshipTiers() { - Become a {tier.name} + Make a One-Time Donation ))}
); -} \ No newline at end of file +}