Skip to content

Commit

Permalink
Merge branch 'stud-dashboard-stats' into truth-redefined-again
Browse files Browse the repository at this point in the history
  • Loading branch information
harshkhandeparkar committed Dec 27, 2023
2 parents c86a362 + 2a17ce5 commit 2f0e7f7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/pages/MentorDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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(/\/\d/, "#")}
{formatPullRequest(pull)}
</a>
))}
</div>
Expand Down
6 changes: 2 additions & 4 deletions src/pages/StudentDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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(/\/\d/, "#")}
{formatPullRequest(pull)}
</a>
))
: "None"}
Expand Down
13 changes: 13 additions & 0 deletions src/util/format.ts
Original file line number Diff line number Diff line change
@@ -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("");
}

0 comments on commit 2f0e7f7

Please sign in to comment.