Skip to content

Commit

Permalink
add TS type
Browse files Browse the repository at this point in the history
  • Loading branch information
fuoridallarete committed Jan 30, 2024
1 parent 23010eb commit 08e2254
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 29 deletions.
63 changes: 34 additions & 29 deletions src/components/RepositoryContributionsCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Contributions, Repository } from "@/types/github";
import { Contributions, PullRequestNode, Repository } from "@/types/github";
import Image from "next/image";
import Link from "next/link";
import { FaCodeMerge } from "react-icons/fa6";
Expand Down Expand Up @@ -52,35 +52,40 @@ export const RepositoryContributionsCard = ({
</div>
</div>
<div className="max-h-[22rem] hide-scrollbar overflow-auto flex flex-col gap-1">
{nodes?.map(({ pullRequest: { state, title, id, url } }: any) => (
<div key={id} className="flex items-center justify-between gap-2">
<a
href={url}
target="_blank"
className="truncate"
title={title}
>
{title}
</a>
<span
className={`h-fit rounded p-1 ${
state === "MERGED"
? "bg-purple-500"
: state === "CLOSED"
? "bg-red-500"
: "bg-green-500"
}`}
{nodes?.map(
({ pullRequest: { state, title, id, url } }: PullRequestNode) => (
<div
key={id}
className="flex items-center justify-between gap-2"
>
{state === "MERGED" ? (
<FaCodeMerge size={18} />
) : state === "CLOSED" ? (
<IoIosCloseCircleOutline size={18} />
) : (
<GoIssueOpened size={18} />
)}
</span>
</div>
))}
<a
href={url}
target="_blank"
className="truncate"
title={title}
>
{title}
</a>
<span
className={`h-fit rounded p-1 ${
state === "MERGED"
? "bg-purple-500"
: state === "CLOSED"
? "bg-red-500"
: "bg-green-500"
}`}
>
{state === "MERGED" ? (
<FaCodeMerge size={18} />
) : state === "CLOSED" ? (
<IoIosCloseCircleOutline size={18} />
) : (
<GoIssueOpened size={18} />
)}
</span>
</div>
)
)}
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/types/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type PullRequest = {
id: string;
title: string;
state: "MERGED" | "CLOSED" | "OPEN";
url: string;
};

export type Repository = {
Expand Down

0 comments on commit 08e2254

Please sign in to comment.