diff --git a/frontend/src/components/Contributors.jsx b/frontend/src/components/Contributors.jsx new file mode 100644 index 0000000..c6a1c86 --- /dev/null +++ b/frontend/src/components/Contributors.jsx @@ -0,0 +1,152 @@ +import React, { useState, useEffect } from 'react'; +import { Github, Loader2 } from 'lucide-react'; + +const Contributors = () => { + const [contributors, setContributors] = useState([]); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + const fetchContributors = async () => { + try { + setLoading(true); + const response = await fetch('https://api.github.com/repos/RamakrushnaBiswal/PlayCafe/contributors'); + if (!response.ok) { + throw new Error('Failed to fetch contributors'); + } + const data = await response.json(); + + // Fetch additional user details for each contributor + const contributorsWithDetails = await Promise.all( + data.map(async (contributor) => { + const userResponse = await fetch(contributor.url); + const userData = await userResponse.json(); + return { + ...contributor, + name: userData.name || userData.login, + bio: userData.bio, + location: userData.location, + company: userData.company + }; + }) + ); + + setContributors(contributorsWithDetails); + setError(null); + } catch (err) { + setError(err.message); + } finally { + setLoading(false); + } + }; + + fetchContributors(); + }, []); + + if (error) { + return ( +
+
+
+ Error loading contributors: {error} +
+
+
+ ); + } + + return ( +
+ {/* Header Section */} +
+
+

+ + GitHub Contributors +

+ + {/* Gradient Bar */} +
+ +

+ Thanks to our amazing contributors who help build and improve this project! 🎉 +

+
+ + {/* Loading State */} + {loading ? ( +
+ +
+ ) : ( + /* Contributors List */ +
+ {contributors.map((contributor) => ( +
+ {contributor.login} +
+
+
+ + {contributor.name || contributor.login} + +

+ @{contributor.login} +

+
+ + {contributor.contributions} contributions + +
+ {(contributor.bio || contributor.location) && ( +
+ {contributor.bio &&

{contributor.bio}

} + {contributor.location && ( +

+ 📍 {contributor.location} +

+ )} +
+ )} +
+
+ ))} +
+ )} + + {/* Repository Link */} +
+
+ Explore more on our GitHub repository: +
+ + + Visit Repository + +
+ + {/* Bottom Gradient Bar */} +
+
+
+ ); +}; + +export default Contributors; \ No newline at end of file diff --git a/frontend/src/components/Shared/Navbar.jsx b/frontend/src/components/Shared/Navbar.jsx index 1b115ca..efda6ae 100644 --- a/frontend/src/components/Shared/Navbar.jsx +++ b/frontend/src/components/Shared/Navbar.jsx @@ -23,6 +23,7 @@ const Navbar = () => { { name: 'BOARDGAMES', path: '/boardgame' }, { name: 'MEMBERSHIP', path: '/membership' }, // Add Membership here { name: 'PROFILE', path: '/dashboard' }, // Add Membership here + { name: 'CONTRIBUTORS', path: '/contributors' }, ]; useEffect(() => { @@ -83,16 +84,15 @@ const Navbar = () => { return (