diff --git a/index.html b/index.html
index e4b78ea..f275256 100644
--- a/index.html
+++ b/index.html
@@ -4,7 +4,7 @@
-
Vite + React + TS
+ GitHub Tracker
diff --git a/src/Routes/Router.tsx b/src/Routes/Router.tsx
index 91c2582..5daf98f 100644
--- a/src/Routes/Router.tsx
+++ b/src/Routes/Router.tsx
@@ -6,12 +6,14 @@ import Contact from "../pages/Contact/Contact"; // Import the Contact component
import Contributors from "../pages/Contributors/Contributors";
import Login from "../pages/Auth/Login";
import Signup from "../pages/Auth/Signup";
+import PRlist from "../components/PRlist";
const Router = () => {
return (
{/* Redirect from root (/) to the home page */}
} />
+ } />
} />
} />
} />
diff --git a/src/components/PRlist.tsx b/src/components/PRlist.tsx
new file mode 100644
index 0000000..2e06eb8
--- /dev/null
+++ b/src/components/PRlist.tsx
@@ -0,0 +1,118 @@
+import { useEffect, useState } from "react";
+import { useParams } from "react-router-dom";
+import {
+ Container,
+ Paper,
+ Box,
+ CircularProgress,
+ Alert,
+ Table,
+ TableBody,
+ TableCell,
+ TableContainer,
+ TableHead,
+ TableRow,
+ Link,
+} from "@mui/material";
+
+
+interface PR {
+ id: number;
+ title: string;
+ html_url: string;
+ repository_url: string;
+ state: string;
+ created_at: string;
+}
+
+
+const PRlist = () => {
+ const { gitusername } = useParams<{ gitusername: string }>();
+ const [prs, setPrs] = useState([]);
+ const [loading, setLoading] = useState(true);
+ const [error, setError] = useState("");
+
+ useEffect(() => {
+ if (gitusername) {
+ const fetchPRs = async () => {
+ setLoading(true);
+ setError("");
+ try {
+ // Fetch PRs from GitHub API (public repos only)
+ const response = await fetch(`https://api.github.com/search/issues?q=type:pr+author:${gitusername}+state:open`);
+ const data = await response.json();
+ setPrs(data.items || []);
+ } catch (err) {
+ console.error("Error fetching PRs:", err);
+ setError("Error fetching pull requests.");
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ fetchPRs();
+ }
+ }, [gitusername]);
+
+ const formatDate = (dateString: string): string => {
+ return new Date(dateString).toLocaleDateString();
+ };
+
+ return (
+
+
+ {gitusername && `You are viewing ${gitusername}'s Open Pull Requests`}
+ {error && {error}}
+
+ {loading ? (
+
+
+
+ ) : (
+
+
+
+
+ Title
+ Repository
+ State
+ Created
+
+
+
+ {prs.length > 0 ? (
+ prs.map((pr) => (
+
+
+
+ {pr.title}
+
+
+
+ {pr.repository_url.replace("https://api.github.com/repos/", "")}
+
+
+ {pr.state}
+
+
+ {formatDate(pr.created_at)}
+
+
+ ))
+ ) : (
+
+
+ No open pull requests found for {gitusername}.
+
+
+ )}
+
+
+
+ )}
+
+
+ );
+};
+
+export default PRlist;
diff --git a/src/pages/Home/Home.tsx b/src/pages/Home/Home.tsx
index cab0b7d..e5875f9 100644
--- a/src/pages/Home/Home.tsx
+++ b/src/pages/Home/Home.tsx
@@ -25,6 +25,7 @@ import {
import { useGitHubAuth } from "../../hooks/useGitHubAuth";
import { useGitHubData } from "../../hooks/useGitHubData";
import { usePagination } from "../../hooks/usePagination";
+import toast from "react-hot-toast";
const ROWS_PER_PAGE = 10;
@@ -82,6 +83,13 @@ const Home: React.FC = () => {
return new Date(dateString).toLocaleDateString();
};
+ // generates the shareable link
+ const generateSharableLink = () => {
+ const link = `${window.location.origin}/prs/${username}`;
+ window.navigator.clipboard.writeText(link);
+ toast.success("link copied to the clipboard");
+ };
+
// Filter data based on selected criteria
const filterData = (
data: GitHubItem[],
@@ -214,6 +222,14 @@ const Home: React.FC = () => {
+
State