Skip to content

Commit

Permalink
improve api fetching and fix ui issue (#559)
Browse files Browse the repository at this point in the history
  • Loading branch information
HimanshuNarware authored Oct 10, 2024
2 parents 47125c6 + 6565ffb commit 91b4588
Show file tree
Hide file tree
Showing 6 changed files with 650 additions and 37 deletions.
72 changes: 37 additions & 35 deletions src/Component/Contributors.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,55 @@ import React, { useEffect, useState } from 'react';
import axios from 'axios';
import './Contributors.css';
import Preloader from './Preloader';
import data from '../DB/Contributor.json'

function Contributors() {
const [contributors, setContributors] = useState([]);
const [loading, setLoading] = useState(true);

useEffect(() => {
async function fetchContributors() {
let allContributors = [];
let page = 1;
// to improve the fetching speed
// useEffect(() => {
// async function fetchContributors() {
// let allContributors = [];
// let page = 1;

try {
while (true) {
const response = await axios.get(
`https://api.github.com/repos/HimanshuNarware/CareerZunction_Intern/contributors`,
{
params: {
per_page: 100,
page,
},
}
);
const data = response.data;
if (data.length === 0) {
break;
}
allContributors = [...allContributors, ...data];
page++;
}
setContributors(allContributors);
} catch (error) {
console.error('Error in fetching contributors:', error);
} finally {
setLoading(false);
}
}
fetchContributors();
}, []);
// try {
// while (true) {
// const response = await axios.get(
// `https://api.github.com/repos/HimanshuNarware/CareerZunction_Intern/contributors`,
// {
// params: {
// per_page: 100,
// page,
// },
// }
// );
// const data = response.data;
// if (data.length === 0) {
// break;
// }
// allContributors = [...allContributors, ...data];
// page++;
// }
// setContributors(allContributors);
// } catch (error) {
// console.error('Error in fetching contributors:', error);
// } finally {
// setLoading(false);
// }
// }
// fetchContributors();
// }, []);

if (loading) {
return <Preloader />;
}
// if (loading) {
// return <Preloader />;
// }

return (
<div className="contributors-container">
<h1 className="contributors-title">Our Contributors</h1>
<div className="contributors-grid">
{contributors.map((contributor) => (
{data.map((contributor) => (
<div key={contributor.id} className="contributor-card">
<a
href={contributor.html_url}
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Documetation/Internship/internpage.css
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ body {

@media screen and (max-width:683px) {
.internBox {
margin-top: -120px;
margin-top: -20px;
padding-top: 50px;

display: flex;
Expand Down
Loading

0 comments on commit 91b4588

Please sign in to comment.