1
1
"use client" ;
2
2
3
+ import { Card , CardContent , CardDescription , CardHeader , CardTitle } from "@/components/ui/card" ;
4
+ import {
5
+ Table ,
6
+ TableBody ,
7
+ TableCell ,
8
+ TableHead ,
9
+ TableHeader ,
10
+ TableRow ,
11
+ } from "@/components/ui/table" ;
3
12
import React from "react" ;
4
13
import {
5
14
LineChart ,
@@ -38,7 +47,7 @@ export default function DashboardPage() {
38
47
wpm : 80 ,
39
48
} ,
40
49
{
41
- gameId : "cljvlqsj8000408l4ahr36soj " ,
50
+ gameId : "cljvlqsj8000448ewhr36soj " ,
42
51
date : "08/02/2023" ,
43
52
accuracy : 78 ,
44
53
errors : 2 ,
@@ -68,11 +77,13 @@ export default function DashboardPage() {
68
77
// All achievements and the progress of finishing it. NOTE: This should be sorted on progress.
69
78
const achievements = [
70
79
{
80
+ id : "cljvlqsj8000408l4ahr36soj" ,
71
81
title : "First race" ,
72
82
description : "Started a race" ,
73
83
progress : 100 ,
74
84
} ,
75
85
{
86
+ id : "cljvlqsj8000408l4ahr36sok" ,
76
87
title : "Play 10 races" ,
77
88
description : "Play a total of 10 races online" ,
78
89
progress : 33 ,
@@ -81,14 +92,18 @@ export default function DashboardPage() {
81
92
82
93
return (
83
94
< >
84
- < h1 className = "text-4xl m-6 font-bold text-center max-[600px]:mb-10" > Dashboard</ h1 >
95
+ < h1 className = "text-4xl m-6 font-bold text-center max-[600px]:mb-10" >
96
+ Dashboard
97
+ </ h1 >
85
98
< div className = "flex max-[600px]:flex-col justify-center items-center w-screen h-[50vh] gap-6 m-2" >
86
- < div className = "w-[47.5%] max-[600px]:w-[100%] max-[600px]:mr-4 h-full max-[600px]:h-[50%] rounded-lg border-gray-400 border-2 border-opacity-50 max-[600px]:ml-4" >
87
- < h2 className = "text-2xl font-bold text-center m-2" > Accuracy</ h2 >
99
+ < Card className = "w-[47.5%] max-[600px]:w-[100%] max-[600px]:mr-4 h-full max-[600px]:h-[50%]" >
100
+ < CardHeader >
101
+ < CardTitle className = "text-center m-2" > Accuracy</ CardTitle >
102
+ </ CardHeader >
88
103
< ResponsiveContainer height = "100%" >
89
104
< LineChart
90
105
data = { accuracyData }
91
- margin = { { right : 25 , left : 25 , bottom : 50 } }
106
+ margin = { { right : 25 , left : 25 , bottom : 100 } }
92
107
>
93
108
< CartesianGrid strokeDasharray = "3 3" />
94
109
< XAxis dataKey = "gameNumber" />
@@ -103,15 +118,15 @@ export default function DashboardPage() {
103
118
/>
104
119
</ LineChart >
105
120
</ ResponsiveContainer >
106
- </ div >
107
- < div className = "w-[47.5%] max-[600px]:w-[100%] h-full max-[600px]:h-[50%] rounded-lg border-gray-400 border-2 border-opacity-50 max-[600px]:mr-4 max-[600px]:ml-4 max-[600px]:mb-6" >
108
- < h2 className = "text-2xl font-bold text-center m-2" >
109
- Words per minute
110
- </ h2 >
121
+ </ Card >
122
+ < Card className = "w-[47.5%] max-[600px]:w-[100%] h-full max-[600px]:h-[50%] max-[600px]:mr-4 max-[600px]:ml-4 max-[600px]:mb-6" >
123
+ < CardHeader >
124
+ < CardTitle className = "text-center m-2" > Words per minute</ CardTitle >
125
+ </ CardHeader >
111
126
< ResponsiveContainer height = "100%" >
112
127
< ComposedChart
113
128
data = { wpmData }
114
- margin = { { right : 25 , left : 25 , bottom : 50 } }
129
+ margin = { { right : 25 , left : 25 , bottom : 100 } }
115
130
>
116
131
< CartesianGrid strokeDasharray = "3 3" />
117
132
< XAxis dataKey = "gameNumber" />
@@ -126,43 +141,54 @@ export default function DashboardPage() {
126
141
/>
127
142
</ ComposedChart >
128
143
</ ResponsiveContainer >
129
- </ div >
144
+ </ Card >
130
145
</ div >
131
146
< div className = "flex max-[850px]:flex-col justify-center items-center w-screen min-[850px]:h-[50vh] gap-4 m-4" >
132
- < div className = "w-[55vw] max-[850px]:w-[100vw] min-[850px]:h-[50vh] rounded-lg border-gray-400 border-2 border-opacity-50 mr-4 p-4" >
133
- < h2 className = "text-2xl font-bold text-center m-2" > Recent Races</ h2 >
134
- < table className = "w-full text-center max-[600px]:text-sm" >
135
- < tr >
136
- < th className = "max-[900px]:hidden" > Game ID</ th >
137
- < th > Errors</ th >
138
- < th > Accuracy</ th >
139
- < th > Wpm</ th >
140
- < th > Date</ th >
141
- </ tr >
142
- { recentGames . map ( ( game ) => {
143
- return (
144
- < tr className = "m-10" >
145
- < td className = "max-[900px]:hidden" > { game . gameId } </ td >
146
- < td className = "text-red-600 hover:text-red-500" >
147
- { game . wpm } Errors
148
- </ td >
149
- < td > { game . accuracy } %</ td >
150
- < td > { game . wpm } Wpm</ td >
151
- < td > { game . date } </ td >
152
- </ tr >
153
- ) ;
154
- } ) }
155
- </ table >
156
- </ div >
157
- < div className = "w-[40vw] max-[850px]:w-screen min-[850px]:h-[50vh] rounded-lg border-gray-400 border-2 border-opacity-50 mr-4" >
147
+ < Card className = "w-[55vw] max-[850px]:w-[100vw] min-[850px]:h-[50vh] mr-4 p-4" >
148
+ < CardHeader >
149
+ < CardTitle className = "text-center m-2" > Recent Races</ CardTitle >
150
+ </ CardHeader >
151
+ < Table className = "w-full max-[600px]:text-sm" >
152
+ < TableHeader >
153
+ < TableRow >
154
+ < TableHead className = "max-[900px]:hidden" > Game ID</ TableHead >
155
+ < TableHead > Errors</ TableHead >
156
+ < TableHead > Accuracy</ TableHead >
157
+ < TableHead > Wpm</ TableHead >
158
+ < TableHead > Date</ TableHead >
159
+ </ TableRow >
160
+ </ TableHeader >
161
+ < TableBody >
162
+ { recentGames . map ( ( game ) => {
163
+ return (
164
+ < TableRow key = { game . gameId } >
165
+ < TableCell className = "max-[900px]:hidden" >
166
+ { game . gameId }
167
+ </ TableCell >
168
+ < TableCell className = "text-red-600 hover:text-red-500" >
169
+ { game . wpm } Errors
170
+ </ TableCell >
171
+ < TableCell > { game . accuracy } %</ TableCell >
172
+ < TableCell > { game . wpm } Wpm</ TableCell >
173
+ < TableCell > { game . date } </ TableCell >
174
+ </ TableRow >
175
+ ) ;
176
+ } ) }
177
+ </ TableBody >
178
+ </ Table >
179
+ </ Card >
180
+ < Card className = "w-[40vw] max-[850px]:w-screen min-[850px]:h-[50vh] mr-4" >
158
181
< h2 className = "text-2xl font-bold text-center m-2" > Achievements</ h2 >
159
182
{ achievements . map ( ( achievement ) => {
160
183
return (
161
- < div className = "border-gray-500 border-2 border-opacity-50 rounded-lg m-4 p-4 flex justify-between" >
162
- < div >
163
- < p className = "font-bold min-[850px]:text-xl text-md" > { achievement . title } </ p >
164
- < p className = "font-normal min-[850px]:text-xs text-sm" > { achievement . description } </ p >
165
- </ div >
184
+ < Card
185
+ className = "m-4 p-4 flex justify-between"
186
+ key = { achievement . id }
187
+ >
188
+ < CardHeader >
189
+ < CardTitle > { achievement . title } </ CardTitle >
190
+ < CardDescription > { achievement . description } </ CardDescription >
191
+ </ CardHeader >
166
192
{ achievement . progress > 50 ? (
167
193
< p className = "font-normal text-green-500 mt-auto mb-auto" >
168
194
{ achievement . progress } %
@@ -172,10 +198,10 @@ export default function DashboardPage() {
172
198
{ achievement . progress } %
173
199
</ p >
174
200
) }
175
- </ div >
201
+ </ Card >
176
202
) ;
177
203
} ) }
178
- </ div >
204
+ </ Card >
179
205
</ div >
180
206
</ >
181
207
) ;
0 commit comments