From 31bc0c6a303922b71029865b7c8ec2ad52f46fd6 Mon Sep 17 00:00:00 2001 From: Tanmay Bajaj Date: Fri, 9 Dec 2022 21:40:22 +0530 Subject: [PATCH] restructure the PR list --- .../{mergedRequests.jsx => MergedCard.jsx} | 0 frontend/components/MergedList.jsx | 11 +++++ .../{pendingRequests.jsx => PendingCard.jsx} | 6 +-- frontend/components/PendingList.jsx | 11 +++++ frontend/pages/profile/index.jsx | 40 ++++++++++++++++--- 5 files changed, 59 insertions(+), 9 deletions(-) rename frontend/components/{mergedRequests.jsx => MergedCard.jsx} (100%) create mode 100644 frontend/components/MergedList.jsx rename frontend/components/{pendingRequests.jsx => PendingCard.jsx} (63%) create mode 100644 frontend/components/PendingList.jsx diff --git a/frontend/components/mergedRequests.jsx b/frontend/components/MergedCard.jsx similarity index 100% rename from frontend/components/mergedRequests.jsx rename to frontend/components/MergedCard.jsx diff --git a/frontend/components/MergedList.jsx b/frontend/components/MergedList.jsx new file mode 100644 index 0000000..6a18a84 --- /dev/null +++ b/frontend/components/MergedList.jsx @@ -0,0 +1,11 @@ +import MergedCard from "./MergedCard"; + +const MergedList= ({ list, callback }) => { + return ( + list.map((Card, i) => { + return ; + }) + ); +}; + +export default MergedList; diff --git a/frontend/components/pendingRequests.jsx b/frontend/components/PendingCard.jsx similarity index 63% rename from frontend/components/pendingRequests.jsx rename to frontend/components/PendingCard.jsx index 5164249..3a66100 100644 --- a/frontend/components/pendingRequests.jsx +++ b/frontend/components/PendingCard.jsx @@ -6,11 +6,11 @@ const PendingCard = ({ username, pr_title, pr_repo, pr_branch }) => { return (
-

{username}/ {pr_repo}/ {pr_branch} ->

-

{pr_repo}/ master

+

{username}/ {pr_repo}/ {pr_branch} ->

+

{pr_repo}/ master

-

{pr_title}

+

{pr_title}

); }; diff --git a/frontend/components/PendingList.jsx b/frontend/components/PendingList.jsx new file mode 100644 index 0000000..6690c31 --- /dev/null +++ b/frontend/components/PendingList.jsx @@ -0,0 +1,11 @@ +import PendingCard from "./PendingCard"; + +const PendingList= ({ list, callback }) => { + return ( + list.map((Card, i) => { + return ; + }) + ); +}; + +export default PendingList; diff --git a/frontend/pages/profile/index.jsx b/frontend/pages/profile/index.jsx index 73f9d5d..58ff69b 100644 --- a/frontend/pages/profile/index.jsx +++ b/frontend/pages/profile/index.jsx @@ -1,14 +1,14 @@ import Profile from "../../components/Profile"; import { useSession } from "next-auth/react"; import { useEffect, useState } from "react"; -import ProfileIssues from "../../components/ProfileIssues"; -import RequestsCard from "../../components/pendingRequests"; -import PendingCard from "../../components/pendingRequests"; -import MergedCard from "../../components/mergedRequests"; +import PendingList from "../../components/PendingList"; +import MergedList from "../../components/MergedList"; const axios = require("axios").default; export default function Home() { + const [MergedList, setMergedList] = useState([]); + const [PendingList, setPendingList] = useState([]); const { data: session } = useSession(); const [user, setUser] = useState(null); @@ -24,6 +24,34 @@ export default function Home() { return response; }; + + const fetchMerged = async () => { + const { data } = await axios.get( + `${process.env.NEXT_PUBLIC_BACKEND_URL}api/` + ); + let repos = []; + data.forEach(async (element) => { + var repoInfo = element.issue.split("/"); + repos = JSON.parse(JSON.stringify(repos)); + repos.push({ + }); + setMergedList(JSON.parse(JSON.stringify(repos))); + }); + }; + const fetchPending = async () => { + const { data } = await axios.get( + `${process.env.NEXT_PUBLIC_BACKEND_URL}api/` + ); + let repos = []; + data.forEach(async (element) => { + var repoInfo = element.issue.split("/"); + repos = JSON.parse(JSON.stringify(repos)); + repos.push({ + }); + setPendingList(JSON.parse(JSON.stringify(repos))); + }); + }; + useEffect(() => { if (session) fetchUserData().then((response) => { @@ -56,9 +84,9 @@ export default function Home() {

merged pull requests

- + ;

pending pull requests

- + ;
) : (