import React, { useState } from ‘react’;
import { Card, CardContent, CardHeader, CardTitle } from ‘@/components/ui/card’;
import { Button } from ‘@/components/ui/button’;
import { Input } from ‘@/components/ui/input’;
import { TextArea } from ‘@/components/ui/textarea’;
import { Plus, Trash2, FileText } from ‘lucide-react’;

const generateMatchSummary = (match) => {
const result = `Partido entre ${match.homeTeam} y ${match.awayTeam}

Resultado Final: ${match.homeTeam} ${match.homeScore} – ${match.awayScore} ${match.awayTeam}

Goleadores:
${match.homeTeam}: ${match.homeGoalscorers.length > 0 ? match.homeGoalscorers.join(‘, ‘) : ‘No hubo goles’}
${match.awayTeam}: ${match.awayGoalscorers.length > 0 ? match.awayGoalscorers.join(‘, ‘) : ‘No hubo goles’}

${match.homeScore > match.awayScore
? `Victoria para ${match.homeTeam}`
: match.homeScore < match.awayScore ? `Victoria para ${match.awayTeam}` : 'Partido terminó en empate'} `; return result; }; const FootballResultsApp = () => {
const [matches, setMatches] = useState([]);
const [homeTeam, setHomeTeam] = useState(»);
const [awayTeam, setAwayTeam] = useState(»);
const [homeScore, setHomeScore] = useState(»);
const [awayScore, setAwayScore] = useState(»);
const [homeGoalscorers, setHomeGoalscorers] = useState(»);
const [awayGoalscorers, setAwayGoalscorers] = useState(»);

const addMatch = () => {
if (homeTeam && awayTeam && homeScore !== » && awayScore !== ») {
const newMatch = {
id: Date.now(),
homeTeam,
awayTeam,
homeScore: parseInt(homeScore),
awayScore: parseInt(awayScore),
homeGoalscorers: homeGoalscorers.split(‘,’).map(name => name.trim()).filter(name => name !== »),
awayGoalscorers: awayGoalscorers.split(‘,’).map(name => name.trim()).filter(name => name !== »)
};
setMatches([…matches, newMatch]);
// Reset input fields
setHomeTeam(»);
setAwayTeam(»);
setHomeScore(»);
setAwayScore(»);
setHomeGoalscorers(»);
setAwayGoalscorers(»);
}
};

const deleteMatch = (id) => {
setMatches(matches.filter(match => match.id !== id));
};

const [selectedSummary, setSelectedSummary] = useState(»);

return (


Resultados de Fútbol

setHomeTeam(e.target.value)}
/>
setHomeScore(e.target.value)}
className=»w-24″
/>

setHomeGoalscorers(e.target.value)}
/>

setAwayTeam(e.target.value)}
/>
setAwayScore(e.target.value)}
className=»w-24″
/>

setAwayGoalscorers(e.target.value)}
/>

{matches.length > 0 && (

Resultados

{matches.map((match) => (


{match.homeTeam} {match.homeScore} – {match.awayScore} {match.awayTeam}


{match.homeGoalscorers.length > 0 && (

Goleadores {match.homeTeam}: {match.homeGoalscorers.join(‘, ‘)}

)}
{match.awayGoalscorers.length > 0 && (

Goleadores {match.awayTeam}: {match.awayGoalscorers.join(‘, ‘)}

)}

))}

)}

{selectedSummary && (

Resumen del Partido