Skip to content

Commit 7a3316c

Browse files
committed
adding following section
1 parent 08e615d commit 7a3316c

9 files changed

Lines changed: 180 additions & 17 deletions

File tree

src/App.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const App = () => {
1616

1717
<div className=" bg-gradient-to-b from-primary-100 flex flex-col gap-12 justify-center items-center ">
1818
<BrowserRouter>
19-
<Title />
19+
2020

2121
<Routes>
2222
<Route

src/components/Dashboard.jsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Navbar from "../pages/Navbar";
77

88
import LoadingSpin from "./mini/LoadingSpin";
99
import InfoContainer from "./InfoContainer";
10+
import FollowingContainer from "./FollowingContainer";
1011

1112
const Dashboard = () => {
1213
const {isAuthenticated,isLoading} = useAuth0()
@@ -16,15 +17,22 @@ if(isLoading){
1617
}
1718
if(isAuthenticated)
1819
return (
19-
<div>
20-
<div className="top"></div>
20+
<div className="flex flex-col gap-5 mb-8">
21+
<div className="top">
2122
<Navbar />
2223
<SearchBox />
23-
<div className="data">
24+
</div>
25+
26+
<div className="data flex flex-col justify-center items-center">
2427
<UserCard />
25-
<InfoContainer/>
26-
<FollowerContainer />
27-
</div>
28+
<InfoContainer/>
29+
</div>
30+
31+
<div className="follow-container flex flex-wrap justify-center gap-3">
32+
<FollowerContainer />
33+
<FollowingContainer/>
34+
</div>
35+
2836
</div>
2937
);
3038
};
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
3+
import {useContext} from 'react'
4+
import FollowingCard from "./mini/FollowingCard";
5+
6+
7+
8+
import SearchContext from '../controller/context/SearchContext';
9+
10+
11+
12+
const FollowingContainer = () => {
13+
14+
const contextObject = useContext(SearchContext)
15+
const isFound = contextObject.isFound
16+
const gitFollowing = contextObject.gitFollowing
17+
18+
if(isFound){
19+
20+
21+
return (
22+
23+
<div className="w-max m-2 flex flex-col justify-center">
24+
<h1 className="text-primary-950 bg-primary-100 w-max px-3 py-1 xsm:pl-8">Following</h1>
25+
<div className=" overflow-scroll bg-primary-100 h-96 justify-center items-start">
26+
<div className="flex flex-col gap-2 ">
27+
28+
{
29+
30+
31+
gitFollowing?.map((item)=>{
32+
33+
return( <FollowingCard {...item} key={item.id} />)
34+
35+
36+
37+
})
38+
39+
}
40+
</div>
41+
</div>
42+
43+
</div>
44+
45+
);
46+
}
47+
};
48+
export default FollowingContainer;

src/components/SearchBox.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const SearchBox = () => {
4545
<button
4646
type="submit"
4747
onClick={handleSubmit}
48-
className="bg-primary-500 h-full text-primary-900 py-2 px-2 xsm:rounded-full "
48+
className="bg-primary-500 h-full text-primary-900 py-2 px-2 sm:rounded-full "
4949
>
5050
{<BiSearch className="animate-bounce" />}{" "}
5151
</button>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
3+
4+
const FollowingCard = ({login,avatar_url,html_url}) => {
5+
return (
6+
<div className=" flex gap-2 items-center p-1 ">
7+
8+
<div className="img rounded-full">
9+
<img src={avatar_url} alt="profile-photo" className="w-16 rounded-full object-fill" />
10+
</div>
11+
<div className="text">
12+
<h1 className="text-lg xsm:text-sm text-poppins text-primary-950">{login}</h1>
13+
<a href={html_url} className="text-blue xsm:text-sm">{html_url} </a>
14+
</div>
15+
</div>
16+
)
17+
}
18+
export default FollowingCard

src/controller/SearchLogic.jsx

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useState,useEffect } from "react";
22
import SearchContext from "./context/SearchContext";
33
import follower from "./defaults/follower";
44
import user from "./defaults/user";
5+
import following from "./defaults/following";
56

67

78

@@ -12,6 +13,8 @@ const SearchLogic = ({ children }) => {
1213

1314
const [gitUser, setGitUser] = useState(user);
1415
const [gitFollower, setGitFollower] = useState(follower);
16+
const [gitFollowing, setGitFollowing] = useState(following);
17+
1518
const [isLoading, setIsLoading] = useState(false)
1619
const [isFound, setIsFound] = useState(true)
1720

@@ -54,12 +57,30 @@ const SearchLogic = ({ children }) => {
5457
console.log(err);
5558
});
5659

57-
// if(gitFollowerFetchedData.message ==='Not Found'){
58-
// setIsFound(false)
59-
// setIsLoading(false)
60-
// }
60+
6161
setGitFollower(gitFollowerFetchedData);
6262

63+
64+
65+
// fetched following
66+
const gitFollowingFetchedData = await fetch(
67+
`${baseUrl}/${userName}/following`
68+
)
69+
.then((res) => {
70+
if(res.status == 404){
71+
setIsFound(false)
72+
return null
73+
}
74+
setIsFound(true)
75+
return res.json();
76+
})
77+
.catch((err) => {
78+
setIsFound(false)
79+
console.log(err);
80+
});
81+
82+
83+
setGitFollowing(gitFollowingFetchedData);
6384
setIsLoading(false)
6485
};
6586

@@ -72,7 +93,7 @@ useEffect(()=>{
7293
},[])
7394

7495
return (
75-
<SearchContext.Provider value={{ SearchGithubUser, gitUser, gitFollower, isLoading,isFound }}>
96+
<SearchContext.Provider value={{ SearchGithubUser, gitUser, gitFollower,gitFollowing, isLoading,isFound }}>
7697
{children}
7798
</SearchContext.Provider>
7899
);
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
export default [
2+
{
3+
"login": "AkhilSharma90",
4+
"id": 26513717,
5+
"node_id": "MDQ6VXNlcjI2NTEzNzE3",
6+
"avatar_url": "https://avatars.githubusercontent.com/u/26513717?v=4",
7+
"gravatar_id": "",
8+
"url": "https://api.github.com/users/AkhilSharma90",
9+
"html_url": "https://github.com/AkhilSharma90",
10+
"followers_url": "https://api.github.com/users/AkhilSharma90/followers",
11+
"following_url": "https://api.github.com/users/AkhilSharma90/following{/other_user}",
12+
"gists_url": "https://api.github.com/users/AkhilSharma90/gists{/gist_id}",
13+
"starred_url": "https://api.github.com/users/AkhilSharma90/starred{/owner}{/repo}",
14+
"subscriptions_url": "https://api.github.com/users/AkhilSharma90/subscriptions",
15+
"organizations_url": "https://api.github.com/users/AkhilSharma90/orgs",
16+
"repos_url": "https://api.github.com/users/AkhilSharma90/repos",
17+
"events_url": "https://api.github.com/users/AkhilSharma90/events{/privacy}",
18+
"received_events_url": "https://api.github.com/users/AkhilSharma90/received_events",
19+
"type": "User",
20+
"site_admin": false
21+
},
22+
{
23+
"login": "john-smilga",
24+
"id": 42133389,
25+
"node_id": "MDQ6VXNlcjQyMTMzMzg5",
26+
"avatar_url": "https://avatars.githubusercontent.com/u/42133389?v=4",
27+
"gravatar_id": "",
28+
"url": "https://api.github.com/users/john-smilga",
29+
"html_url": "https://github.com/john-smilga",
30+
"followers_url": "https://api.github.com/users/john-smilga/followers",
31+
"following_url": "https://api.github.com/users/john-smilga/following{/other_user}",
32+
"gists_url": "https://api.github.com/users/john-smilga/gists{/gist_id}",
33+
"starred_url": "https://api.github.com/users/john-smilga/starred{/owner}{/repo}",
34+
"subscriptions_url": "https://api.github.com/users/john-smilga/subscriptions",
35+
"organizations_url": "https://api.github.com/users/john-smilga/orgs",
36+
"repos_url": "https://api.github.com/users/john-smilga/repos",
37+
"events_url": "https://api.github.com/users/john-smilga/events{/privacy}",
38+
"received_events_url": "https://api.github.com/users/john-smilga/received_events",
39+
"type": "User",
40+
"site_admin": false
41+
},
42+
{
43+
"login": "amreshify",
44+
"id": 127320834,
45+
"node_id": "U_kgDOB5bDAg",
46+
"avatar_url": "https://avatars.githubusercontent.com/u/127320834?v=4",
47+
"gravatar_id": "",
48+
"url": "https://api.github.com/users/amreshify",
49+
"html_url": "https://github.com/amreshify",
50+
"followers_url": "https://api.github.com/users/amreshify/followers",
51+
"following_url": "https://api.github.com/users/amreshify/following{/other_user}",
52+
"gists_url": "https://api.github.com/users/amreshify/gists{/gist_id}",
53+
"starred_url": "https://api.github.com/users/amreshify/starred{/owner}{/repo}",
54+
"subscriptions_url": "https://api.github.com/users/amreshify/subscriptions",
55+
"organizations_url": "https://api.github.com/users/amreshify/orgs",
56+
"repos_url": "https://api.github.com/users/amreshify/repos",
57+
"events_url": "https://api.github.com/users/amreshify/events{/privacy}",
58+
"received_events_url": "https://api.github.com/users/amreshify/received_events",
59+
"type": "User",
60+
"site_admin": false
61+
}
62+
]

src/pages/LoginButton.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import React from "react";
22
import {FcGoogle} from 'react-icons/fc'
33
import { useAuth0 } from "@auth0/auth0-react";
4+
import Title from "../components/mini/Title";
45

56
const LoginButton = () => {
67
const { loginWithRedirect ,isLoading,isAuthenticated} = useAuth0();
78

89

910
return <div className="flex flex-col m-1 justify-center items-center">
11+
<Title/>
1012
<div className="git p-1 px-2">
1113
<img src="/github.png" alt="git-logo" className="rounded-full object-fill w-56"/>
1214
</div>

src/pages/Navbar.jsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import React from "react";
22
import { useAuth0 } from "@auth0/auth0-react";
3+
import LoadingSpin from "../components/mini/LoadingSpin";
34

45

56
const Profile = () => {
67
const { user, isAuthenticated, isLoading,logout } = useAuth0();
78
const isUserExist = isAuthenticated && user
89
if (isLoading) {
9-
return <div>Loading ...</div>;
10+
return <div><LoadingSpin/></div>;
1011
}
1112
if(isUserExist){
1213
return (
1314
<>
14-
<h1 className="titile text-center m-2 p-1 font-bold text-xl text-primary-800"> Welcome {user?.name}</h1>
15-
<div className="flex justify-center items-center gap-2 bg-primary-200 p-1">
15+
<div className="flex justify-center items-center gap-2 bg-primary-200 py-1 px-2 ">
1616

1717
<div className="img">
1818
<img src={user?.picture} alt={user?.name} className="rounded-full w-14 " />
@@ -22,11 +22,15 @@ if(isUserExist){
2222
</div>
2323
<div className="logout-btn">
2424
<button className="px-2 py-1 bg-primary-800 text-primary-200 rounded-lg" onClick={() => logout({ logoutParams: { returnTo: window.location.origin } })}>
25-
Log Out
25+
Logout
2626
</button>
2727
</div>
2828

2929
</div>
30+
31+
<h1 className="titile text-center m-2 p-1 font-bold text-xl text-primary-800"> Welcome {user?.name}</h1>
32+
33+
3034
</>
3135
);
3236
}

0 commit comments

Comments
 (0)