From a50e3cfe2d796576dded74d4da2fac7f50a74bb3 Mon Sep 17 00:00:00 2001 From: jsg5625 Date: Sat, 11 Jan 2025 18:32:57 +0100 Subject: [PATCH 1/2] Improved player card UI --- src/components/PlayerCard.tsx | 154 ++++++++++++++++++---------------- 1 file changed, 84 insertions(+), 70 deletions(-) diff --git a/src/components/PlayerCard.tsx b/src/components/PlayerCard.tsx index 005ac16..0fa41d3 100644 --- a/src/components/PlayerCard.tsx +++ b/src/components/PlayerCard.tsx @@ -1,167 +1,181 @@ -import { User, Trash2, Edit } from 'lucide-react'; -import { useState } from 'react'; -import { Player } from '../types'; -import { calculateWinRate, calculateScore } from '../utils/playerStats'; +import { User, Trash2, Edit } from 'lucide-react' +import { useState } from 'react' +import { Player } from '../types' +import { calculateWinRate, calculateScore } from '../utils/playerStats' interface PlayerCardProps { - player: Player; - onDelete?: (id: string) => void; - onEdit?: (id: string, updatedData: Partial>) => void; + player: Player + onDelete?: (id: string) => void + onEdit?: (id: string, updatedData: Partial>) => void } -export function PlayerCard({ player, onDelete, onEdit }: PlayerCardProps) { - const [isEditing, setIsEditing] = useState(false); +export function PlayerCard ({ player, onDelete, onEdit }: PlayerCardProps) { + const [isEditing, setIsEditing] = useState(false) const [editedData, setEditedData] = useState>>({ name: player.name, matches: player.matches, goals: player.goals, - assists: player.assists, - }); + assists: player.assists + }) - const winRate = calculateWinRate(player); - const score = calculateScore(player); + const winRate = calculateWinRate(player) + const score = calculateScore(player) const handleEdit = () => { - setIsEditing(true); - }; + setIsEditing(true) + } const handleSave = () => { if (onEdit) { - onEdit(player.id, editedData); + onEdit(player.id, editedData) } - setIsEditing(false); - }; + setIsEditing(false) + } const handleCancel = () => { setEditedData({ name: player.name, matches: player.matches, goals: player.goals, - assists: player.assists, - }); - setIsEditing(false); - }; + assists: player.assists + }) + setIsEditing(false) + } return ( -
-
-
- -

{player.name}

+
+ {/* Header */} +
+
+ +

{player.name}

-
+
{onEdit && ( )} {onDelete && ( )}
-
+ + {/* Stats Grid */} +
-

Partidos jugados

-

{player.matches}

+

Partidos V/E/D

+

+ {player.wins}/{player.matches - player.wins - player.losses}/ + {player.losses} +

-

Tasa de victorias

-

{winRate.toFixed(1)}%

+

Tasa de victorias

+

+ {winRate.toFixed(1)}% +

-

Goles

-

{player.goals}

+

Goles

+

{player.goals}

-

Asistencias

-

{player.assists}

+

Asistencias

+

{player.assists}

-
-

Puntuación del jugador

-

{score.toFixed(1)}

+ + {/* Player Score */} +
+

Puntuación del jugador

+

+ {score.toFixed(1)} +

{/* Modal for editing */} {isEditing && ( -
-
-

Edit Player

-
+
+
+

Edit Player

+
-
-
-
-
-
+
@@ -170,5 +184,5 @@ export function PlayerCard({ player, onDelete, onEdit }: PlayerCardProps) {
)}
- ); + ) } From 3bf38e9380206ba0d1a093a1fcbcfdd34fcc2bde Mon Sep 17 00:00:00 2001 From: jsg5625 Date: Sat, 11 Jan 2025 18:35:31 +0100 Subject: [PATCH 2/2] Improved match cards UI and added grid --- src/App.tsx | 2 +- src/components/MatchCard.tsx | 64 +++++++++++++++++++++--------------- 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 69eb05f..6456671 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -46,7 +46,7 @@ function App() { {/* Tab Content */} {activeTab === 'matches' && ( -
+
{matches.length > 0 ? ( matches.map(match => ( diff --git a/src/components/MatchCard.tsx b/src/components/MatchCard.tsx index 0b48c66..c4b5fcf 100644 --- a/src/components/MatchCard.tsx +++ b/src/components/MatchCard.tsx @@ -29,60 +29,70 @@ export function MatchCard({ match, onEdit, onDelete }: MatchCardProps) { }; return ( -
-
-
- - {format(new Date(match.date), 'PPP', { locale: es })} +
+ {/* Header */} +
+
+ + {format(new Date(match.date), 'PPP', { locale: es })}
-
+
- -
+ + {/* Match Details */} +
+ {/* Team A */}
-
Equipo A
-
{match.teamA.score}
-
+
Equipo A
+
{match.teamA.score}
+
{match.teamA.players.map(p => p.name).join(', ')}
- -
vs
- + +
vs
+ + {/* Team B */}
-
Equipo B
-
{match.teamB.score}
-
+
Equipo B
+
{match.teamB.score}
+
{match.teamB.players.map(p => p.name).join(', ')}
- + + {/* Goals */} {match.goals.length > 0 && ( -
-
- - Goles +
+
+ + Goles
-
+
{match.goals.map((goal, index) => ( -
+
{`${match.teamA.players.concat(match.teamB.players).find(p => p.id === goal.playerId)?.name} (${goal.minute}')`} - {goal.assistById && ` - Asistencia: ${match.teamA.players.concat(match.teamB.players).find(p => p.id === goal.assistById)?.name}`} + {goal.assistById && ( + - Asistencia: {match.teamA.players.concat(match.teamB.players).find(p => p.id === goal.assistById)?.name} + )}
))}