Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/components/collapsible/issues/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ const CollaspsibleIssue = ({
<section className="flex items-center w-max gap-2">
<Image
src={
issue.issue.author.avatarUrl
issue.issue.author?.avatarUrl
}
alt="avatar"
height={16}
width={16}
className="rounded-[50%]"
/>
<p>{issue.issue.author.login}</p>
<p>{issue.issue.author?.login}</p>
</section>
<span>•</span>
<section className="flex items-center w-max gap-2">
Expand Down
118 changes: 77 additions & 41 deletions src/app/components/contribution-graph/index.tsx
Original file line number Diff line number Diff line change
@@ -1,63 +1,99 @@
import { days, months } from "@/helpers/utils"
import { Contribution } from "@/types"
import { IssueCommentNodes } from "@/types/comments"
import { PrNodes } from "@/types/pull_requests"
import React from "react"
import ToolTip from "../tool-tip"

const ContributionGraph = ({
memoizedGraphValues,
loading,
onClickToolTip
onClickToolTip,
allPrs,
allIssues,
username
}: {
memoizedGraphValues: Contribution[]
onClickToolTip: (content: Contribution) => void
loading: boolean
allPrs: PrNodes[]
allIssues: IssueCommentNodes[]
username: string
}) => {
const condition = allPrs.length === 0 && allIssues.length === 0

return (
<div>
<div className="flex items-center gap-[3px]">
<section className="flex flex-col justify-center h-full mt-[10px]">
{days.map((d) => (
<p key={d} className="text-black text-xs pt-[8.5px]">
{d}
</p>
))}
<div
className={`${
condition && loading === false ? "relative border rounded" : ""
} `}
>
{condition && loading === false ? (
<section className="h-full w-full flex items-center justify-center absolute z-50 bg-slate-50 opacity-70">
<p className="text-black font-semibold text-sm opacity-100">
<span className="text-black capitalize">
{username}
</span>{" "}
may have mostly private contributions
</p>
</section>
<div className="max-w-full w-full overflow-x-auto h-full relative">
<section className="grid grid-flow-col pb-[2px] w-full overflow-x-auto md:min-w-[620px] min-w-[620px]">
{months.map((m) => (
<p key={m} className="text-black text-xs">
{m}
</p>
))}
</section>
<div>
<div className="gap-[2px] grid grid-flow-col h-full gridBox">
{memoizedGraphValues.map((day, idx) => (
<ToolTip
key={`${day.day}_${idx}`}
content={day}
onClickToolTip={onClickToolTip}
loading={loading}
/>
) : null}
<>
<div className="flex items-center gap-[3px]">
{condition ? null : (
<section className="flex flex-col justify-center h-full mt-[10px]">
{days.map((d) => (
<p
key={d}
className="text-black text-xs pt-[8.5px]"
>
{d}
</p>
))}
</section>
)}
<div className="max-w-full w-full overflow-x-auto h-full relative">
{allPrs.length === 0 &&
allIssues.length === 0 ? null : (
<section className="grid grid-flow-col pb-[2px] w-full overflow-x-auto md:min-w-[620px] min-w-[620px]">
{months.map((m) => (
<p key={m} className="text-black text-xs">
{m}
</p>
))}
</section>
)}
<div>
<div className="gap-[2px] grid grid-flow-col h-full gridBox">
{memoizedGraphValues.map((day, idx) => (
<ToolTip
key={`${day.day}_${idx}`}
content={day}
onClickToolTip={onClickToolTip}
loading={loading}
/>
))}
</div>
</div>
</div>
</div>
</div>
<section className="text-black text-xs font-medium flex gap-3 flex-wrap pt-4">
<div className="flex items-center gap-1">
<p>Commits</p>
<section className="h-[10px] w-[10px] rounded-[3px] bg-grid-blue"></section>
</div>
<div className="flex items-center gap-1">
<p>Comments</p>
<section className="h-[10px] w-[10px] rounded-[3px] bg-grid-yellow"></section>
</div>
<div className="flex items-center gap-1">
<p>Commits & Comments</p>
<section className="h-[10px] w-[10px] rounded-[3px] bg-grid-green"></section>
</div>
</section>
{condition ? null : (
<section className="text-black text-xs font-medium flex gap-3 flex-wrap pt-4">
<div className="flex items-center gap-1">
<p>Commits</p>
<section className="h-[10px] w-[10px] rounded-[3px] bg-grid-blue"></section>
</div>
<div className="flex items-center gap-1">
<p>Comments</p>
<section className="h-[10px] w-[10px] rounded-[3px] bg-grid-yellow"></section>
</div>
<div className="flex items-center gap-1">
<p>Commits & Comments</p>
<section className="h-[10px] w-[10px] rounded-[3px] bg-grid-green"></section>
</div>
</section>
)}
</>
</div>
)
}
Expand Down
7 changes: 6 additions & 1 deletion src/app/result/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ const Page = () => {
handleYearlyFilter,
memoizedGraphValues,
onClickToolTip,
goBack
goBack,
allPrs,
allIssues
} = useGithubIssues()
const { years } = useGetYears()

Expand Down Expand Up @@ -65,6 +67,9 @@ const Page = () => {
memoizedGraphValues={memoizedGraphValues}
onClickToolTip={onClickToolTip}
loading={loading}
allPrs={allPrs}
allIssues={allIssues}
username={username!}
/>
</section>
<ProjectsBlock
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/get-comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const getOwnComments = ({
data = data ?? []

const rawComments = data?.filter(
(comment) => comment.issue.author.login === username
(comment) => comment.issue.author?.login === username
)

const comments: Comment[] = rawComments?.map((comment) => {
Expand Down Expand Up @@ -43,7 +43,7 @@ export const getOthersComments = ({
data = data ?? []

const rawComments = data?.filter(
(comment) => comment.issue.author.login !== username
(comment) => comment.issue.author?.login !== username
)

const comments: Comment[] = rawComments?.map((comment) => {
Expand Down
14 changes: 10 additions & 4 deletions src/hooks/useGithubIssues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
getOwnComments
} from "@/helpers/get-comments"
import { getPullRequests } from "@/helpers/get-pull-requests"
import { Project, PRsObject } from "@/types/pull_requests"
import { PrNodes, Project, PRsObject } from "@/types/pull_requests"
import { useRouter, useSearchParams } from "next/navigation"
import {
createGridSet,
Expand All @@ -15,7 +15,7 @@ import {
getOrganisations,
getYearlyContributions
} from "@/helpers/utils"
import { IssuesObject } from "@/types/comments"
import { IssueCommentNodes, IssuesObject } from "@/types/comments"
import { Contribution } from "@/types"

export const useGithubIssues = () => {
Expand All @@ -33,6 +33,8 @@ export const useGithubIssues = () => {
const [toggleFilter, setToggleFilter] = useState<string | null>("")
const [yearlyFilter, setYearlyFilter] = useState<string>(currentYear)
const [toolTipKey, setToolTipKey] = useState<string | null>("")
const [allPrs, setAllPrs] = useState<PrNodes[]>([])
const [allIssues, setAllIssues] = useState<IssueCommentNodes[]>([])
const [issuesObject, setIssuesObject] = useState<IssuesObject>({
ownIssueComments: [],
longIssueComments: [],
Expand Down Expand Up @@ -116,6 +118,8 @@ export const useGithubIssues = () => {
setLoading(false)
return
}
setAllIssues(rangedIssuesData)
setAllPrs(rangedPrsData)

const issue = getOwnComments({
data: rangedIssuesData,
Expand Down Expand Up @@ -204,7 +208,7 @@ export const useGithubIssues = () => {
}
}

const goBack = () => Router.back()
const goBack = () => Router.push("/")

return {
projects,
Expand All @@ -218,6 +222,8 @@ export const useGithubIssues = () => {
handleYearlyFilter,
memoizedGraphValues,
onClickToolTip,
goBack
goBack,
allPrs,
allIssues
}
}