Skip to content

Commit 8a82ef3

Browse files
committed
feat: add contribution heatmap to chapter details page
1 parent 0ea5d68 commit 8a82ef3

File tree

1 file changed

+36
-12
lines changed
  • frontend/src/app/chapters/[chapterKey]

1 file changed

+36
-12
lines changed

frontend/src/app/chapters/[chapterKey]/page.tsx

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type { Chapter } from 'types/chapter'
99
import type { Contributor } from 'types/contributor'
1010
import { formatDate } from 'utils/dateFormatter'
1111
import DetailsCard from 'components/CardDetailsPage'
12+
import ContributionHeatmap from 'components/ContributionHeatmap'
1213
import LoadingSpinner from 'components/LoadingSpinner'
1314

1415
export default function ChapterDetailsPage() {
@@ -59,18 +60,41 @@ export default function ChapterDetailsPage() {
5960
),
6061
},
6162
]
63+
64+
// Calculate contribution heatmap date range (1 year back)
65+
const today = new Date()
66+
const oneYearAgo = new Date(today)
67+
oneYearAgo.setFullYear(today.getFullYear() - 1)
68+
const startDate = oneYearAgo.toISOString().split('T')[0]
69+
const endDate = today.toISOString().split('T')[0]
70+
6271
return (
63-
<DetailsCard
64-
details={details}
65-
entityKey={chapter.key}
66-
entityLeaders={chapter.entityLeaders}
67-
geolocationData={[chapter]}
68-
isActive={chapter.isActive}
69-
socialLinks={chapter.relatedUrls}
70-
summary={chapter.summary}
71-
title={chapter.name}
72-
topContributors={topContributors}
73-
type="chapter"
74-
/>
72+
<>
73+
<DetailsCard
74+
details={details}
75+
entityKey={chapter.key}
76+
entityLeaders={chapter.entityLeaders}
77+
geolocationData={[chapter]}
78+
isActive={chapter.isActive}
79+
socialLinks={chapter.relatedUrls}
80+
summary={chapter.summary}
81+
title={chapter.name}
82+
topContributors={topContributors}
83+
type="chapter"
84+
/>
85+
{chapter.contributionData && Object.keys(chapter.contributionData).length > 0 && (
86+
<div className="min-h-screen bg-white p-8 text-gray-600 dark:bg-[#212529] dark:text-gray-300">
87+
<div className="mx-auto max-w-6xl">
88+
<ContributionHeatmap
89+
contributionData={chapter.contributionData}
90+
startDate={startDate}
91+
endDate={endDate}
92+
title="Chapter Contribution Activity"
93+
unit="contributions"
94+
/>
95+
</div>
96+
</div>
97+
)}
98+
</>
7599
)
76100
}

0 commit comments

Comments
 (0)