@@ -3,29 +3,36 @@ import { Metadata } from "next";
3
3
import { Suspense } from "react" ;
4
4
5
5
export const metadata : Metadata = {
6
- title : "Race History"
6
+ title : "Race History" ,
7
7
} ;
8
8
9
9
async function RaceHistoryCard ( ) {
10
10
const historyMatches = [
11
11
{
12
+ id : "1" ,
12
13
date : "March 20, 2023" ,
13
14
averageSpeed : 2000 ,
14
15
versus : "Xx_deadlyMamba_xX" ,
15
- status : "lost"
16
- } , {
16
+ status : "lost" ,
17
+ } ,
18
+ {
19
+ id : "2" ,
17
20
date : "March 21, 2023" ,
18
21
averageSpeed : 1000 ,
19
22
versus : "funnyGuy123" ,
20
- status : "won"
21
- } , {
23
+ status : "won" ,
24
+ } ,
25
+ {
26
+ id : "3" ,
22
27
date : "April 22, 2023" ,
23
28
averageSpeed : 10000 ,
24
29
versus : "masterOfAll" ,
25
- status : "draw"
26
- }
30
+ status : "draw" ,
31
+ } ,
27
32
] ;
28
- { /** Dynamic data coming soon... */ }
33
+ {
34
+ /** Dynamic data coming soon... */
35
+ }
29
36
const descendingOrder = historyMatches . sort ( ( a , b ) => {
30
37
if ( new Date ( a . date ) > new Date ( b . date ) ) {
31
38
return - 1 ;
@@ -40,40 +47,48 @@ async function RaceHistoryCard() {
40
47
41
48
return (
42
49
< section className = "grid grid-cols-[1fr] 2xl:grid-cols-[1fr,1fr] gap-x-8 gap-y-4" >
43
- {
44
- descendingOrder . map ( match => {
45
- let name = match . versus ;
46
- /** If the name length > 11 chars, then cut it. This is to avoid overflows */
47
- if ( match . versus . length > 11 ) {
48
- name = ` ${ match . versus . slice ( 0 , 11 ) } ...` ;
49
- }
50
- const statusColor = match . status === "won"
50
+ { descendingOrder . map ( ( match ) => {
51
+ let name = match . versus ;
52
+ /** If the name length > 11 chars, then cut it. This is to avoid overflows */
53
+ if ( match . versus . length > 11 ) {
54
+ name = ` ${ match . versus . slice ( 0 , 11 ) } ...` ;
55
+ }
56
+ const statusColor =
57
+ match . status === "won"
51
58
? "text-green-400"
52
59
: match . status === "lost"
53
- ? "text-destructive"
54
- : "text-yellow-400"
55
- return (
56
- (
57
- /** This container can be a button or link which leads
58
- * to a page that'll give more information about the
59
- * match.
60
- */
61
- < div className = "text-center shadow-md shadow-monochrome-low-opacity flex gap-4 md:gap-8 justify-between items-center bg-secondary py-2 px-4 md:py-4 md:px-8 rounded-md" >
62
- < div className = "flex-[0.85] text-start" >
63
- < h2 className = "text-base md:text-lg font-medium" > Battled vs. { name } </ h2 >
64
- < span className = "text-xs md:text-sm" > Last: < Time date = { new Date ( match . date ) } /> </ span >
65
- </ div >
66
- < span className = { `${ statusColor } flex-[0.125] font-bold text-sm md:text-lg inline-block` } > { match . status . toUpperCase ( ) } </ span >
67
- { /**Some kind of circle here to indicate how good the speed is */ }
68
- < div className = "flex-[0.125]" > { match . averageSpeed / 1000 } s</ div >
69
- </ div >
70
- )
71
- )
72
- } )
73
- }
60
+ ? "text-destructive"
61
+ : "text-yellow-400" ;
62
+ return (
63
+ /** This container can be a button or link which leads
64
+ * to a page that'll give more information about the
65
+ * match.
66
+ */
67
+ < div
68
+ key = { match . id }
69
+ className = "text-center shadow-md shadow-monochrome-low-opacity flex gap-4 md:gap-8 justify-between items-center bg-secondary py-2 px-4 md:py-4 md:px-8 rounded-md"
70
+ >
71
+ < div className = "flex-[0.85] text-start" >
72
+ < h2 className = "text-base md:text-lg font-medium" >
73
+ Battled vs. { name }
74
+ </ h2 >
75
+ < span className = "text-xs md:text-sm" >
76
+ Last: < Time date = { new Date ( match . date ) } />
77
+ </ span >
78
+ </ div >
79
+ < span
80
+ className = { `${ statusColor } flex-[0.125] font-bold text-sm md:text-lg inline-block` }
81
+ >
82
+ { match . status . toUpperCase ( ) }
83
+ </ span >
84
+ { /**Some kind of circle here to indicate how good the speed is */ }
85
+ < div className = "flex-[0.125]" > { match . averageSpeed / 1000 } s</ div >
86
+ </ div >
87
+ ) ;
88
+ } ) }
74
89
</ section >
75
90
) ;
76
- } ;
91
+ }
77
92
78
93
export default function RaceHistoryPage ( ) {
79
94
return (
@@ -84,4 +99,4 @@ export default function RaceHistoryPage() {
84
99
</ Suspense >
85
100
</ article >
86
101
) ;
87
- } ;
102
+ }
0 commit comments