Skip to content

Commit

Permalink
Merge pull request #836 from souvikpramanikgit/add-contributor
Browse files Browse the repository at this point in the history
Add Contributor Page
  • Loading branch information
manikumarreddyu authored Nov 7, 2024
2 parents 58de566 + e470ddc commit 7859ed4
Show file tree
Hide file tree
Showing 6 changed files with 317 additions and 0 deletions.
34 changes: 34 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@fortawesome/fontawesome-svg-core": "^6.x.x",
"@fortawesome/free-brands-svg-icons": "^6.6.0",
"@fortawesome/free-regular-svg-icons": "^6.6.0",
"@fortawesome/free-solid-svg-icons": "^6.6.0",
"@fortawesome/react-fontawesome": "^0.2.2",
Expand Down Expand Up @@ -40,6 +41,7 @@
"react": "^18.3.1",
"react-bootstrap": "^2.10.5",
"react-chartjs-2": "^5.2.0",
"react-countup": "^6.5.3",
"react-dom": "^18.3.1",
"react-fontawesome": "^1.7.1",
"react-icons": "^5.3.0",
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/MainContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import NotFound from './NotFound';
import Prices from './components/models/Prices';
import Reports from './components/models/Reports';
import AboutUs from "./components/AboutUs";
import Contributor from './pages/ContributorsPage';
import UseScrollToTop from './components/UseScrollToTop';
import Article from './pages/Article';
import TaskReminder from './components/tools/TaskReminder';
Expand Down Expand Up @@ -115,6 +116,7 @@ const MainContent = () => {
<Route path="/" element={<Home />} />
<Route path="/chatbot" element={<ChatBot />} />
<Route path="/contact" element={<Contact />} />
<Route path="/contributor" element={<Contributor />} />
<Route path="/about" element={<About />} />
<Route path="/crop" element={<Crop />} />
<Route path="/fertilizer" element={<Fertilizer />} />
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const Footer = () => {
const companyLinks = [
{ name: 'About Us', path: '/aboutus' },
{ name: 'Contact Us', path: '/contact' },
{ name: 'Contributors', path: '/contributor' },
];

// Define quick links
Expand Down
156 changes: 156 additions & 0 deletions frontend/src/pages/ContributorsPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
import React, { useEffect, useState } from 'react'
import '../styles/ContributorsPage.css';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faGithub } from '@fortawesome/free-brands-svg-icons'
import CountUp from 'react-countup'
import axios from 'axios'
const ContributorsPage = () => {
const [contributors, setContributors] = useState([])
const [repoStats, setRepoStats] = useState({})
const [loading, setLoading] = useState(true)
const fetchData = async () => {
try {
const contributorsResponse = await fetch(
'https://api.github.com/repos/manikumarreddyu/AgroTech-AI/contributors'
)
const contributorsData = await contributorsResponse.json()

const repoResponse = await fetch(
'https://api.github.com/repos/manikumarreddyu/AgroTech-AI'
)
const repoData = await repoResponse.json()

setContributors(contributorsData)
setRepoStats(repoData)
} catch (error) {
console.error('Error fetching data:', error)
setContributors([])
setRepoStats({})
} finally {
setLoading(false)
}
}

useEffect(() => {
fetchData()
}, [])

const renderStats = () => {
const contributorsCount = contributors.length
const stats = [
{ label: 'Contributors', value: contributorsCount, icon: 'users' },
{
label: 'Total Contributions',
value:
contributors.reduce(
(sum, contributor) => sum + contributor.contributions,
0
) || 0,
icon: 'git-commit',
},
{
label: 'GitHub Stars',
value: repoStats.stargazers_count || 0,
icon: 'star',
},
{
label: 'Forks',
value: repoStats.forks_count || 0,
icon: 'git-branch',
},
]

return (
<div className="contributor-stats-grid" id="statsGrid">
{stats.map((stat) => (
<div className="contributor-stat-card" key={stat.label}>
<div
className="contributor-icon"
dangerouslySetInnerHTML={{
__html: getIcon(stat.icon),
}}
/>
<h3>
<CountUp
start={0}
end={stat.value}
duration={3}
separator=","
/>
</h3>
<p>{stat.label}</p>
</div>
))}
</div>
)
}

const renderContributors = () => {
return (
<div
className="contributor-contributors-grid"
id="contributorsGrid"
>
{contributors.map((contributor) => (
<div
className="contributor-contributor-card"
key={contributor.login}
>
<img
src={contributor.avatar_url}
alt={contributor.login}
/>
<h3>{contributor.login}</h3>
<p>{contributor.type}</p>
<div className="contributor-contributions">
{contributor.contributions} Contributions
</div>
<div className="contributor-footer">
<a
href={contributor.html_url}
target="_blank"
rel="noopener noreferrer"
>
{getIcon('external-link')}
<FontAwesomeIcon icon={faGithub} />
</a>
{getIcon('github')}
</div>
</div>
))}
</div>
)
}

const getIcon = (name) => {
const icons = {
// svg icons
}
return icons[name] || ''
}

return (
<>
<section className=" dark:bg-slate-900">
<div className="contributor-contributors">
{loading ? (
<div id="loading" className="contributor-loading"></div>
) : (
<>
<h2 className="text-green-500">
Project Statistics
</h2>
{renderStats()}
<h2 className="text-green-700">
Meet Our Contributors
</h2>
{renderContributors()}
</>
)}
</div>
</section>
</>
)
}

export default ContributorsPage
Loading

0 comments on commit 7859ed4

Please sign in to comment.