Skip to content

Commit

Permalink
restructure the PR list
Browse files Browse the repository at this point in the history
  • Loading branch information
frey0-0 committed Dec 9, 2022
1 parent f4b8e9e commit 31bc0c6
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 9 deletions.
File renamed without changes.
11 changes: 11 additions & 0 deletions frontend/components/MergedList.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import MergedCard from "./MergedCard";

const MergedList= ({ list, callback }) => {
return (
list.map((Card, i) => {
return <MergedCard Card={Card} key={i} callback={callback} />;
})
);
};

export default MergedList;
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ const PendingCard = ({ username, pr_title, pr_repo, pr_branch }) => {
return (
<div className="pendingCard" >
<div className="requestsTop">
<p className='top'>{username}/ {pr_repo}/ {pr_branch} -&gt;</p>
<p className='top'>{pr_repo}/ master</p>
<p className='top'>{username}/ {pr_repo}/ {pr_branch} -&gt;</p>
<p className='top'>{pr_repo}/ master</p>
</div>
<div className="requestsTitle">
<p className='prTitle'>{pr_title}</p> </div>
<p className='prTitle'>{pr_title}</p> </div>
</div>
);
};
Expand Down
11 changes: 11 additions & 0 deletions frontend/components/PendingList.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import PendingCard from "./PendingCard";

const PendingList= ({ list, callback }) => {
return (
list.map((Card, i) => {
return <PendingCard Card={Card} key={i} callback={callback} />;
})
);
};

export default PendingList;
40 changes: 34 additions & 6 deletions frontend/pages/profile/index.jsx
Original file line number Diff line number Diff line change
@@ -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);

Expand All @@ -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) => {
Expand Down Expand Up @@ -56,9 +84,9 @@ export default function Home() {
</div>
<div className="split_right">
<h1 className="request">merged pull requests</h1>
<MergedCard />
<MergedList list={CardData} callback={fetchMerged} />;
<h1 className="request">pending pull requests</h1>
<PendingCard />
<PendingList list={CardData} callback={fetchPending} />;
</div>
</div>
) : (
Expand Down

0 comments on commit 31bc0c6

Please sign in to comment.