From 6cd519ee19a67a33400621d293b3ecc03a245622 Mon Sep 17 00:00:00 2001 From: Harsh Khandeparkar Date: Thu, 28 Dec 2023 00:39:32 +0530 Subject: [PATCH 1/2] fix: fixed pull request numbers in dashboard --- src/pages/MentorDashboard.tsx | 2 +- src/pages/StudentDashboard.tsx | 85 +++++++++++++++++----------------- 2 files changed, 44 insertions(+), 43 deletions(-) diff --git a/src/pages/MentorDashboard.tsx b/src/pages/MentorDashboard.tsx index 5c5316c8..6c2d3e5e 100644 --- a/src/pages/MentorDashboard.tsx +++ b/src/pages/MentorDashboard.tsx @@ -153,7 +153,7 @@ function MentorDashboard() { {pull .replace("https://github.com/", "") .replace("pull/", "") - .replace(/\/\d/, "#")} + .replace("/", "#")} ))} diff --git a/src/pages/StudentDashboard.tsx b/src/pages/StudentDashboard.tsx index 57746b95..0a825776 100644 --- a/src/pages/StudentDashboard.tsx +++ b/src/pages/StudentDashboard.tsx @@ -69,10 +69,7 @@ function StudentDashboard() { : 0; // Languages used and projects - let languages_used = - dashboard === null - ? [] - : dashboard.languages_used; + let languages_used = dashboard === null ? [] : dashboard.languages_used; return (
@@ -160,7 +157,11 @@ function StudentDashboard() { Mid Evaluation:

- {dashboard?.passed_mid_evals ? Passed : Pending} + {dashboard?.passed_mid_evals ? ( + Passed + ) : ( + Pending + )}

@@ -170,12 +171,15 @@ function StudentDashboard() { End Evaluation:

- {dashboard?.passed_end_evals ? Passed : Pending} + {dashboard?.passed_end_evals ? ( + Passed + ) : ( + Pending + )}

- ) - } + )} @@ -245,22 +249,21 @@ function StudentDashboard() {
{dashboard !== null && (
-

- Projects Worked On -

+

Projects Worked On

- {dashboard.projects_worked.length > 0 ? dashboard.projects_worked - .map(({ name, repo_link }, i) => ( - - {name} - - )) : 'None'} + {dashboard.projects_worked.length > 0 + ? dashboard.projects_worked.map(({ name, repo_link }, i) => ( + + {name} + + )) + : "None"}
)} @@ -271,29 +274,27 @@ function StudentDashboard() { Merged Pull Requests
- {dashboard.pulls.length > 0 ? - dashboard.pulls.map((pull, i) => ( - - {pull - .replace("https://github.com/", "") - .replace("pull/", "") - .replace(/\/\d/, "#")} - - )) : 'None'} + {dashboard.pulls.length > 0 + ? dashboard.pulls.map((pull, i) => ( + + {pull + .replace("https://github.com/", "") + .replace("pull/", "") + .replace("/", "#")} + + )) + : "None"}
)} - + ); From 2a17ce59052509fef1b0caeb7073419ecd34d09a Mon Sep 17 00:00:00 2001 From: Harsh Khandeparkar Date: Thu, 28 Dec 2023 00:52:45 +0530 Subject: [PATCH 2/2] fix: actual proper real pull request formatting --- src/pages/MentorDashboard.tsx | 6 ++---- src/pages/StudentDashboard.tsx | 6 ++---- src/util/format.ts | 13 +++++++++++++ 3 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 src/util/format.ts diff --git a/src/pages/MentorDashboard.tsx b/src/pages/MentorDashboard.tsx index 6c2d3e5e..95741656 100644 --- a/src/pages/MentorDashboard.tsx +++ b/src/pages/MentorDashboard.tsx @@ -11,6 +11,7 @@ import { REGISTRATIONS_OPEN, ROUTER_PATHS } from "../util/constants"; import { makeRequest } from "../util/backend"; import SpinnerLoader from "../components/SpinnerLoader"; import { Profile, Resources } from "../components/DashboardElements"; +import { formatPullRequest } from "../util/format"; function MentorDashboard() { const navigate = useNavigate(); @@ -150,10 +151,7 @@ function MentorDashboard() { rel="noopener noreferrer" className="text-primary hover:text-primary-600 hover:underline" > - {pull - .replace("https://github.com/", "") - .replace("pull/", "") - .replace("/", "#")} + {formatPullRequest(pull)} ))} diff --git a/src/pages/StudentDashboard.tsx b/src/pages/StudentDashboard.tsx index 0a825776..cf6241d0 100644 --- a/src/pages/StudentDashboard.tsx +++ b/src/pages/StudentDashboard.tsx @@ -16,6 +16,7 @@ import { BiGitCommit, BiGitPullRequest } from "react-icons/bi"; import { MdOutlineDifference } from "react-icons/md"; import { FaCode } from "react-icons/fa"; import { HiOutlineDocumentReport } from "react-icons/hi"; +import { formatPullRequest } from "../util/format"; function StudentDashboard() { const navigate = useNavigate(); @@ -283,10 +284,7 @@ function StudentDashboard() { rel="noopener noreferrer" className="text-primary hover:text-primary-600 hover:underline" > - {pull - .replace("https://github.com/", "") - .replace("pull/", "") - .replace("/", "#")} + {formatPullRequest(pull)} )) : "None"} diff --git a/src/util/format.ts b/src/util/format.ts new file mode 100644 index 00000000..b44e6c1d --- /dev/null +++ b/src/util/format.ts @@ -0,0 +1,13 @@ +// Formats a pull request in the format [org]/[repo]#[number] from the url +export function formatPullRequest(url: string): string { + return url + .replace("https://github.com/", "") + .replace("pull/", "") + .split("") + .reverse() + .join("") + .replace("/", "#") + .split("") + .reverse() + .join(""); +}