Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve api fetching and fix ui issue #559

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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