import { useState } from 'react'; import { Card, CardContent } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs"; import { BarChart, Bar, XAxis, YAxis, Tooltip, ResponsiveContainer } from 'recharts'; import Image from "next/image"; import nhpaLogo from "/mnt/data/NHPA-Logo-Final.ai"; export default function PickleballStatsApp() { const [matchInfo, setMatchInfo] = useState({ date: '', tournament: '', player: '', matchType: 'singles', partner: '', opponents: ['', ''] }); const [score, setScore] = useState({ me: 0, opponent: 0 }); const [stats, setStats] = useState({ points: { active: 0, passive: 0 }, errors: { forced: 0, unforced: 0 }, actions: { serve: [0, 0], drive: [0, 0], deepDink: [0, 0], volley: [0, 0], shortDink: [0, 0], smash: [0, 0], lob: [0, 0], erne: [0, 0], atp: [0, 0], reset: [0, 0] } }); const [showSummary, setShowSummary] = useState(false); const addPoint = (type) => { const newScore = { ...score }; newScore.me++; setScore(newScore); setStats(prev => ({ ...prev, points: { ...prev.points, [type]: prev.points[type] + 1 } })); }; const addError = (type) => { const newScore = { ...score }; newScore.opponent++; setScore(newScore); setStats(prev => ({ ...prev, errors: { ...prev.errors, [type]: prev.errors[type] + 1 } })); }; const updateAction = (action, index) => { setStats(prev => { const updated = { ...prev.actions }; updated[action] = [...updated[action]]; updated[action][index]++; return { ...prev, actions: updated }; }); }; const renderActionButtons = () => ( Object.entries(stats.actions).map(([key, [success, fail]]) => (
{key}
{success}
{fail}
)) ); const totalSuccess = Object.values(stats.actions).reduce((sum, [succ]) => sum + succ, 0); const totalFail = Object.values(stats.actions).reduce((sum, [, fail]) => sum + fail, 0); const renderSummary = () => (
南海匹克球协会
比赛:{matchInfo.tournament}({matchInfo.date})
类型:{matchInfo.matchType === 'singles' ? '单打' : `双打(拍档:${matchInfo.partner})`}
本人:{matchInfo.player}
对手:{matchInfo.opponents.filter(Boolean).join('、')}
比分:{score.me} - {score.opponent}
主动得分:{stats.points.active},被动得分:{stats.points.passive}
受迫失分:{stats.errors.forced},非受迫失分:{stats.errors.unforced}
技术动作:成功 {totalSuccess} 项,失误 {totalFail} 项
); return (
南海匹克球协会技术统计专用
setMatchInfo({ ...matchInfo, date: e.target.value })} /> setMatchInfo({ ...matchInfo, tournament: e.target.value })} /> setMatchInfo({ ...matchInfo, player: e.target.value })} /> setMatchInfo({ ...matchInfo, matchType: v })}> 单打 双打 setMatchInfo({ ...matchInfo, partner: e.target.value })} /> setMatchInfo({ ...matchInfo, opponents: [e.target.value, matchInfo.opponents[1]] })} /> setMatchInfo({ ...matchInfo, opponents: [matchInfo.opponents[0], e.target.value] })} />

比分:{score.me} - {score.opponent}

技术动作统计

{renderActionButtons()}
总成功数:{totalSuccess},总失误数:{totalFail}

图表预览(主动/被动 vs 失误)

{showSummary && (

比赛统计结果

{renderSummary()}
)}
); }