From f8444fc1148dfef6e15a84bc241f82865640ed70 Mon Sep 17 00:00:00 2001 From: aslw1 <Abdelrahman.Eldahab@student.aast.edu> Date: Mon, 8 Jan 2024 02:51:00 +0200 Subject: [PATCH 1/2] fixed the terms page as it wasn't viewing anything --- packages/app/src/app/terms/page.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/app/src/app/terms/page.tsx b/packages/app/src/app/terms/page.tsx index 282f176a..017adf17 100644 --- a/packages/app/src/app/terms/page.tsx +++ b/packages/app/src/app/terms/page.tsx @@ -4,10 +4,8 @@ const page = () => { <> <Heading title="Terms" /> <div> - <h1>CodeRacer - Terms of Service</h1> - <p><strong>Effective Date:</strong> [Date]</p> - - <p>Welcome to CodeRacer! These Terms of Service ("Terms") constitute a legal agreement between you and CodeRacer. Please read these Terms carefully before using our platform, which is accessible at <a href="https://code-racer-eight.vercel.app/">https://code-racer-eight.vercel.app/</a>. By using CodeRacer, you agree to be bound by these Terms.</p> + <h1>CodeRacer - Terms of Service</h1> + <p>Welcome to CodeRacer! These Terms of Service Terms constitute a legal agreement between you and CodeRacer. Please read these Terms carefully before using our platform, which is accessible at <a href="https://code-racer-eight.vercel.app/">https://code-racer-eight.vercel.app/</a>. By using CodeRacer, you agree to be bound by these Terms.</p> <h2>1. User Accounts</h2> <p> @@ -45,7 +43,7 @@ const page = () => { <h2>6. Limitation of Liability</h2> <p> - <strong>6.1. Disclaimer:</strong> CodeRacer is provided "as is," and we make no warranties or representations about the accuracy or reliability of the platform. Your use of CodeRacer is at your own risk. + <strong>6.1. Disclaimer:</strong> CodeRacer is provided as is, and we make no warranties or representations about the accuracy or reliability of the platform. Your use of CodeRacer is at your own risk. </p> <h2>7. Changes to Terms</h2> @@ -58,6 +56,7 @@ const page = () => { <strong>8.1. Questions:</strong> If you have any questions or concerns about these Terms, please contact us at <a href="mailto:contact@coderacer.com">contact@coderacer.com</a>. </p> </div> + </> ); }; From 14b395db6eacbedf2d1873dcca80a664c2a5a85c Mon Sep 17 00:00:00 2001 From: aslw1 <Abdelrahman.Eldahab@student.aast.edu> Date: Mon, 8 Jan 2024 03:04:44 +0200 Subject: [PATCH 2/2] refactored the leaderboard page --- .../_components/ContributorsList.tsx | 31 +++++++++++++++++++ .../src/app/contributors/_helpers/types.ts | 26 ++++++++++++++++ packages/app/src/app/contributors/page.tsx | 24 +++++--------- 3 files changed, 64 insertions(+), 17 deletions(-) create mode 100644 packages/app/src/app/contributors/_components/ContributorsList.tsx diff --git a/packages/app/src/app/contributors/_components/ContributorsList.tsx b/packages/app/src/app/contributors/_components/ContributorsList.tsx new file mode 100644 index 00000000..0840060a --- /dev/null +++ b/packages/app/src/app/contributors/_components/ContributorsList.tsx @@ -0,0 +1,31 @@ +import Contributor from "./contributor" +import { GitHubContributor, contributors } from "../_helpers/types" +interface contributerListProps { + contributors: contributors; + sliceStartIndex: number; + sliceEndIndex: number; + contributorCommitActivities: any; +} +const Contributors = ({contributors,sliceStartIndex,sliceEndIndex,contributorCommitActivities}:contributerListProps) => { + return ( + <div> + <ul className="grid gap-4 mt-8 list-none md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"> + {contributors + .slice(sliceStartIndex, sliceEndIndex) + .map((contributor: GitHubContributor) => ( + <Contributor + key={contributor.id} + contributor={contributor} + contributorsCodeChanges={ + contributorCommitActivities.find( + (e: { login: string }) => e.login === contributor.login, + ) ?? { additions: 0, deletions: 0, login: contributor.login } + } + /> + ))} + </ul> + </div> + ) +} + +export default Contributors \ No newline at end of file diff --git a/packages/app/src/app/contributors/_helpers/types.ts b/packages/app/src/app/contributors/_helpers/types.ts index 8411988e..0d5e278b 100644 --- a/packages/app/src/app/contributors/_helpers/types.ts +++ b/packages/app/src/app/contributors/_helpers/types.ts @@ -58,6 +58,31 @@ interface GitHubContributorCommitActivity { }[]; } + +type contributors ={ + + login: string; + id: number; + node_id: string; + avatar_url: string; + gravatar_id: string; + url: string; + html_url: string; + followers_url: string; + following_url: string; + gists_url: string; + starred_url: string; + subscriptions_url: string; + organizations_url: string; + repos_url: string; + events_url: string; + received_events_url: string; + type: string; + site_admin: boolean; + contributions: number; + +}[] + // GitHub API Response schemas ------------------------------------------ export { @@ -67,4 +92,5 @@ export { type GitHubContributor, type GitHubCommit, type ContributorCodeChanges, + type contributors, }; diff --git a/packages/app/src/app/contributors/page.tsx b/packages/app/src/app/contributors/page.tsx index 1bc4002b..d048ae53 100644 --- a/packages/app/src/app/contributors/page.tsx +++ b/packages/app/src/app/contributors/page.tsx @@ -1,5 +1,4 @@ import { Heading } from "@/components/ui/heading"; -import Contributor from "./_components/contributor"; import AdditionsDeletions from "./_components/additions-deletions"; import ProportionBarChart from "./_components/proportion-bar-chart"; import Time from "@/components/ui/time"; @@ -13,6 +12,7 @@ import { getRepoWeeklyCodeChanges, } from "./_helpers/utils"; import { redirect } from "next/navigation"; +import ContributorsList from "./_components/ContributorsList"; const PER_PAGE_MAX = 12; // Limit to only 12 per page to avoid hitting rate limit @@ -107,22 +107,12 @@ export default async function ContributorsPage({ /> </div> </div> - <ul className="grid gap-4 mt-8 list-none md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"> - {contributors - .slice(sliceStartIndex, sliceEndIndex) - .map((contributor) => ( - <Contributor - key={contributor.id} - contributor={contributor} - contributorsCodeChanges={ - contributorCommitActivities.find( - (e) => e.login === contributor.login, - ) ?? { additions: 0, deletions: 0, login: contributor.login } - } - /> - ))} - </ul> - + <ContributorsList + contributors={contributors} + sliceStartIndex={sliceStartIndex} + sliceEndIndex={sliceEndIndex} + contributorCommitActivities={contributorCommitActivities} + ></ContributorsList> <PaginationBar className="flex justify-center w-full mt-6" nextURL={`/contributors?page=${Math.min(