Skip to content
Open
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
55 changes: 24 additions & 31 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"axios": "^1.8.4",
"axios": "^1.9.0",
"lucide-react": "^0.501.0",
"moment": "^2.30.1",
"react": "^19.0.0",
Expand Down
7 changes: 7 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import React from 'react';
import Navbar from './components/Navbar';

// TODO: Import react router dom here
import {BrowserRouter as Router, Routes, Route} from 'react-router-dom';

import Footer from './components/Footer';
import './styles/App.css';
import Home from './pages/Home';
import Projects from './pages/Projects';

function App() {
return (
Expand All @@ -13,6 +16,10 @@ function App() {
<Navbar />
<main className="main-content">
{/* TODO: Add react router dom routes here */}
<Routes>
<Route path='/' element={<Home/>}/>
<Route path='/projects' element={<Projects/>}/>
</Routes>

</main>
<Footer />
Expand Down
4 changes: 4 additions & 0 deletions src/components/Navbar.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React from 'react';

// TODO: Import LINK from react router dom components
import { Link } from 'react-router-dom';
import { useLocation } from 'react-router-dom'


import { Github } from 'lucide-react';
import '../styles/Navbar.css';

Expand All @@ -20,9 +22,11 @@ const Navbar = () => {
<ul className="navbar-menu">
<li className="navbar-item">
{/* TODO: Add the home route here */}
<Link to="/">Home</Link>
</li>
<li className="navbar-item">
{/* TODO: Add the projects route here */}
<Link to="/projects">Projects</Link>
</li>
</ul>
</div>
Expand Down
23 changes: 23 additions & 0 deletions src/pages/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ import { Link } from 'react-router-dom';

// TODO: Import axios here



import moment from 'moment';
import { Users, Star, GitBranch, MapPin, Calendar, ExternalLink } from 'lucide-react';
import '../styles/Home.css';
import axios from 'axios';

const Home = () => {
const [user, setUser] = useState(null);
Expand All @@ -15,6 +18,26 @@ const Home = () => {
// TODO: Fetch user data from GitHub API using axios and useEffect and set the user state, also handle the loading and error states
// API: https://api.github.com/users/YOUR_USERNAME

useEffect(()=>{
const FetchUser= async()=>{
try{
setLoading(true)
const response = await axios.get("https://api.github.com/users/ikran123")
setUser(response.data);


} catch (error){
setError("failed to fetch the user")
console.error(error);
} finally{
setLoading(false)
}
};
FetchUser();
}, []);





if (loading) {
Expand Down
21 changes: 21 additions & 0 deletions src/pages/Projects.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState, useEffect } from 'react';

// TODO: Import axios here
import axios from 'axios';


import ProjectCard from '../components/ProjectCard';
Expand All @@ -14,6 +15,26 @@ const Projects = () => {
// TODO: Fetch repositories from GitHub API using axios and useEffect and set the repos state, also handle the loading and error states
// API: https://api.github.com/users/YOUR_GITHUB_USERNAME/repos?per_page=10&sort=updated

useEffect(()=>{
const fetchRepos = async() =>{
try{
setLoading(true);
const response = await axios.get("https://api.github.com/users/ikran123/repos?per_page=10&sort=updated")
setRepos(response.data);
}catch (error){
setError('failed fetch error');
console.error(error);
}finally{
setLoading(false);
}
}
fetchRepos()

}, []);






if (loading) {
Expand Down