Skip to content

Commit f498d13

Browse files
authored
fix: deleted accounts (#80)
* fix null conditions for deleted accountst * add condition for private contributions
1 parent 8883434 commit f498d13

File tree

5 files changed

+97
-50
lines changed

5 files changed

+97
-50
lines changed

src/app/components/collapsible/issues/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ const CollaspsibleIssue = ({
9797
<section className="flex items-center w-max gap-2">
9898
<Image
9999
src={
100-
issue.issue.author.avatarUrl
100+
issue.issue.author?.avatarUrl
101101
}
102102
alt="avatar"
103103
height={16}
104104
width={16}
105105
className="rounded-[50%]"
106106
/>
107-
<p>{issue.issue.author.login}</p>
107+
<p>{issue.issue.author?.login}</p>
108108
</section>
109109
<span></span>
110110
<section className="flex items-center w-max gap-2">

src/app/components/contribution-graph/index.tsx

Lines changed: 77 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,99 @@
11
import { days, months } from "@/helpers/utils"
22
import { Contribution } from "@/types"
3+
import { IssueCommentNodes } from "@/types/comments"
4+
import { PrNodes } from "@/types/pull_requests"
35
import React from "react"
46
import ToolTip from "../tool-tip"
57

68
const ContributionGraph = ({
79
memoizedGraphValues,
810
loading,
9-
onClickToolTip
11+
onClickToolTip,
12+
allPrs,
13+
allIssues,
14+
username
1015
}: {
1116
memoizedGraphValues: Contribution[]
1217
onClickToolTip: (content: Contribution) => void
1318
loading: boolean
19+
allPrs: PrNodes[]
20+
allIssues: IssueCommentNodes[]
21+
username: string
1422
}) => {
23+
const condition = allPrs.length === 0 && allIssues.length === 0
24+
1525
return (
16-
<div>
17-
<div className="flex items-center gap-[3px]">
18-
<section className="flex flex-col justify-center h-full mt-[10px]">
19-
{days.map((d) => (
20-
<p key={d} className="text-black text-xs pt-[8.5px]">
21-
{d}
22-
</p>
23-
))}
26+
<div
27+
className={`${
28+
condition && loading === false ? "relative border rounded" : ""
29+
} `}
30+
>
31+
{condition && loading === false ? (
32+
<section className="h-full w-full flex items-center justify-center absolute z-50 bg-slate-50 opacity-70">
33+
<p className="text-black font-semibold text-sm opacity-100">
34+
<span className="text-black capitalize">
35+
{username}
36+
</span>{" "}
37+
may have mostly private contributions
38+
</p>
2439
</section>
25-
<div className="max-w-full w-full overflow-x-auto h-full relative">
26-
<section className="grid grid-flow-col pb-[2px] w-full overflow-x-auto md:min-w-[620px] min-w-[620px]">
27-
{months.map((m) => (
28-
<p key={m} className="text-black text-xs">
29-
{m}
30-
</p>
31-
))}
32-
</section>
33-
<div>
34-
<div className="gap-[2px] grid grid-flow-col h-full gridBox">
35-
{memoizedGraphValues.map((day, idx) => (
36-
<ToolTip
37-
key={`${day.day}_${idx}`}
38-
content={day}
39-
onClickToolTip={onClickToolTip}
40-
loading={loading}
41-
/>
40+
) : null}
41+
<>
42+
<div className="flex items-center gap-[3px]">
43+
{condition ? null : (
44+
<section className="flex flex-col justify-center h-full mt-[10px]">
45+
{days.map((d) => (
46+
<p
47+
key={d}
48+
className="text-black text-xs pt-[8.5px]"
49+
>
50+
{d}
51+
</p>
4252
))}
53+
</section>
54+
)}
55+
<div className="max-w-full w-full overflow-x-auto h-full relative">
56+
{allPrs.length === 0 &&
57+
allIssues.length === 0 ? null : (
58+
<section className="grid grid-flow-col pb-[2px] w-full overflow-x-auto md:min-w-[620px] min-w-[620px]">
59+
{months.map((m) => (
60+
<p key={m} className="text-black text-xs">
61+
{m}
62+
</p>
63+
))}
64+
</section>
65+
)}
66+
<div>
67+
<div className="gap-[2px] grid grid-flow-col h-full gridBox">
68+
{memoizedGraphValues.map((day, idx) => (
69+
<ToolTip
70+
key={`${day.day}_${idx}`}
71+
content={day}
72+
onClickToolTip={onClickToolTip}
73+
loading={loading}
74+
/>
75+
))}
76+
</div>
4377
</div>
4478
</div>
4579
</div>
46-
</div>
47-
<section className="text-black text-xs font-medium flex gap-3 flex-wrap pt-4">
48-
<div className="flex items-center gap-1">
49-
<p>Commits</p>
50-
<section className="h-[10px] w-[10px] rounded-[3px] bg-grid-blue"></section>
51-
</div>
52-
<div className="flex items-center gap-1">
53-
<p>Comments</p>
54-
<section className="h-[10px] w-[10px] rounded-[3px] bg-grid-yellow"></section>
55-
</div>
56-
<div className="flex items-center gap-1">
57-
<p>Commits & Comments</p>
58-
<section className="h-[10px] w-[10px] rounded-[3px] bg-grid-green"></section>
59-
</div>
60-
</section>
80+
{condition ? null : (
81+
<section className="text-black text-xs font-medium flex gap-3 flex-wrap pt-4">
82+
<div className="flex items-center gap-1">
83+
<p>Commits</p>
84+
<section className="h-[10px] w-[10px] rounded-[3px] bg-grid-blue"></section>
85+
</div>
86+
<div className="flex items-center gap-1">
87+
<p>Comments</p>
88+
<section className="h-[10px] w-[10px] rounded-[3px] bg-grid-yellow"></section>
89+
</div>
90+
<div className="flex items-center gap-1">
91+
<p>Commits & Comments</p>
92+
<section className="h-[10px] w-[10px] rounded-[3px] bg-grid-green"></section>
93+
</div>
94+
</section>
95+
)}
96+
</>
6197
</div>
6298
)
6399
}

src/app/result/page.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ const Page = () => {
2626
handleYearlyFilter,
2727
memoizedGraphValues,
2828
onClickToolTip,
29-
goBack
29+
goBack,
30+
allPrs,
31+
allIssues
3032
} = useGithubIssues()
3133
const { years } = useGetYears()
3234

@@ -65,6 +67,9 @@ const Page = () => {
6567
memoizedGraphValues={memoizedGraphValues}
6668
onClickToolTip={onClickToolTip}
6769
loading={loading}
70+
allPrs={allPrs}
71+
allIssues={allIssues}
72+
username={username!}
6873
/>
6974
</section>
7075
<ProjectsBlock

src/helpers/get-comments.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const getOwnComments = ({
1111
data = data ?? []
1212

1313
const rawComments = data?.filter(
14-
(comment) => comment.issue.author.login === username
14+
(comment) => comment.issue.author?.login === username
1515
)
1616

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

4545
const rawComments = data?.filter(
46-
(comment) => comment.issue.author.login !== username
46+
(comment) => comment.issue.author?.login !== username
4747
)
4848

4949
const comments: Comment[] = rawComments?.map((comment) => {

src/hooks/useGithubIssues.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
getOwnComments
77
} from "@/helpers/get-comments"
88
import { getPullRequests } from "@/helpers/get-pull-requests"
9-
import { Project, PRsObject } from "@/types/pull_requests"
9+
import { PrNodes, Project, PRsObject } from "@/types/pull_requests"
1010
import { useRouter, useSearchParams } from "next/navigation"
1111
import {
1212
createGridSet,
@@ -15,7 +15,7 @@ import {
1515
getOrganisations,
1616
getYearlyContributions
1717
} from "@/helpers/utils"
18-
import { IssuesObject } from "@/types/comments"
18+
import { IssueCommentNodes, IssuesObject } from "@/types/comments"
1919
import { Contribution } from "@/types"
2020

2121
export const useGithubIssues = () => {
@@ -33,6 +33,8 @@ export const useGithubIssues = () => {
3333
const [toggleFilter, setToggleFilter] = useState<string | null>("")
3434
const [yearlyFilter, setYearlyFilter] = useState<string>(currentYear)
3535
const [toolTipKey, setToolTipKey] = useState<string | null>("")
36+
const [allPrs, setAllPrs] = useState<PrNodes[]>([])
37+
const [allIssues, setAllIssues] = useState<IssueCommentNodes[]>([])
3638
const [issuesObject, setIssuesObject] = useState<IssuesObject>({
3739
ownIssueComments: [],
3840
longIssueComments: [],
@@ -116,6 +118,8 @@ export const useGithubIssues = () => {
116118
setLoading(false)
117119
return
118120
}
121+
setAllIssues(rangedIssuesData)
122+
setAllPrs(rangedPrsData)
119123

120124
const issue = getOwnComments({
121125
data: rangedIssuesData,
@@ -204,7 +208,7 @@ export const useGithubIssues = () => {
204208
}
205209
}
206210

207-
const goBack = () => Router.back()
211+
const goBack = () => Router.push("/")
208212

209213
return {
210214
projects,
@@ -218,6 +222,8 @@ export const useGithubIssues = () => {
218222
handleYearlyFilter,
219223
memoizedGraphValues,
220224
onClickToolTip,
221-
goBack
225+
goBack,
226+
allPrs,
227+
allIssues
222228
}
223229
}

0 commit comments

Comments
 (0)