@@ -3,29 +3,36 @@ import { Metadata } from "next";
33import { Suspense } from "react" ;
44
55export const metadata : Metadata = {
6- title : "Race History"
6+ title : "Race History" ,
77} ;
88
99async function RaceHistoryCard ( ) {
1010 const historyMatches = [
1111 {
12+ id : "1" ,
1213 date : "March 20, 2023" ,
1314 averageSpeed : 2000 ,
1415 versus : "Xx_deadlyMamba_xX" ,
15- status : "lost"
16- } , {
16+ status : "lost" ,
17+ } ,
18+ {
19+ id : "2" ,
1720 date : "March 21, 2023" ,
1821 averageSpeed : 1000 ,
1922 versus : "funnyGuy123" ,
20- status : "won"
21- } , {
23+ status : "won" ,
24+ } ,
25+ {
26+ id : "3" ,
2227 date : "April 22, 2023" ,
2328 averageSpeed : 10000 ,
2429 versus : "masterOfAll" ,
25- status : "draw"
26- }
30+ status : "draw" ,
31+ } ,
2732 ] ;
28- { /** Dynamic data coming soon... */ }
33+ {
34+ /** Dynamic data coming soon... */
35+ }
2936 const descendingOrder = historyMatches . sort ( ( a , b ) => {
3037 if ( new Date ( a . date ) > new Date ( b . date ) ) {
3138 return - 1 ;
@@ -40,40 +47,48 @@ async function RaceHistoryCard() {
4047
4148 return (
4249 < 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"
5158 ? "text-green-400"
5259 : 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+ } ) }
7489 </ section >
7590 ) ;
76- } ;
91+ }
7792
7893export default function RaceHistoryPage ( ) {
7994 return (
@@ -84,4 +99,4 @@ export default function RaceHistoryPage() {
8499 </ Suspense >
85100 </ article >
86101 ) ;
87- } ;
102+ }
0 commit comments