diff --git a/src/app/components/collapsible/issues/index.tsx b/src/app/components/collapsible/issues/index.tsx index 03cb407..144e2dc 100644 --- a/src/app/components/collapsible/issues/index.tsx +++ b/src/app/components/collapsible/issues/index.tsx @@ -97,14 +97,14 @@ const CollaspsibleIssue = ({
avatar -

{issue.issue.author.login}

+

{issue.issue.author?.login}

diff --git a/src/app/components/contribution-graph/index.tsx b/src/app/components/contribution-graph/index.tsx index 2fd8db0..2a1d0cb 100644 --- a/src/app/components/contribution-graph/index.tsx +++ b/src/app/components/contribution-graph/index.tsx @@ -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 ( -
-
-
- {days.map((d) => ( -

- {d} -

- ))} +
+ {condition && loading === false ? ( +
+

+ + {username} + {" "} + may have mostly private contributions +

-
-
- {months.map((m) => ( -

- {m} -

- ))} -
-
-
- {memoizedGraphValues.map((day, idx) => ( - + ) : null} + <> +
+ {condition ? null : ( +
+ {days.map((d) => ( +

+ {d} +

))} +
+ )} +
+ {allPrs.length === 0 && + allIssues.length === 0 ? null : ( +
+ {months.map((m) => ( +

+ {m} +

+ ))} +
+ )} +
+
+ {memoizedGraphValues.map((day, idx) => ( + + ))} +
-
-
-
-

Commits

-
-
-
-

Comments

-
-
-
-

Commits & Comments

-
-
-
+ {condition ? null : ( +
+
+

Commits

+
+
+
+

Comments

+
+
+
+

Commits & Comments

+
+
+
+ )} +
) } diff --git a/src/app/result/page.tsx b/src/app/result/page.tsx index 2077384..97aa13d 100644 --- a/src/app/result/page.tsx +++ b/src/app/result/page.tsx @@ -26,7 +26,9 @@ const Page = () => { handleYearlyFilter, memoizedGraphValues, onClickToolTip, - goBack + goBack, + allPrs, + allIssues } = useGithubIssues() const { years } = useGetYears() @@ -65,6 +67,9 @@ const Page = () => { memoizedGraphValues={memoizedGraphValues} onClickToolTip={onClickToolTip} loading={loading} + allPrs={allPrs} + allIssues={allIssues} + username={username!} />
comment.issue.author.login === username + (comment) => comment.issue.author?.login === username ) const comments: Comment[] = rawComments?.map((comment) => { @@ -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) => { diff --git a/src/hooks/useGithubIssues.ts b/src/hooks/useGithubIssues.ts index 6c89fb3..abc7c35 100644 --- a/src/hooks/useGithubIssues.ts +++ b/src/hooks/useGithubIssues.ts @@ -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, @@ -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 = () => { @@ -33,6 +33,8 @@ export const useGithubIssues = () => { const [toggleFilter, setToggleFilter] = useState("") const [yearlyFilter, setYearlyFilter] = useState(currentYear) const [toolTipKey, setToolTipKey] = useState("") + const [allPrs, setAllPrs] = useState([]) + const [allIssues, setAllIssues] = useState([]) const [issuesObject, setIssuesObject] = useState({ ownIssueComments: [], longIssueComments: [], @@ -116,6 +118,8 @@ export const useGithubIssues = () => { setLoading(false) return } + setAllIssues(rangedIssuesData) + setAllPrs(rangedPrsData) const issue = getOwnComments({ data: rangedIssuesData, @@ -204,7 +208,7 @@ export const useGithubIssues = () => { } } - const goBack = () => Router.back() + const goBack = () => Router.push("/") return { projects, @@ -218,6 +222,8 @@ export const useGithubIssues = () => { handleYearlyFilter, memoizedGraphValues, onClickToolTip, - goBack + goBack, + allPrs, + allIssues } }