@@ -6,7 +6,12 @@ import Link from "next/link";
6
6
import { useLeetcodeStore } from "@/store/LeetcodeStore/useLeetcodeStore" ;
7
7
import { Card , CardContent , CardHeader } from "@/components/ui/card" ;
8
8
import { Skeleton } from "@/components/ui/skeleton" ;
9
- import { Line , Bar , Doughnut } from "react-chartjs-2" ;
9
+ import { Doughnut } from "react-chartjs-2" ;
10
+
11
+ import CalendarHeatmap from "react-calendar-heatmap" ;
12
+ import "../styles/style.css" ;
13
+ import 'react-calendar-heatmap/dist/styles.css' ;
14
+
10
15
import {
11
16
Chart as ChartJS ,
12
17
CategoryScale ,
@@ -82,6 +87,17 @@ export default function Dashboard() {
82
87
} ] ,
83
88
} ;
84
89
90
+
91
+ const processLeetCodeData = ( submissionCalendar : string ) => {
92
+ const parsedData = JSON . parse ( submissionCalendar ) ;
93
+
94
+ return Object . entries ( parsedData ) . map ( ( [ timestamp ] ) => ( {
95
+ date : new Date ( Number ( timestamp ) * 1000 ) . toISOString ( ) . split ( "T" ) [ 0 ]
96
+ } ) ) ;
97
+ } ;
98
+
99
+ console . log ( processLeetCodeData ( userDetails . submissionCalendar ) ) ;
100
+
85
101
return (
86
102
< div className = "max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 space-y-8" >
87
103
{ /* Profile Header Card */ }
@@ -147,16 +163,21 @@ export default function Dashboard() {
147
163
</ span >
148
164
</ div >
149
165
</ CardHeader >
150
- < CardContent className = "p-6" >
151
- < LeetCodeCalendar
152
- username = "yashksaini"
153
- blockSize = { 11 }
154
- blockMargin = { 3 }
155
- fontSize = { 11 }
156
- theme = { exampleTheme }
157
- style = { { maxWidth : '100%' } }
166
+ < CardContent className = "p-6" >
167
+ < CalendarHeatmap
168
+ values = { processLeetCodeData ( userDetails . submissionCalendar ) }
169
+ startDate = { new Date ( new Date ( ) . setFullYear ( new Date ( ) . getFullYear ( ) - 1 ) ) }
170
+ endDate = { new Date ( ) }
171
+ classForValue = { ( value ) => {
172
+ if ( ! value ) {
173
+ return 'color-empty' ;
174
+ }
175
+ return `color-scale-${ ( value . count ) , 4 } ` ;
176
+ } }
177
+ showWeekdayLabels
178
+ onMouseOver = { ( e , value ) => console . log ( e , value ) }
158
179
/>
159
- </ CardContent >
180
+ </ CardContent >
160
181
</ Card >
161
182
162
183
{ /* Recent Submissions Card */ }
0 commit comments