Skip to content

Commit d5e4e8b

Browse files
renamed user profile page
1 parent a0455dc commit d5e4e8b

File tree

3 files changed

+64
-57
lines changed

3 files changed

+64
-57
lines changed

src/Routes/Router.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
1-
import { Navigate, Route, Routes } from "react-router-dom"
2-
import Home from "../pages/Home/Home"
3-
import About from "../pages/About/About"
4-
import Contact from "../pages/Contact/Contact"
5-
import Contributors from "../pages/Contributors/Contributors"
6-
import Signup from "../pages/Signup/Signup.tsx"
7-
import Login from "../pages/Login/Login.tsx"
8-
import UserProfile from "../pages/UserProfile/UserProfile.tsx"
9-
10-
1+
import { Navigate, Route, Routes } from "react-router-dom";
2+
import Home from "../pages/Home/Home";
3+
import About from "../pages/About/About";
4+
import Contact from "../pages/Contact/Contact";
5+
import Contributors from "../pages/Contributors/Contributors";
6+
import Signup from "../pages/Signup/Signup.tsx";
7+
import Login from "../pages/Login/Login.tsx";
8+
import ContributorProfile from "../pages/ContributorProfile/ContributorProfile.tsx";
119

1210
const Router = () => {
1311
return (
1412
<Routes>
15-
{/* Redirect from root (/) to the home page */}
13+
<Route path="/" element={<Home />} />
1614
<Route path="/signup" element={<Signup />} />
1715
<Route path="/login" element={<Login />} />
18-
<Route path="/" element={<Home />} />
1916
<Route path="/about" element={<About />} />
2017
<Route path="/contact" element={<Contact />} />
2118
<Route path="/contributors" element={<Contributors />} />
22-
<Route path="/user/:username" element={<UserProfile />} />
19+
<Route path="/contributor/:username" element={<ContributorProfile />} />
2320
</Routes>
2421
);
25-
};
22+
};
23+
2624
export default Router;

src/pages/UserProfile/UserProfile.tsx renamed to src/pages/ContributorProfile/ContributorProfile.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type PR = {
88
repository_url: string;
99
};
1010

11-
export default function UserProfile() {
11+
export default function ContributorProfile() {
1212
const { username } = useParams();
1313
const [profile, setProfile] = useState<any>(null);
1414
const [prs, setPRs] = useState<PR[]>([]);
@@ -23,7 +23,9 @@ export default function UserProfile() {
2323
const userData = await userRes.json();
2424
setProfile(userData);
2525

26-
const prsRes = await fetch(`https://api.github.com/search/issues?q=author:${username}+type:pr`);
26+
const prsRes = await fetch(
27+
`https://api.github.com/search/issues?q=author:${username}+type:pr`
28+
);
2729
const prsData = await prsRes.json();
2830
setPRs(prsData.items);
2931
} catch (error) {
@@ -43,12 +45,19 @@ export default function UserProfile() {
4345

4446
if (loading) return <div className="text-center mt-10">Loading...</div>;
4547

46-
if (!profile) return <div className="text-center mt-10 text-red-600">User not found.</div>;
48+
if (!profile)
49+
return (
50+
<div className="text-center mt-10 text-red-600">User not found.</div>
51+
);
4752

4853
return (
4954
<div className="max-w-3xl mx-auto mt-2 mb-2 p-4 bg-white dark:bg-gray-800 dark:text-white shadow-xl rounded-xl">
5055
<div className="text-center">
51-
<img src={profile.avatar_url} alt="Avatar" className="w-24 h-24 mx-auto rounded-full" />
56+
<img
57+
src={profile.avatar_url}
58+
alt="Avatar"
59+
className="w-24 h-24 mx-auto rounded-full"
60+
/>
5261
<h2 className="text-2xl font-bold mt-2">{profile.login}</h2>
5362
<p className="">{profile.bio}</p>
5463
<button

src/pages/Contributors/Contributors.tsx

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@ const ContributorsPage = () => {
7373
<Grid container spacing={4}>
7474
{contributors.map((contributor) => (
7575
<Grid item xs={12} sm={6} md={3} key={contributor.id}>
76-
<Link
77-
to={`/user/${contributor.login}`}
78-
style={{ textDecoration: "none" }}
79-
>
8076
<Card
8177
sx={{
8278
textAlign: "center",
@@ -93,46 +89,50 @@ const ContributorsPage = () => {
9389
},
9490
}}
9591
>
96-
<Avatar
97-
src={contributor.avatar_url}
98-
alt={contributor.login}
99-
sx={{ width: 100, height: 100, mx: "auto", mb: 2 }}
100-
/>
92+
<Link
93+
to={`/contributor/${contributor.login}`}
94+
style={{ textDecoration: "none" }}
95+
>
96+
<Avatar
97+
src={contributor.avatar_url}
98+
alt={contributor.login}
99+
sx={{ width: 100, height: 100, mx: "auto", mb: 2 }}
100+
/>
101+
<CardContent>
102+
<Typography variant="h6" sx={{ fontWeight: "bold" }}>
103+
{contributor.login}
104+
</Typography>
101105

102-
<CardContent>
103-
<Typography variant="h6" sx={{ fontWeight: "bold" }}>
104-
{contributor.login}
105-
</Typography>
106-
107-
<Typography variant="body2" color="text.secondary">
108-
{contributor.contributions} Contributions
109-
</Typography>
110-
{/*
111-
<Typography variant="body2" sx={{ mt: 2 }}>
112-
Thank you for your valuable contributions to our
113-
community!
114-
</Typography> */}
106+
<Typography variant="body2" color="text.secondary">
107+
{contributor.contributions} Contributions
108+
</Typography>
109+
{/*
110+
<Typography variant="body2" sx={{ mt: 2 }}>
111+
Thank you for your valuable contributions to our
112+
community!
113+
</Typography> */}
114+
</CardContent>
115+
</Link>
115116

116117
<Box sx={{ mt: 2 }}>
117-
<Button
118-
variant="contained"
119-
startIcon={<FaGithub />}
120-
href={contributor.html_url}
121-
target="_blank"
122-
sx={{
123-
backgroundColor: "#333333",
124-
color: "#FFFFFF",
125-
"&:hover": {
126-
backgroundColor: "#555555",
127-
},
128-
}}
129-
>
130-
GitHub Profile
131-
</Button>
118+
<Button
119+
variant="contained"
120+
startIcon={<FaGithub />}
121+
href={contributor.html_url}
122+
target="_blank"
123+
sx={{
124+
backgroundColor: "#333333",
125+
textTransform: "none",
126+
color: "#FFFFFF",
127+
"&:hover": {
128+
backgroundColor: "#555555",
129+
},
130+
}}
131+
>
132+
GitHub
133+
</Button>
132134
</Box>
133-
</CardContent>
134135
</Card>
135-
</Link>
136136
</Grid>
137137
))}
138138
</Grid>

0 commit comments

Comments
 (0)