Spaces:
Sleeping
Sleeping
Download src/components/ProLeagueView.tsx from Musabek/NOVAESPORT: direct link, hf CLI and curl.
- Browser
- Download file 42.6 kB
-
https://huggingface.co/spaces/Musabek/NOVAESPORT/resolve/main/src/components/ProLeagueView.tsx
- Command line
-
hf download hf://spaces/Musabek/NOVAESPORT/src/components/ProLeagueView.tsx
-
curl -L -o ProLeagueView.tsx https://huggingface.co/spaces/Musabek/NOVAESPORT/resolve/main/src/components/ProLeagueView.tsx
42.6 kB
| import React, { useState } from 'react'; | |
| import { Team, User } from '../types'; | |
| import { Award, ShieldAlert, Sparkles, Trophy, Users, Star, Target, Check, Facebook, Twitter, Send, Globe, X, Scale, Newspaper } from 'lucide-react'; | |
| import { ResponsiveContainer, AreaChart, Area, Radar, RadarChart, PolarGrid, PolarAngleAxis, PolarRadiusAxis, Legend, Tooltip } from 'recharts'; | |
| import { motion, AnimatePresence } from 'motion/react'; | |
| interface ProLeagueViewProps { | |
| teams: Team[]; | |
| currentUser: User | null; | |
| currentLanguage?: string; | |
| } | |
| // Helper to construct a realistic points progression history over time for the sparkline chart | |
| const getPointsHistory = (team: Team, lang: string = 'EN') => { | |
| const w = team.matchesWon ?? 0; | |
| const d = team.draws ?? 0; | |
| const l = team.losses ?? 0; | |
| const m = team.matchesPlayed ?? 0; | |
| // Base date representing mid-March start of typical Uzbekistan Pro Liga | |
| const baseDate = new Date(2026, 2, 14); // March 14, 2026 | |
| const formatDate = (idx: number) => { | |
| const d = new Date(baseDate); | |
| d.setDate(baseDate.getDate() + idx * 7); | |
| if (lang === 'UZ') { | |
| return d.toLocaleDateString('uz-UZ', { day: 'numeric', month: 'long', year: 'numeric' }); | |
| } else if (lang === 'RU') { | |
| return d.toLocaleDateString('ru-RU', { day: 'numeric', month: 'long', year: 'numeric' }); | |
| } else { | |
| return d.toLocaleDateString('en-US', { day: 'numeric', month: 'long', year: 'numeric' }); | |
| } | |
| }; | |
| // If no matches played, render a flat line with slightly moving dummy starts to indicate presence | |
| if (m === 0) { | |
| return [ | |
| { day: 0, val: 0, date: formatDate(0) }, | |
| { day: 1, val: 0, date: formatDate(1) }, | |
| { day: 2, val: 0, date: formatDate(2) }, | |
| { day: 3, val: 0, date: formatDate(3) } | |
| ]; | |
| } | |
| // Interleave outcomes to form a realistic distribution of points over the match history | |
| const outcomes: number[] = []; | |
| let winsLeft = w; | |
| let drawsLeft = d; | |
| let lossesLeft = l; | |
| for (let i = 0; i < m; i++) { | |
| if (i % 3 === 0 && winsLeft > 0) { | |
| outcomes.push(3); | |
| winsLeft--; | |
| } else if (i % 3 === 1 && drawsLeft > 0) { | |
| outcomes.push(1); | |
| drawsLeft--; | |
| } else if (lossesLeft > 0) { | |
| outcomes.push(0); | |
| lossesLeft--; | |
| } else if (winsLeft > 0) { | |
| outcomes.push(3); | |
| winsLeft--; | |
| } else if (drawsLeft > 0) { | |
| outcomes.push(1); | |
| drawsLeft--; | |
| } else { | |
| outcomes.push(0); | |
| } | |
| } | |
| const history = [{ day: 0, val: 0, date: formatDate(0) }]; | |
| let currentPoints = 0; | |
| for (let i = 0; i < outcomes.length; i++) { | |
| currentPoints += outcomes[i]; | |
| history.push({ day: i + 1, val: currentPoints, date: formatDate(i + 1) }); | |
| } | |
| // Ensure last point aligns exactly with team points (handles point penalitative modifications or manually set values) | |
| if (team.points !== undefined && history[history.length - 1].val !== team.points) { | |
| history[history.length - 1].val = team.points; | |
| } | |
| return history; | |
| }; | |
| export const ProLeagueView: React.FC<ProLeagueViewProps> = ({ teams = [], currentUser, currentLanguage = 'EN' }) => { | |
| const favoriteTeamIds = currentUser?.favoriteTeams || []; | |
| // Filter teams with gameType 'pro_league' or 'pro' added in Firestore | |
| const proTeams = teams.filter((t) => t.gameType === 'pro_league' || t.gameType === 'pro'); | |
| const baseTeams = proTeams; | |
| // Clone and sort the teams, placing favorites at the top | |
| const activeTeams = [...baseTeams].sort((a, b) => { | |
| const isAFavorite = favoriteTeamIds.includes(a.id); | |
| const isBFavorite = favoriteTeamIds.includes(b.id); | |
| if (isAFavorite && !isBFavorite) return -1; | |
| if (!isAFavorite && isBFavorite) return 1; | |
| if (b.points !== a.points) return b.points - a.points; | |
| return (a.rank || 99) - (b.rank || 99); | |
| }); | |
| const [isCompareOpen, setIsCompareOpen] = useState(false); | |
| const [toastMsg, setToastMsg] = useState(''); | |
| const triggerToast = (msg: string) => { | |
| setToastMsg(msg); | |
| setTimeout(() => setToastMsg(''), 4000); | |
| }; | |
| const [teamAId, setTeamAId] = useState<string>(''); | |
| const [teamBId, setTeamBId] = useState<string>(''); | |
| React.useEffect(() => { | |
| if (activeTeams.length > 0) { | |
| if (!teamAId || !activeTeams.some(t => t.id === teamAId)) { | |
| setTeamAId(activeTeams[0].id); | |
| } | |
| if (activeTeams.length > 1) { | |
| if (!teamBId || !activeTeams.some(t => t.id === teamBId)) { | |
| setTeamBId(activeTeams[1].id); | |
| } | |
| } else { | |
| setTeamBId(activeTeams[0].id); | |
| } | |
| } | |
| }, [activeTeams, teamAId, teamBId]); | |
| const [hoveredTeams, setHoveredTeams] = useState<string[]>([]); | |
| const [vsPosition, setVsPosition] = useState<{ top: number; height: number; center: number } | null>(null); | |
| React.useEffect(() => { | |
| if (hoveredTeams.length < 2) { | |
| setVsPosition(null); | |
| return; | |
| } | |
| const el1 = document.getElementById(`row-${hoveredTeams[0]}`); | |
| const el2 = document.getElementById(`row-${hoveredTeams[1]}`); | |
| if (el1 && el2) { | |
| const top1 = el1.offsetTop; | |
| const top2 = el2.offsetTop; | |
| const h1 = el1.offsetHeight; | |
| const h2 = el2.offsetHeight; | |
| const minTop = Math.min(top1, top2); | |
| const maxTop = Math.max(top1, top2); | |
| const maxH = top1 > top2 ? h1 : h2; | |
| const minH = top1 < top2 ? h1 : h2; | |
| const start = minTop + minH / 2; | |
| const end = maxTop + maxH / 2; | |
| setVsPosition({ | |
| top: minTop, | |
| height: (maxTop + maxH) - minTop, | |
| center: minTop + (maxTop + maxH - minTop) / 2 | |
| }); | |
| } | |
| }, [hoveredTeams]); | |
| const handleMouseEnterRow = (teamId: string) => { | |
| setHoveredTeams((prev) => { | |
| if (prev.includes(teamId)) return prev; | |
| return [...prev, teamId].slice(-2); | |
| }); | |
| }; | |
| const getTeamStats = (t?: Team) => { | |
| if (!t) return { pts: 0, wins: 0, draws: 0, losses: 0, goalsScored: 0, goalsConceded: 0, winRate: 0, defenseRating: 0, played: 0 }; | |
| const pts = t.points ?? 0; | |
| const wins = t.matchesWon ?? 0; | |
| const draws = t.draws ?? 0; | |
| const losses = t.losses ?? 0; | |
| const played = t.matchesPlayed ?? 0; | |
| let goalsScored = 0; | |
| let goalsConceded = 0; | |
| if (t.goals) { | |
| const parts = t.goals.split('-'); | |
| if (parts.length === 2) { | |
| goalsScored = parseInt(parts[0]) || 0; | |
| goalsConceded = parseInt(parts[1]) || 0; | |
| } | |
| } | |
| const winRate = played > 0 ? Math.round((wins / played) * 100) : 0; | |
| const avgConceded = played > 0 ? (goalsConceded / played) : 0; | |
| const defenseRating = Math.max(0, Math.min(10, Math.round(10 - avgConceded))); | |
| return { pts, wins, draws, losses, goalsScored, goalsConceded, winRate, defenseRating, played }; | |
| }; | |
| const handleToggleFavorite = async (teamId: string) => { | |
| if (!currentUser || currentUser.id === 'guest') { | |
| triggerToast(currentLanguage === 'UZ' ? "Jamoani tanlanganlarga qo'shish uchun avval tizimga kiring!" : "Please login to add a team to your favorites!"); | |
| return; | |
| } | |
| const currentFavorites = currentUser.favoriteTeams || []; | |
| let updatedFavorites: string[]; | |
| if (currentFavorites.includes(teamId)) { | |
| updatedFavorites = currentFavorites.filter(id => id !== teamId); | |
| } else { | |
| updatedFavorites = [...currentFavorites, teamId]; | |
| } | |
| try { | |
| const { doc, updateDoc } = await import('firebase/firestore'); | |
| const { db } = await import('../firebase'); | |
| const userRef = doc(db, 'users', currentUser.id); | |
| await updateDoc(userRef, { | |
| favoriteTeams: updatedFavorites | |
| }); | |
| } catch (err) { | |
| console.error("Failed to update favorite teams:", err); | |
| } | |
| }; | |
| // Render headers base on language | |
| const isUz = currentLanguage === 'UZ'; | |
| const labels = { | |
| rank: '#', | |
| team: isUz ? 'Jamoa' : 'Team / Club', | |
| played: "O'", | |
| won: "G'", | |
| drawn: 'D', | |
| lost: 'M', | |
| goals: '+/-', | |
| points: 'O', | |
| trend: isUz ? 'Trend' : 'Form', | |
| }; | |
| const cmpLabels = { | |
| compare: isUz ? "Jamoalarni solishtirish" : currentLanguage === "RU" ? "Сравнение команд" : "Compare Teams", | |
| teamA: isUz ? "1-Jamoa" : currentLanguage === "RU" ? "Команда 1" : "Team A", | |
| teamB: isUz ? "2-Jamoa" : currentLanguage === "RU" ? "Команда 2" : "Team B", | |
| attack: isUz ? "Hujumkorlik" : currentLanguage === "RU" ? "Атака" : "Attack", | |
| defense: isUz ? "Himoya" : currentLanguage === "RU" ? "Защита" : "Defense", | |
| wins: isUz ? "G'alabalar" : currentLanguage === "RU" ? "Победы" : "Wins", | |
| points: isUz ? "Ochkolar" : currentLanguage === "RU" ? "Очки" : "Points", | |
| winrate: isUz ? "G'alaba %" : currentLanguage === "RU" ? "% Побед" : "Win Rate %", | |
| played: isUz ? "O'yinlar" : currentLanguage === "RU" ? "Матчи" : "Matches", | |
| headToHead: isUz ? "Yuzma-yuz solishtirish" : currentLanguage === "RU" ? "Сравнение сил" : "Head-to-Head Comparison", | |
| close: isUz ? "Yopish" : currentLanguage === "RU" ? "Закрыть" : "Close", | |
| }; | |
| const selectedTeamA = activeTeams.find(t => t.id === teamAId) || activeTeams[0]; | |
| const selectedTeamB = activeTeams.find(t => t.id === teamBId) || activeTeams[1] || activeTeams[0]; | |
| const teamA = selectedTeamA || { id: '', name: 'Team A', logo: '🛡️', points: 0 }; | |
| const teamB = selectedTeamB || { id: '', name: 'Team B', logo: '🛡️', points: 0 }; | |
| const statsA = getTeamStats(teamA); | |
| const statsB = getTeamStats(teamB); | |
| const metrics = [ | |
| { name: cmpLabels.points, key: 'pts', fullMark: Math.max(...(activeTeams.map(t => t.points ?? 0).concat(10))) }, | |
| { name: cmpLabels.played, key: 'played', fullMark: Math.max(...(activeTeams.map(t => t.matchesPlayed ?? 0).concat(5))) }, | |
| { name: cmpLabels.wins, key: 'wins', fullMark: Math.max(...(activeTeams.map(t => t.matchesWon ?? 0).concat(5))) }, | |
| { name: cmpLabels.attack, key: 'goalsScored', fullMark: Math.max(...(activeTeams.map(t => { | |
| const parts = (t.goals || '0-0').split('-'); | |
| return parseInt(parts[0]) || 5; | |
| }).concat(10))) }, | |
| { name: cmpLabels.defense, key: 'defenseRating', fullMark: 10 }, | |
| { name: cmpLabels.winrate, key: 'winRate', fullMark: 100 }, | |
| ]; | |
| const chartData = metrics.map((metric) => { | |
| const scoreA = statsA[metric.key as keyof typeof statsA] ?? 0; | |
| const scoreB = statsB[metric.key as keyof typeof statsB] ?? 0; | |
| const normalizedA = Math.round((scoreA / metric.fullMark) * 100); | |
| const normalizedB = Math.round((scoreB / metric.fullMark) * 100); | |
| return { | |
| metric: metric.name, | |
| teamA_raw: scoreA, | |
| teamB_raw: scoreB, | |
| [teamA.name]: normalizedA, | |
| [teamB.name]: normalizedB, | |
| }; | |
| }); | |
| const isRu = currentLanguage === 'RU'; | |
| return ( | |
| <div className="max-w-4xl mx-auto px-4 py-10 relative overflow-hidden font-sans" id="pro-league-view"> | |
| {/* Dynamic Purple/Violet glow animations on corners like the upload image */} | |
| <div className="absolute top-0 left-0 w-80 h-80 bg-purple-600/15 rounded-full blur-[120px] pointer-events-none" /> | |
| <div className="absolute bottom-0 right-0 w-80 h-80 bg-fuchsia-600/10 rounded-full blur-[120px] pointer-events-none" /> | |
| {/* Main Container */} | |
| <div className="flex flex-col items-center justify-center space-y-6 relative z-10"> | |
| {/* POLISHED ESPORTS HEADLINE: PRO LIGA */} | |
| <div className="text-center space-y-3"> | |
| <h1 className="text-5xl md:text-6xl font-black text-white tracking-widest uppercase flex items-center justify-center gap-3 drop-shadow-[0_4px_12px_rgba(255,255,255,0.1)]"> | |
| <span>PRO</span> | |
| <span className="text-purple-400 font-extrabold rotate-3 transform inline-block bg-purple-500/10 border border-purple-500/30 px-2 rounded">⚡</span> | |
| <span>LIGA</span> | |
| </h1> | |
| {/* Active Round Badge (2-TUR) as styled in screen */} | |
| <div className="inline-block transform -skew-x-6 bg-purple-600 border border-purple-400 shadow-[0_0_15px_rgba(147,51,234,0.5)] px-6 py-1.5 text-xs font-black tracking-widest text-white uppercase"> | |
| 2-TUR | |
| </div> | |
| </div> | |
| {/* STANDINGS ACTIONS AND FILTERS */} | |
| <div className="w-full flex justify-end"> | |
| <button | |
| onClick={() => setIsCompareOpen(true)} | |
| className="flex items-center gap-2 px-5 py-2.5 rounded-xl bg-gradient-to-r from-cyan-500 to-purple-600 text-white text-xs font-black tracking-widest uppercase cursor-pointer hover:shadow-[0_0_20px_rgba(34,211,238,0.25)] hover:bg-gradient-to-r hover:from-cyan-450 hover:to-purple-550 active:scale-95 transition-all shadow-lg border border-white/5" | |
| style={{ minHeight: '44px' }} | |
| > | |
| <Scale className="w-4 h-4 text-cyan-200" /> | |
| <span>{cmpLabels.compare}</span> | |
| </button> | |
| </div> | |
| {/* STANDINGS TABLE CARD */} | |
| <div | |
| className="w-full bg-[#11121d]/90 border border-white/10 rounded-2xl shadow-2xl overflow-hidden backdrop-blur-xl transition-all relative" | |
| onMouseLeave={() => setHoveredTeams([])} | |
| > | |
| <div className="overflow-x-auto"> | |
| <table className="w-full text-left border-collapse"> | |
| <thead> | |
| <tr className="border-b border-white/10 text-[11px] md:text-xs font-bold text-slate-400 bg-[#161726]/80 select-none"> | |
| <th className="py-4 px-5 text-center w-14 font-semibold">{labels.rank}</th> | |
| <th className="py-4 px-5 font-semibold text-left">{labels.team}</th> | |
| <th className="py-4 px-4 text-center w-14 font-semibold">{labels.played}</th> | |
| <th className="py-4 px-4 text-center w-14 font-semibold">{labels.won}</th> | |
| <th className="py-4 px-4 text-center w-14 font-semibold">{labels.drawn}</th> | |
| <th className="py-4 px-4 text-center w-14 font-semibold">{labels.lost}</th> | |
| <th className="py-4 px-5 text-center w-20 font-semibold">{labels.goals}</th> | |
| <th className="py-4 px-4 text-center w-28 font-semibold">{labels.trend}</th> | |
| <th className="py-4 px-6 text-center w-16 font-semibold text-purple-400">{labels.points}</th> | |
| </tr> | |
| </thead> | |
| <tbody className="divide-y divide-white/5 text-sm font-semibold text-slate-200"> | |
| {activeTeams.length === 0 ? ( | |
| <tr> | |
| <td colSpan={9} className="py-16 px-6 text-center text-slate-400 font-medium"> | |
| <div className="flex flex-col items-center justify-center space-y-3"> | |
| <Trophy className="w-12 h-12 text-purple-400 opacity-60 animate-bounce" /> | |
| <p className="text-sm font-semibold uppercase tracking-wider font-mono"> | |
| {isUz ? "Hozircha Pro Liga jamoalari mavjud emas." : "No Pro Liga teams registered yet."} | |
| </p> | |
| <p className="text-xs text-slate-500 max-w-sm font-sans"> | |
| {isUz | |
| ? "Admin tomonidan yangi jamoalar qo'shilishini kuting yoki Admin panel orqali jamoa qo'shing." | |
| : "Wait for the admin to register teams or add them via the Admin Panel."} | |
| </p> | |
| </div> | |
| </td> | |
| </tr> | |
| ) : ( | |
| activeTeams.map((team, idx) => { | |
| const displayRank = idx + 1; | |
| const isTopRank = displayRank <= 3; | |
| const scoreDifference = team.goals || '0-0'; | |
| const isFavorited = favoriteTeamIds.includes(team.id); | |
| const isRivalA = hoveredTeams[0] === team.id; | |
| const isRivalB = hoveredTeams[1] === team.id; | |
| const isAnyRival = isRivalA || isRivalB; | |
| const hasTwoRivals = hoveredTeams.length === 2; | |
| const rivalryClass = isRivalA | |
| ? 'bg-cyan-500/[0.04] border-l-2 border-l-cyan-400 shadow-[inset_4px_0_12px_rgba(34,211,238,0.03)]' | |
| : 'bg-purple-500/[0.04] border-l-2 border-l-purple-500 shadow-[inset_4px_0_12px_rgba(168,85,247,0.03)]'; | |
| return ( | |
| <tr | |
| key={team.id} | |
| id={`row-${team.id}`} | |
| onMouseEnter={() => handleMouseEnterRow(team.id)} | |
| className={`transition-all duration-150 border-b border-white/5 cursor-pointer ${ | |
| hasTwoRivals && isAnyRival | |
| ? rivalryClass | |
| : isFavorited | |
| ? 'bg-amber-500/[0.02] hover:bg-amber-500/[0.04] border-l-2 border-l-amber-500/80 shadow-[inset_4px_0_12px_rgba(245,158,11,0.02)]' | |
| : 'hover:bg-white/[0.03]' | |
| }`} | |
| > | |
| {/* Rank Column */} | |
| <td className="py-4 px-5 text-center font-mono"> | |
| <span className={`inline-flex items-center justify-center w-6 h-6 rounded font-black ${ | |
| displayRank === 1 ? 'bg-amber-500/10 text-amber-400 border border-amber-500/20' : | |
| displayRank === 2 ? 'bg-slate-300/10 text-slate-300 border border-slate-300/20' : | |
| displayRank === 3 ? 'bg-amber-700/10 text-amber-600 border border-amber-700/20' : | |
| 'text-slate-400' | |
| }`}> | |
| {displayRank} | |
| </span> | |
| </td> | |
| {/* Team Logo/Emoji & Title */} | |
| <td className="py-4 px-5 font-bold text-white text-left"> | |
| <div className="flex items-center gap-3"> | |
| <button | |
| onClick={() => handleToggleFavorite(team.id)} | |
| className={`p-1.5 rounded-lg transition-all cursor-pointer shrink-0 flex items-center justify-center ${ | |
| isFavorited | |
| ? 'text-amber-400 bg-amber-400/10 hover:bg-amber-400/25 border border-amber-500/25' | |
| : 'text-slate-500 hover:text-slate-300 hover:bg-white/5 border border-transparent' | |
| }`} | |
| style={{ minWidth: '32px', minHeight: '32px' }} | |
| title={isFavorited ? "Remove from Favorites" : "Add to Favorites"} | |
| > | |
| <Star className={`w-3.5 h-3.5 ${isFavorited ? 'fill-amber-400 text-amber-400' : 'text-slate-500'}`} /> | |
| </button> | |
| <div className="w-8 h-8 rounded-xl bg-white/5 flex items-center justify-center text-lg shadow-inner ring-1 ring-white/10 shrink-0 overflow-hidden"> | |
| {team.logo && (team.logo.startsWith('data:') || team.logo.startsWith('http')) ? ( | |
| <img src={team.logo} className="w-full h-full object-contain" alt="" referrerPolicy="no-referrer" /> | |
| ) : ( | |
| <span className="text-lg">{team.logo || "🎮"}</span> | |
| )} | |
| </div> | |
| <div className="flex flex-col"> | |
| <span className="tracking-wide text-sm md:text-base">{team.name}</span> | |
| {team.tag && ( | |
| <span className="text-[10px] text-slate-500 font-mono font-bold">[{team.tag}]</span> | |
| )} | |
| </div> | |
| </div> | |
| </td> | |
| {/* Played Matches */} | |
| <td className="py-4 px-4 text-center font-mono font-medium text-slate-300"> | |
| {team.matchesPlayed ?? 0} | |
| </td> | |
| {/* Games Won */} | |
| <td className="py-4 px-4 text-center font-mono font-bold text-emerald-400"> | |
| {team.matchesWon ?? 0} | |
| </td> | |
| {/* Games Drawn */} | |
| <td className="py-4 px-4 text-center font-mono text-slate-400"> | |
| {team.draws ?? 0} | |
| </td> | |
| {/* Games Lost */} | |
| <td className="py-4 px-4 text-center font-mono text-rose-500/80"> | |
| {team.losses ?? 0} | |
| </td> | |
| {/* Goal Difference +/- Ratio */} | |
| <td className="py-4 px-5 text-center font-mono text-slate-300 font-bold bg-white/[0.01]"> | |
| {scoreDifference} | |
| </td> | |
| {/* Points Progression Sparkline */} | |
| <td className="py-2 px-4 text-center w-28 bg-white/[0.005]"> | |
| <div className="flex items-center justify-center h-8 w-24 mx-auto select-none" style={{ minWidth: '96px', minHeight: '32px' }}> | |
| <ResponsiveContainer width="100%" height="100%"> | |
| <AreaChart data={getPointsHistory(team, currentLanguage)} margin={{ top: 2, right: 2, left: 2, bottom: 2 }}> | |
| <defs> | |
| <linearGradient id={`sparklineGrad-${team.id}`} x1="0" y1="0" x2="0" y2="1"> | |
| <stop offset="5%" stopColor={isFavorited ? "#fbbf24" : "#a855f7"} stopOpacity={0.3} /> | |
| <stop offset="95%" stopColor={isFavorited ? "#fbbf24" : "#a855f7"} stopOpacity={0} /> | |
| </linearGradient> | |
| </defs> | |
| <Tooltip | |
| wrapperStyle={{ pointerEvents: 'none', zIndex: 100 }} | |
| cursor={{ stroke: isFavorited ? '#fbbf24' : '#c084fc', strokeWidth: 1, strokeDasharray: '2 2' }} | |
| content={({ active, payload }) => { | |
| if (active && payload && payload.length) { | |
| const data = payload[0].payload; | |
| const ptsLabel = isUz ? "Ochkolar" : currentLanguage === "RU" ? "Очки" : "Points"; | |
| return ( | |
| <div className="bg-[#0f1020]/95 border border-white/10 px-2 py-1.5 rounded-lg text-[9px] shadow-2xl backdrop-blur-md pointer-events-none min-w-[124px] text-left"> | |
| <div className="text-slate-400 font-mono font-bold leading-tight select-none"> | |
| {data.date} | |
| </div> | |
| <div className="flex items-center justify-between font-extrabold text-white font-mono mt-1"> | |
| <span className="text-[9px] uppercase tracking-wider text-slate-500">{ptsLabel}:</span> | |
| <span className={isFavorited ? "text-amber-400" : "text-purple-400"}>{data.val}</span> | |
| </div> | |
| </div> | |
| ); | |
| } | |
| return null; | |
| }} | |
| /> | |
| <Area | |
| type="monotone" | |
| dataKey="val" | |
| stroke={isFavorited ? "#fbbf24" : "#c084fc"} | |
| strokeWidth={1.5} | |
| fillOpacity={1} | |
| fill={`url(#sparklineGrad-${team.id})`} | |
| dot={{ r: 1.5, strokeWidth: 1, fill: isFavorited ? "#fbbf24" : "#c084fc" }} | |
| activeDot={{ r: 3 }} | |
| /> | |
| </AreaChart> | |
| </ResponsiveContainer> | |
| </div> | |
| </td> | |
| {/* Seasonal Accumulated points */} | |
| <td className="py-4 px-6 text-center font-mono font-black text-base text-cyan-400 bg-cyan-400/[0.02]"> | |
| {team.points ?? 0} | |
| </td> | |
| </tr> | |
| ); | |
| }) | |
| )} | |
| </tbody> | |
| </table> | |
| </div> | |
| {/* Real-time Rivalry Mode 'VS' Connecting Laser and Badge */} | |
| <AnimatePresence> | |
| {vsPosition && ( | |
| <> | |
| {/* Laser beam connecting the two rival rows */} | |
| <motion.div | |
| initial={{ opacity: 0, height: 0 }} | |
| animate={{ opacity: 0.8, height: vsPosition.height }} | |
| exit={{ opacity: 0, height: 0 }} | |
| className="absolute left-[28px] w-0.5 bg-gradient-to-b from-cyan-400 via-fuchsia-500 to-purple-500 pointer-events-none z-20" | |
| style={{ top: `${vsPosition.top}px` }} | |
| /> | |
| {/* Glowing VS pulse badge */} | |
| <motion.div | |
| initial={{ opacity: 0, scale: 0.8, y: -10 }} | |
| animate={{ opacity: 1, scale: 1, y: 0 }} | |
| exit={{ opacity: 0, scale: 0.8, y: -10 }} | |
| className="absolute left-[14px] pointer-events-none z-30 flex items-center justify-center" | |
| style={{ top: `${vsPosition.center - 14}px` }} | |
| > | |
| <div className="relative bg-gradient-to-br from-cyan-400 via-purple-500 to-fuchsia-600 text-[10px] font-black text-white w-7 h-7 rounded-full border border-white/20 shadow-[0_0_20px_rgba(139,92,246,0.8)] font-mono tracking-tighter flex items-center justify-center animate-pulse"> | |
| VS | |
| </div> | |
| </motion.div> | |
| </> | |
| )} | |
| </AnimatePresence> | |
| {/* Social Channels / Footer section as styled in screenshot */} | |
| <div className="bg-[#161726]/95 border-t border-white/10 px-6 py-5 flex flex-wrap items-center justify-center gap-x-6 gap-y-3 mt-auto"> | |
| <a | |
| href="https://facebook.com/cyberuzb" | |
| target="_blank" | |
| rel="noreferrer" | |
| className="flex items-center gap-2 text-[11px] font-mono text-slate-400 hover:text-blue-400 transition-colors uppercase tracking-wider" | |
| > | |
| <Facebook className="w-3.5 h-3.5 text-blue-500" /> | |
| <span>cyberuzb</span> | |
| </a> | |
| <a | |
| href="https://twitter.com/uzpfl" | |
| target="_blank" | |
| rel="noreferrer" | |
| className="flex items-center gap-2 text-[11px] font-mono text-slate-400 hover:text-sky-400 transition-colors uppercase tracking-wider" | |
| > | |
| <Twitter className="w-3.5 h-3.5 text-sky-400" /> | |
| <span>uzpfl</span> | |
| </a> | |
| <a | |
| href="https://instagram.com/pfl_uz" | |
| target="_blank" | |
| rel="noreferrer" | |
| className="flex items-center gap-2 text-[11px] font-mono text-slate-400 hover:text-pink-400 transition-colors uppercase tracking-wider" | |
| > | |
| <Globe className="w-3.5 h-3.5 text-pink-400" /> | |
| <span>pfl_uz</span> | |
| </a> | |
| <a | |
| href="https://t.me/uzpfl" | |
| target="_blank" | |
| rel="noreferrer" | |
| className="flex items-center gap-2 text-[11px] font-mono text-slate-400 hover:text-sky-400 transition-colors uppercase tracking-wider" | |
| > | |
| <Send className="w-3.5 h-3.5 text-cyan-400" /> | |
| <span>uzpfl</span> | |
| </a> | |
| </div> | |
| </div> | |
| </div> | |
| {/* Team Comparison Radar Modal */} | |
| <AnimatePresence> | |
| {isCompareOpen && ( | |
| <div className="fixed inset-0 z-50 flex items-center justify-center p-4"> | |
| {/* Backdrop */} | |
| <motion.div | |
| initial={{ opacity: 0 }} | |
| animate={{ opacity: 1 }} | |
| exit={{ opacity: 0 }} | |
| onClick={() => setIsCompareOpen(false)} | |
| className="fixed inset-0 bg-[#020205]/80 backdrop-blur-md" | |
| /> | |
| {/* Modal Panel */} | |
| <motion.div | |
| initial={{ opacity: 0, scale: 0.95, y: 20 }} | |
| animate={{ opacity: 1, scale: 1, y: 0 }} | |
| exit={{ opacity: 0, scale: 0.95, y: 20 }} | |
| transition={{ type: "spring", duration: 0.5 }} | |
| className="bg-[#0c0d19] border border-white/10 rounded-2xl max-w-3xl w-full text-left shadow-2xl relative overflow-hidden flex flex-col max-h-[90vh] z-10" | |
| > | |
| {/* Purple/cyan abstract glows inside modal */} | |
| <div className="absolute top-0 left-0 w-48 h-48 bg-cyan-500/10 rounded-full blur-[80px] pointer-events-none" /> | |
| <div className="absolute bottom-0 right-0 w-48 h-48 bg-purple-500/10 rounded-full blur-[80px] pointer-events-none" /> | |
| {/* Modal Header */} | |
| <div className="px-6 py-4 bg-[#111221] border-b border-white/10 flex justify-between items-center z-10"> | |
| <div className="flex items-center gap-2"> | |
| <Scale className="w-5 h-5 text-cyan-400" /> | |
| <span className="text-sm font-black tracking-wider uppercase text-white font-mono"> | |
| {cmpLabels.compare} | |
| </span> | |
| </div> | |
| <button | |
| onClick={() => setIsCompareOpen(false)} | |
| className="p-1.5 rounded-lg bg-white/5 hover:bg-white/10 text-slate-400 hover:text-white transition-colors cursor-pointer" | |
| > | |
| <X className="w-4 h-4" /> | |
| </button> | |
| </div> | |
| {/* Modal Body */} | |
| <div className="p-6 overflow-y-auto z-10 space-y-6"> | |
| {activeTeams.length === 0 ? ( | |
| <div className="text-center py-12 text-slate-400"> | |
| <Trophy className="w-12 h-12 mx-auto text-purple-400 opacity-60 mb-3 animate-bounce" /> | |
| <p className="text-sm font-semibold uppercase tracking-wider font-mono"> | |
| {isUz ? "Taqqoslash uchun jamoalar mavjud emas!" : "No teams available for comparison!"} | |
| </p> | |
| <p className="text-xs text-slate-500 mt-1 font-sans"> | |
| {isUz | |
| ? "Iltimos, avval Admin panel orqali jamoalar qo'shing." | |
| : "Please add teams through the Admin Panel first."} | |
| </p> | |
| </div> | |
| ) : ( | |
| <> | |
| {/* Team Selector Row */} | |
| <div className="grid grid-cols-1 sm:grid-cols-7 gap-4 items-center bg-white/[0.02] border border-white/5 p-4 rounded-xl"> | |
| {/* Team A Column */} | |
| <div className="sm:col-span-3 space-y-1.5 text-center sm:text-left"> | |
| <label className="text-[10px] uppercase font-bold text-slate-400 font-mono block"> | |
| {cmpLabels.teamA} | |
| </label> | |
| <select | |
| value={teamAId || activeTeams[0]?.id} | |
| onChange={(e) => setTeamAId(e.target.value)} | |
| className="w-full bg-[#161726]/90 border border-white/10 hover:border-cyan-400/30 focus:border-cyan-450 focus:ring-1 focus:ring-cyan-400/20 rounded-xl px-3 py-2.5 text-xs text-white outline-none cursor-pointer transition-all" | |
| > | |
| {activeTeams.map((t) => ( | |
| <option key={t.id} value={t.id} className="bg-[#11121d] text-white"> | |
| {t.logo && (t.logo.startsWith('data:') || t.logo.startsWith('http')) ? "🛡️" : t.logo} {t.name} | |
| </option> | |
| ))} | |
| </select> | |
| </div> | |
| {/* VS Indicator */} | |
| <div className="sm:col-span-1 flex justify-center text-center"> | |
| <span className="w-10 h-10 rounded-full bg-gradient-to-br from-cyan-400 to-purple-500 flex items-center justify-center text-xs font-black text-white shadow-[0_0_15px_rgba(34,211,238,0.2)]"> | |
| VS | |
| </span> | |
| </div> | |
| {/* Team B Column */} | |
| <div className="sm:col-span-3 space-y-1.5 text-center sm:text-right"> | |
| <label className="text-[10px] uppercase font-bold text-slate-400 font-mono block"> | |
| {cmpLabels.teamB} | |
| </label> | |
| <select | |
| value={teamBId || activeTeams[1]?.id} | |
| onChange={(e) => setTeamBId(e.target.value)} | |
| className="w-full bg-[#161726]/90 border border-white/10 hover:border-purple-400/30 focus:border-purple-450 focus:ring-1 focus:ring-purple-400/20 rounded-xl px-3 py-2.5 text-xs text-white outline-none cursor-pointer transition-all" | |
| > | |
| {activeTeams.map((t) => ( | |
| <option key={t.id} value={t.id} className="bg-[#11121d] text-white"> | |
| {t.logo && (t.logo.startsWith('data:') || t.logo.startsWith('http')) ? "🛡️" : t.logo} {t.name} | |
| </option> | |
| ))} | |
| </select> | |
| </div> | |
| </div> | |
| {/* Main Visuals & Side-by-Side comparative chart */} | |
| <div className="grid grid-cols-1 md:grid-cols-12 gap-6 items-center"> | |
| {/* Left Column: Metric split list */} | |
| <div className="md:col-span-5 bg-white/[0.01] border border-white/5 p-4 rounded-xl space-y-4"> | |
| <h3 className="text-xs font-black tracking-wider text-slate-300 font-mono uppercase pb-2 border-b border-white/5"> | |
| {cmpLabels.headToHead} | |
| </h3> | |
| <div className="space-y-4"> | |
| {metrics.map((m) => { | |
| const rawA = statsA[m.key as keyof typeof statsA] ?? 0; | |
| const rawB = statsB[m.key as keyof typeof statsB] ?? 0; | |
| const pctA = Math.round((rawA / m.fullMark) * 100); | |
| const pctB = Math.round((rawB / m.fullMark) * 100); | |
| return ( | |
| <div key={m.name} className="space-y-1.5"> | |
| <div className="flex justify-between items-center text-xs font-semibold"> | |
| <span className="text-cyan-400 font-mono font-bold">{m.key === 'winRate' ? `${rawA}%` : rawA}</span> | |
| <span className="text-slate-400 font-bold uppercase tracking-wider text-[10px]">{m.name}</span> | |
| <span className="text-purple-400 font-mono font-bold">{m.key === 'winRate' ? `${rawB}%` : rawB}</span> | |
| </div> | |
| <div className="h-2 w-full bg-white/5 rounded-full flex overflow-hidden"> | |
| {/* Team A bar */} | |
| <div | |
| className="bg-gradient-to-l from-cyan-400 to-cyan-500 h-full rounded-l-full transition-all duration-300" | |
| style={{ width: `${Math.max(4, pctA / 2)}%`, marginLeft: 'auto' }} | |
| /> | |
| {/* Split divider */} | |
| <div className="w-[2px] bg-[#0c0d19] z-10" /> | |
| {/* Team B bar */} | |
| <div | |
| className="bg-gradient-to-r from-purple-500 to-purple-600 h-full rounded-r-full transition-all duration-300" | |
| style={{ width: `${Math.max(4, pctB / 2)}%`, marginRight: 'auto' }} | |
| /> | |
| </div> | |
| </div> | |
| ); | |
| })} | |
| </div> | |
| </div> | |
| {/* Right Column: Radar Chart visualization */} | |
| <div className="md:col-span-7 bg-white/[0.01] border border-white/5 p-4 rounded-xl flex items-center justify-center relative min-h-[300px]"> | |
| <div className="absolute inset-0 bg-radial-gradient from-purple-950/20 via-transparent to-transparent pointer-events-none" /> | |
| <div className="w-full h-72"> | |
| <ResponsiveContainer width="100%" height="100%"> | |
| <RadarChart cx="50%" cy="50%" outerRadius="62%" data={chartData}> | |
| <PolarGrid stroke="rgba(255, 255, 255, 0.08)" /> | |
| <PolarAngleAxis | |
| dataKey="metric" | |
| tick={{ fill: '#94a3b8', fontSize: 10, fontWeight: 700 }} | |
| /> | |
| <PolarRadiusAxis | |
| angle={30} | |
| domain={[0, 100]} | |
| tick={{ fill: '#475569', fontSize: 8 }} | |
| axisLine={false} | |
| /> | |
| <Radar | |
| name={`${teamA.logo} ${teamA.name}`} | |
| dataKey={teamA.name} | |
| stroke="#22d3ee" | |
| fill="#22d3ee" | |
| fillOpacity={0.2} | |
| strokeWidth={2} | |
| /> | |
| <Radar | |
| name={`${teamB.logo} ${teamB.name}`} | |
| dataKey={teamB.name} | |
| stroke="#c084fc" | |
| fill="#c084fc" | |
| fillOpacity={0.2} | |
| strokeWidth={2} | |
| /> | |
| <Tooltip | |
| content={({ active, payload }) => { | |
| if (active && payload && payload.length) { | |
| const data = payload[0].payload; | |
| return ( | |
| <div className="bg-[#0f1020]/95 border border-white/10 p-3 rounded-xl text-[10px] space-y-1.5 shadow-xl backdrop-blur-md"> | |
| <p className="font-extrabold text-slate-300 uppercase font-mono tracking-wider">{data.metric}</p> | |
| <div className="flex items-center gap-3 justify-between font-bold text-cyan-400"> | |
| <span>{teamA.logo} {teamA.name}:</span> | |
| <span className="font-black text-white font-mono">{data.teamA_raw}</span> | |
| </div> | |
| <div className="flex items-center gap-3 justify-between font-bold text-purple-400"> | |
| <span>{teamB.logo} {teamB.name}:</span> | |
| <span className="font-black text-white font-mono">{data.teamB_raw}</span> | |
| </div> | |
| </div> | |
| ); | |
| } | |
| return null; | |
| }} | |
| /> | |
| <Legend | |
| verticalAlign="bottom" | |
| height={32} | |
| wrapperStyle={{ fontSize: '10px', fontWeight: 700, textTransform: 'uppercase', color: '#94a3b8' }} | |
| /> | |
| </RadarChart> | |
| </ResponsiveContainer> | |
| </div> | |
| </div> | |
| </div> | |
| </> | |
| )} | |
| </div> | |
| {/* Modal Footer */} | |
| <div className="px-6 py-4 bg-[#111221] border-t border-white/10 flex justify-end z-10"> | |
| <button | |
| onClick={() => setIsCompareOpen(false)} | |
| className="px-5 py-2.5 rounded-xl bg-white/5 hover:bg-white/10 hover:text-white text-slate-300 text-xs font-black tracking-widest uppercase transition-all cursor-pointer" | |
| style={{ minHeight: '44px' }} | |
| > | |
| {cmpLabels.close} | |
| </button> | |
| </div> | |
| </motion.div> | |
| </div> | |
| )} | |
| </AnimatePresence> | |
| {toastMsg && ( | |
| <div className="fixed top-8 right-8 z-50 bg-rose-500/90 border border-rose-400 text-white px-6 py-4 rounded-xl shadow-2xl flex items-center gap-2.5 backdrop-blur-md animate-in slide-in-from-top-4 duration-300"> | |
| <span className="text-xs font-bold uppercase tracking-wider font-mono">⚠️ {toastMsg}</span> | |
| </div> | |
| )} | |
| </div> | |
| ); | |
| }; | |