-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Enhance UI for live scores and standings, refactor data types f… #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,69 +43,130 @@ export function LiveScoreCard() { | |
|
|
||
| return ( | ||
| <Card key={match.id} className="glass glass-hover border-primary/30"> | ||
| <CardHeader> | ||
| <div className="flex justify-between items-center"> | ||
| <Badge className="neon-glow bg-primary/20 text-primary border-primary/50"> | ||
| <div className="w-2 h-2 bg-primary rounded-full animate-pulse mr-2"></div> | ||
| LIVE | ||
| </Badge> | ||
| <div className="flex items-center gap-2 text-sm text-muted-foreground"> | ||
| <MapPin className="h-4 w-4" /> | ||
| {match.venue} | ||
| </div> | ||
| </div> | ||
| </CardHeader> | ||
| <CardContent className="space-y-6"> | ||
| {/* Team 1 */} | ||
| <div className="flex justify-between items-center p-4 glass rounded-lg"> | ||
| <div> | ||
| <h3 className="text-xl font-bold">{match.team1?.name}</h3> | ||
| <p className="text-sm text-muted-foreground">Innings {team1Score?.innings || 1}</p> | ||
| </div> | ||
| <div className="text-right"> | ||
| <div className="text-2xl font-bold text-primary"> | ||
| {team1Score?.runs || 0}/{team1Score?.wickets || 0} | ||
| </div> | ||
| <div className="text-sm text-muted-foreground">({team1Score?.overs || 0.0} overs)</div> | ||
| <div className="text-xs text-secondary">RR: {team1Score?.current_rr?.toFixed(2) || "0.00"}</div> | ||
| </div> | ||
| </div> | ||
| <CardHeader> | ||
| <div className="flex justify-between items-center"> | ||
| <Badge className="neon-glow bg-primary/20 text-primary border-primary/50"> | ||
| <div className="w-2 h-2 bg-primary rounded-full animate-pulse mr-2"></div> | ||
| LIVE | ||
| </Badge> | ||
| <div className="flex items-center gap-2 text-sm text-muted-foreground"> | ||
| <MapPin className="h-4 w-4" /> | ||
| {match.venue} | ||
| </div> | ||
| </div> | ||
| </CardHeader> | ||
| <CardContent className="space-y-6"> | ||
| <div className="grid grid-cols-1 md:grid-cols-3 gap-3"> | ||
| {/* Team 1 - Stacked Layout */} | ||
| <div className="p-4 glass rounded-lg"> | ||
| <div className="flex items-center gap-3 mb-3"> | ||
| <div className="w-10 h-10 rounded-full bg-primary/20 flex items-center justify-center"> | ||
| <span className="text-sm font-bold text-primary">{match.team1?.shortCode || 'T1'}</span> | ||
| </div> | ||
| <div> | ||
| <h3 className="text-xl font-bold">{match.team1?.name}</h3> | ||
| <p className="text-sm text-muted-foreground">Innings {team1Score?.innings || 1}</p> | ||
| </div> | ||
| </div> | ||
|
|
||
| {/* Score Stacked Below Team Info */} | ||
| <div className="grid grid-cols-2 gap-4 text-center"> | ||
| <div className="space-y-1"> | ||
| <div className="text-3xl font-bold text-primary"> | ||
| {team1Score?.runs || 0}<span className="text-red-400">/</span>{team1Score?.wickets || 0} | ||
| </div> | ||
| <div className="text-sm text-muted-foreground">Runs/Wickets</div> | ||
| </div> | ||
| <div className="space-y-1"> | ||
| <div className="text-lg font-bold text-primary">{team1Score?.overs?.toFixed(1) || 0.0}</div> | ||
| <div className="text-sm text-muted-foreground">Overs</div> | ||
| <div className="text-xs text-secondary">RR: {team1Score?.current_rr?.toFixed(2) || "0.00"}</div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| {/* Team 2 */} | ||
| <div className="flex justify-between items-center p-4 glass rounded-lg"> | ||
| <div> | ||
| <h3 className="text-xl font-bold">{match.team2?.name}</h3> | ||
| <p className="text-sm text-muted-foreground">Innings {team2Score?.innings || 1}</p> | ||
| </div> | ||
| <div className="text-right"> | ||
| <div className="text-2xl font-bold text-primary"> | ||
| {team2Score?.runs || 0}/{team2Score?.wickets || 0} | ||
| </div> | ||
| <div className="text-sm text-muted-foreground">({team2Score?.overs || 0.0} overs)</div> | ||
| {team2Score?.required_rr && ( | ||
| <div className="text-xs text-secondary">Req RR: {team2Score.required_rr.toFixed(2)}</div> | ||
| )} | ||
| </div> | ||
| </div> | ||
| {/* Match Center Info */} | ||
| <div className="glass rounded-lg p-4 text-center space-y-3"> | ||
| {team2Score?.required_rr && ( | ||
| <div className="space-y-1"> | ||
| <div className="text-lg font-bold">Target: {team1Score?.runs || 0}</div> | ||
| <div className="text-sm text-muted-foreground"> | ||
| Need {team1Score?.runs - (team2Score?.runs || 0)} runs • | ||
| Req RR: {team2Score.required_rr.toFixed(2)} | ||
| </div> | ||
| </div> | ||
| )} | ||
|
|
||
| <div className="space-y-2"> | ||
| <h4 className="font-semibold text-sm">{match.currentOver?.number || 6}th over</h4> | ||
| <div className="flex justify-center gap-1"> | ||
| {match.currentOver?.balls?.map((ball, index) => ( | ||
|
Comment on lines
+101
to
+103
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P1] Match type missing current over data The UI now reads Useful? React with 👍 / 👎. |
||
| <span key={index} className={`w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold ${ | ||
| ball === 'W' ? 'bg-red-500/30 text-red-300' : | ||
| ball === '4' ? 'bg-green-500/30 text-green-300' : | ||
| ball === '6' ? 'bg-purple-500/30 text-purple-300' : | ||
| 'bg-white/10 text-muted-foreground' | ||
| }`}> | ||
| {ball} | ||
| </span> | ||
| )) || ['.', '.', '.', '.', '.', '.'].map((ball, index) => ( | ||
| <span key={index} className="w-6 h-6 rounded-full bg-white/10 flex items-center justify-center text-muted-foreground text-xs"> | ||
| {ball} | ||
| </span> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div className="flex gap-3"> | ||
| <Button size="sm" className="flex-1" asChild> | ||
| <Link href={`/match/${match.id}`}> | ||
| <Target className="mr-2 h-4 w-4" /> | ||
| Ball by Ball | ||
| </Link> | ||
| </Button> | ||
| <Button size="sm" variant="secondary" className="flex-1" asChild> | ||
| <Link href={`/match/${match.id}/scorecard`}> | ||
| <TrendingUp className="mr-2 h-4 w-4" /> | ||
| Scorecard | ||
| </Link> | ||
| </Button> | ||
| </div> | ||
| </CardContent> | ||
| </Card> | ||
| ) | ||
| })} | ||
| {/* Team 2 - Stacked Layout */} | ||
| <div className="p-4 glass rounded-lg"> | ||
| <div className="flex items-center gap-3 mb-3"> | ||
| <div className="w-10 h-10 rounded-full bg-primary/20 flex items-center justify-center"> | ||
| <span className="text-sm font-bold text-primary">{match.team2?.shortCode || 'T2'}</span> | ||
| </div> | ||
| <div> | ||
| <h3 className="text-xl font-bold">{match.team2?.name}</h3> | ||
| <p className="text-sm text-muted-foreground">Innings {team2Score?.innings || 1}</p> | ||
| </div> | ||
| </div> | ||
|
|
||
| {/* Score Stacked Below Team Info */} | ||
| <div className="grid grid-cols-2 gap-4 text-center"> | ||
| <div className="space-y-1"> | ||
| <div className="text-3xl font-bold text-primary"> | ||
| {team2Score?.runs || 0}<span className="text-red-400">/</span>{team2Score?.wickets || 0} | ||
| </div> | ||
| <div className="text-sm text-muted-foreground">Runs/Wickets</div> | ||
| </div> | ||
| <div className="space-y-1"> | ||
| <div className="text-lg font-bold text-primary">{team2Score?.overs?.toFixed(1) || 0.0}</div> | ||
| <div className="text-sm text-muted-foreground">Overs</div> | ||
| {team2Score?.required_rr ? ( | ||
| <div className="text-xs text-secondary">Req RR: {team2Score.required_rr.toFixed(2)}</div> | ||
| ) : ( | ||
| <div className="text-xs text-secondary">RR: {team2Score?.current_rr?.toFixed(2) || "0.00"}</div> | ||
| )} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ) | ||
|
|
||
| <div className="flex gap-3"> | ||
| <Button size="sm" className="flex-1" asChild> | ||
| <Link href={`/match/${match.id}`}> | ||
| <Target className="mr-2 h-4 w-4" /> | ||
| Ball by Ball | ||
| </Link> | ||
| </Button> | ||
| <Button size="sm" variant="secondary" className="flex-1" asChild> | ||
| <Link href={`/match/${match.id}/scorecard`}> | ||
| <TrendingUp className="mr-2 h-4 w-4" /> | ||
| Scorecard | ||
| </Link> | ||
| </Button> | ||
| </div> | ||
| </CardContent> | ||
| </Card>) | ||
| })} | ||
| </div>) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| export interface TeamInfo { | ||
| name: string; | ||
| } | ||
|
|
||
| export interface ScoreboardEntry { | ||
| id: string; | ||
| runs: number; | ||
| overs: number; | ||
| innings: 1 | 2; | ||
| team_id: string; | ||
| wickets: number; | ||
| match_id: string; | ||
| current_rr: number; | ||
| updated_at: string; | ||
| required_rr: number | null; | ||
| } | ||
|
|
||
| export interface Match { | ||
| id: string; | ||
| team1_id: string; | ||
| team2_id: string; | ||
| venue: string; | ||
| match_date: string; | ||
| status: "completed" | "ongoing" | "upcoming"; // expanded based on possible values | ||
| winner_id: string | null; | ||
| toss_winner_id: string; | ||
| elected_to: "bat" | "bowl"; | ||
| created_at: string; | ||
| overs_per_innings: number; | ||
| team1: TeamInfo; | ||
| team2: TeamInfo; | ||
| winner: TeamInfo | null; | ||
| scoreboard: ScoreboardEntry[]; | ||
| } | ||
|
|
||
| export type Matches = Match[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Extend TeamInfo to cover short codes
The new
Matchestypings only give a teamname, yet the live score card rendersmatch.team1?.shortCodeas part of the UI. With the stricter typing introduced in this commit, runningnpx tsc --noEmitfails (TS2339: Property 'shortCode' does not exist on type 'TeamInfo'). Either add an optionalshortCodefield toTeamInfoor stop referencing it so type checking doesn’t break.Useful? React with 👍 / 👎.