AnayShukla commited on
Commit
d2f22d5
·
1 Parent(s): 6ed24e2

team ratings tab fix

Browse files
frontend/src/components/PitchView.jsx CHANGED
@@ -20,7 +20,7 @@ export const PitchView = ({
20
  chipsByGw,
21
  }) => {
22
  return (
23
- <div className="w-full bg-[#0a3a2a] rounded-2xl border-4 border-[#072a1e] min-h-[650px] xl:min-h-[850px] relative overflow-hidden flex flex-col shadow-[0_0_50px_rgba(0,0,0,0.5)]">
24
  {/* PITCH LINES */}
25
  <div className="absolute inset-0 pointer-events-none opacity-30 flex flex-col items-center">
26
  <div className="w-full h-1/2 border-b-2 border-white/40 absolute top-0"></div>
@@ -34,7 +34,7 @@ export const PitchView = ({
34
 
35
  {/* STARTERS */}
36
  <div className="flex-1 w-full overflow-x-auto custom-scrollbar">
37
- <div className="flex flex-col justify-evenly gap-y-10 z-10 pt-8 pb-12 px-4 min-w-max sm:min-w-0 min-h-full h-full mx-auto">
38
  {["G", "D", "M", "F"].map((pos) => {
39
  const rowPlayers = teamData.slice(0, 11).filter((p) => p.Pos === pos);
40
  if (rowPlayers.length === 0) return null;
 
20
  chipsByGw,
21
  }) => {
22
  return (
23
+ <div className="w-full bg-[#0a3a2a] rounded-2xl border-4 border-[#072a1e] min-h-[540px] sm:min-h-[700px] xl:min-h-[850px] relative overflow-hidden flex flex-col shadow-[0_0_50px_rgba(0,0,0,0.5)]">
24
  {/* PITCH LINES */}
25
  <div className="absolute inset-0 pointer-events-none opacity-30 flex flex-col items-center">
26
  <div className="w-full h-1/2 border-b-2 border-white/40 absolute top-0"></div>
 
34
 
35
  {/* STARTERS */}
36
  <div className="flex-1 w-full overflow-x-auto custom-scrollbar">
37
+ <div className="flex flex-col justify-evenly gap-y-4 sm:gap-y-10 z-10 pt-6 sm:pt-8 pb-10 sm:pb-12 px-2 sm:px-4 min-w-max sm:min-w-0 min-h-full h-full mx-auto">
38
  {["G", "D", "M", "F"].map((pos) => {
39
  const rowPlayers = teamData.slice(0, 11).filter((p) => p.Pos === pos);
40
  if (rowPlayers.length === 0) return null;
frontend/src/components/PlayerCardVisual.jsx CHANGED
@@ -22,7 +22,7 @@ export const PlayerCardVisual = ({
22
  return (
23
  <div
24
  onClick={onPlayerClick}
25
- className="relative w-[64px] sm:w-[76px] md:w-[88px] h-[90px] sm:h-[105px] md:h-[120px] flex flex-col items-center justify-center cursor-pointer border-2 border-dashed border-slate-500 bg-slate-900/60 rounded-xl hover:bg-slate-800 hover:border-emerald-400 transition-all z-20 shadow-inner group"
26
  >
27
  {player.replacedPlayer && (
28
  <div className="absolute left-[-14px] top-[-10px] flex flex-col gap-1 z-40 pointer-events-auto">
@@ -147,7 +147,7 @@ export const PlayerCardVisual = ({
147
  return (
148
  <div
149
  onClick={onPlayerClick}
150
- className="relative w-[64px] sm:w-[76px] md:w-[88px] h-[90px] sm:h-[105px] md:h-[120px] flex flex-col items-center transform-gpu justify-end cursor-grab active:cursor-grabbing"
151
  >
152
  <div className="absolute left-[-14px] top-[-10px] flex flex-col gap-1 z-40 pointer-events-auto">
153
  {!isBench && handleCapChange && (
 
22
  return (
23
  <div
24
  onClick={onPlayerClick}
25
+ className="relative w-[64px] sm:w-[76px] md:w-[88px] h-[85px] sm:h-[105px] md:h-[120px] flex flex-col items-center justify-center cursor-pointer border-2 border-dashed border-slate-500 bg-slate-900/60 rounded-xl hover:bg-slate-800 hover:border-emerald-400 transition-all z-20 shadow-inner group transform scale-[0.82] sm:scale-100 origin-bottom"
26
  >
27
  {player.replacedPlayer && (
28
  <div className="absolute left-[-14px] top-[-10px] flex flex-col gap-1 z-40 pointer-events-auto">
 
147
  return (
148
  <div
149
  onClick={onPlayerClick}
150
+ className="relative w-[64px] sm:w-[76px] md:w-[88px] h-[85px] sm:h-[105px] md:h-[120px] flex flex-col items-center justify-end cursor-grab active:cursor-grabbing transform scale-[0.82] sm:scale-100 origin-bottom"
151
  >
152
  <div className="absolute left-[-14px] top-[-10px] flex flex-col gap-1 z-40 pointer-events-auto">
153
  {!isBench && handleCapChange && (
frontend/src/components/TeamRatings.jsx CHANGED
@@ -1,5 +1,14 @@
1
  import React, { useState, useEffect } from 'react';
2
 
 
 
 
 
 
 
 
 
 
3
  export default function TeamRatings() {
4
  const [data, setData] = useState([]);
5
  const [isLoading, setIsLoading] = useState(true);
@@ -73,6 +82,7 @@ export default function TeamRatings() {
73
  {data.map(team => {
74
  const leftPct = ((maxDef - team.Defence) / (maxDef - minDef)) * 100;
75
  const bottomPct = ((team.Attack - minAttack) / (maxAttack - minAttack)) * 100;
 
76
 
77
  return (
78
  <div
@@ -80,10 +90,10 @@ export default function TeamRatings() {
80
  className="absolute w-10 h-10 -ml-5 -mb-5 group z-10 hover:z-50 transition-transform hover:scale-125 cursor-pointer"
81
  style={{ left: `${leftPct}%`, bottom: `${bottomPct}%` }}
82
  >
83
- {team.Logo ? (
84
- <img src={team.Logo} alt={team.Team} className="w-full h-full object-contain drop-shadow-xl" />
85
  ) : (
86
- <div className="w-4 h-4 m-3 bg-luigi-500 rounded-full shadow-[0_0_15px_rgba(16,185,129,0.8)]" />
87
  )}
88
 
89
  <div className="absolute bottom-full left-1/2 -translate-x-1/2 mb-2 w-max px-3 py-2 bg-slate-900 border border-slate-700 text-xs rounded opacity-0 group-hover:opacity-100 pointer-events-none shadow-2xl z-50 transition-opacity">
 
1
  import React, { useState, useEffect } from 'react';
2
 
3
+ const TEAM_LOGOS = {
4
+ "Arsenal": 57, "Manchester City": 65, "Liverpool": 64, "Chelsea": 61,
5
+ "Newcastle United": 67, "Aston Villa": 58, "Manchester United": 66,
6
+ "Brentford": 402, "Brighton and Hove Albion": 397, "AFC Bournemouth": 1044,
7
+ "Tottenham Hotspur": 73, "Crystal Palace": 354, "Fulham": 63,
8
+ "Nottingham Forest": 351, "Everton": 62, "Leeds United": 341,
9
+ "West Ham United": 563, "Wolverhampton Wanderers": 76, "Sunderland": 71, "Burnley": 328,
10
+ };
11
+
12
  export default function TeamRatings() {
13
  const [data, setData] = useState([]);
14
  const [isLoading, setIsLoading] = useState(true);
 
82
  {data.map(team => {
83
  const leftPct = ((maxDef - team.Defence) / (maxDef - minDef)) * 100;
84
  const bottomPct = ((team.Attack - minAttack) / (maxAttack - minAttack)) * 100;
85
+ const logoId = TEAM_LOGOS[team.Team];
86
 
87
  return (
88
  <div
 
90
  className="absolute w-10 h-10 -ml-5 -mb-5 group z-10 hover:z-50 transition-transform hover:scale-125 cursor-pointer"
91
  style={{ left: `${leftPct}%`, bottom: `${bottomPct}%` }}
92
  >
93
+ {logoId ? (
94
+ <img src={`/logos/${logoId}.png`} alt={team.Team} className="w-full h-full object-contain md:drop-shadow-xl" />
95
  ) : (
96
+ <div className="w-4 h-4 m-3 bg-luigi-500 rounded-full md:shadow-[0_0_15px_rgba(16,185,129,0.8)]" />
97
  )}
98
 
99
  <div className="absolute bottom-full left-1/2 -translate-x-1/2 mb-2 w-max px-3 py-2 bg-slate-900 border border-slate-700 text-xs rounded opacity-0 group-hover:opacity-100 pointer-events-none shadow-2xl z-50 transition-opacity">
logos/1044.png DELETED

Git LFS Details

  • SHA256: 2703d4d22a050434985764fd8512bdc83dc967b022f854668811b03aa05f2155
  • Pointer size: 129 Bytes
  • Size of remote file: 7.59 kB
logos/328.png DELETED

Git LFS Details

  • SHA256: a418607981308fd980be2246d4885b2f6794ebad33e0980315dd90e392b707e5
  • Pointer size: 130 Bytes
  • Size of remote file: 12.9 kB
logos/341.png DELETED

Git LFS Details

  • SHA256: 16e5872c0127c093f14e8338b2ba1d79bc307cc24dcc690ca820c85c3af056f0
  • Pointer size: 129 Bytes
  • Size of remote file: 6.89 kB
logos/351.png DELETED

Git LFS Details

  • SHA256: d4098e62317e19e6dc92d806ded0e77ba7714b22728998466a441aef0c8e9025
  • Pointer size: 129 Bytes
  • Size of remote file: 5.1 kB
logos/354.png DELETED

Git LFS Details

  • SHA256: 8cd5323ea26846f9991bd5604ae63e124f81e5e3feda7716a3f038ab5151458c
  • Pointer size: 130 Bytes
  • Size of remote file: 15.5 kB
logos/397.png DELETED

Git LFS Details

  • SHA256: b2a60525561839e8a113d95ec80598f8398a28b568124e3d9b15c69c651f5d07
  • Pointer size: 129 Bytes
  • Size of remote file: 7.47 kB
logos/402.png DELETED

Git LFS Details

  • SHA256: 165adcf2e24288dcabd3e5d5e5de3b83e58e7c549aaa2c6101a37159a12c1753
  • Pointer size: 130 Bytes
  • Size of remote file: 15.5 kB
logos/563.png DELETED

Git LFS Details

  • SHA256: 11e0ae907552888ef9190265cdef5f9b0f3e23052575870dc9fcf47ddca71898
  • Pointer size: 129 Bytes
  • Size of remote file: 6.86 kB
logos/57.png DELETED

Git LFS Details

  • SHA256: 36e761b46213d8fa6deb1ddd94add8b61060a74fab48ca77a1f28827ff37d209
  • Pointer size: 130 Bytes
  • Size of remote file: 10.3 kB
logos/58.png DELETED

Git LFS Details

  • SHA256: cd9d0e04bb7d781bca31fb8575de5ede409e4775db07a2cf64da7cbc3ee93202
  • Pointer size: 129 Bytes
  • Size of remote file: 5.92 kB
logos/61.png DELETED

Git LFS Details

  • SHA256: bb79d3ccd973afb7802d4d48fb9b58de8940e9ac2183b66df28d83b61c1bfc6a
  • Pointer size: 130 Bytes
  • Size of remote file: 14.3 kB
logos/62.png DELETED

Git LFS Details

  • SHA256: 9d8062665589e8089e67175fe479efb2a647b6bd0ec7883a9602fc9557a788d7
  • Pointer size: 130 Bytes
  • Size of remote file: 12.4 kB
logos/63.png DELETED

Git LFS Details

  • SHA256: c84fb63fdd0a20e9268e2e5d967fd459b15c1e4194f8d4197a84a071b68187e2
  • Pointer size: 129 Bytes
  • Size of remote file: 3.73 kB
logos/64.png DELETED

Git LFS Details

  • SHA256: e98ce271542dfc14ecaee2b5b6b228841a8ca19751f537eacec2fe66820fbcce
  • Pointer size: 130 Bytes
  • Size of remote file: 15 kB
logos/65.png DELETED

Git LFS Details

  • SHA256: d3602d5a8ecc240c6685d935a502fe56167d127ee53810e3ff618d2bba9db432
  • Pointer size: 130 Bytes
  • Size of remote file: 14.8 kB
logos/66.png DELETED

Git LFS Details

  • SHA256: 5bd8bd07d24ac133a75c2c7d93886b5d586cb84a41281378a98b0ef827850846
  • Pointer size: 130 Bytes
  • Size of remote file: 16.3 kB
logos/67.png DELETED

Git LFS Details

  • SHA256: 93ac1da648d20a87e9661564752e32f7d7be2e3d835917807207713149f2b571
  • Pointer size: 130 Bytes
  • Size of remote file: 16.2 kB
logos/71.png DELETED

Git LFS Details

  • SHA256: 7690bab9be9d1712314b3982efcca442649f9ea75ad9ca3c4cce54c3621a35aa
  • Pointer size: 130 Bytes
  • Size of remote file: 11.1 kB
logos/73.png DELETED

Git LFS Details

  • SHA256: 2cfcd7ca5dd94737e52e965f5a44de45da5d08181410737722cd7d9929c5b1a4
  • Pointer size: 129 Bytes
  • Size of remote file: 4.28 kB
logos/76.png DELETED

Git LFS Details

  • SHA256: ab19a729b23877189ac54b7ff7c5b8c10d46adcea98d04b782beff0d4380e950
  • Pointer size: 129 Bytes
  • Size of remote file: 3.04 kB
main.py CHANGED
@@ -514,47 +514,11 @@ def update_player(req: UpdateRequest):
514
 
515
  @app.get("/api/ratings")
516
  def get_ratings():
517
- import base64
518
-
519
  if os.path.exists("team_ratings_dual_speed.csv"):
520
  df = pd.read_csv("team_ratings_dual_speed.csv")
521
  df.rename(columns=lambda x: x.strip(), inplace=True)
522
-
523
- # Team IDs mapping for the logos
524
- team_ids = {
525
- "Arsenal": 57,
526
- "Manchester City": 65,
527
- "Liverpool": 64,
528
- "Chelsea": 61,
529
- "Newcastle United": 67,
530
- "Aston Villa": 58,
531
- "Manchester United": 66,
532
- "Brentford": 402,
533
- "Brighton and Hove Albion": 397,
534
- "AFC Bournemouth": 1044,
535
- "Tottenham Hotspur": 73,
536
- "Crystal Palace": 354,
537
- "Fulham": 63,
538
- "Nottingham Forest": 351,
539
- "Everton": 62,
540
- "Leeds United": 341,
541
- "West Ham United": 563,
542
- "Wolverhampton Wanderers": 76,
543
- "Sunderland": 71,
544
- "Burnley": 328,
545
- }
546
-
547
- def get_logo(t_name):
548
- tid = team_ids.get(t_name)
549
- logo_path = f"logos/{tid}.png"
550
- if tid and os.path.exists(logo_path):
551
- with open(logo_path, "rb") as f:
552
- return (
553
- "data:image/png;base64," + base64.b64encode(f.read()).decode()
554
- )
555
- return None
556
-
557
- df["Logo"] = df["Team"].apply(get_logo)
558
  return df.to_dict(orient="records")
559
  return []
560
 
 
514
 
515
  @app.get("/api/ratings")
516
  def get_ratings():
 
 
517
  if os.path.exists("team_ratings_dual_speed.csv"):
518
  df = pd.read_csv("team_ratings_dual_speed.csv")
519
  df.rename(columns=lambda x: x.strip(), inplace=True)
520
+ # Strip trailing spaces just in case!
521
+ df["Team"] = df["Team"].str.strip()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
522
  return df.to_dict(orient="records")
523
  return []
524