-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ededdneddyfan/add_leaderboard_tab
Add leaderboard tab, about tab, remove a bunch of unused stuff. point db at readonly mysql
- Loading branch information
Showing
34 changed files
with
161 additions
and
693 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from "react"; | ||
|
||
const About: React.FC = () => ( | ||
<div className="container mx-auto px-4 mt-8"> | ||
<div className="bg-gray-800 shadow-md rounded-lg p-8 max-w-3xl mx-auto text-gray-200"> | ||
<h2 className="text-2xl font-bold mb-6">TFPugs</h2> | ||
<div className="space-y-4"> | ||
<p> | ||
TFpugs is a discord community for playing Team Fortress Classic pickup games, we mostly play 4v4 CTF games. | ||
</p> | ||
<p> | ||
I'm EDEdDNEdDYFaN on discord as well as everywhere else online. | ||
</p> | ||
<div className="flex items-center space-x-2"> | ||
<a | ||
href="https://bsky.app/profile/sethn.gg" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className="text-blue-400 hover:text-blue-300 flex items-center" | ||
> | ||
<svg className="w-5 h-5 mr-1" viewBox="0 0 24 24" fill="currentColor"> | ||
<path d="M12 2L2 19.5h20L12 2zm0 4l6.5 11.5h-13L12 6z" /> | ||
</svg> | ||
@sethn.gg | ||
</a> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
|
||
export default About; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import { Link } from "react-router-dom"; | ||
|
||
interface Player { | ||
id: number; | ||
player_name: string; | ||
current_elo: number; | ||
discord_id: string; | ||
pug_wins: number; | ||
pug_losses: number; | ||
pug_draws: number; | ||
} | ||
|
||
const Leaderboard: React.FC = () => { | ||
const [players, setPlayers] = useState<Player[]>([]); | ||
const [loading, setLoading] = useState(true); | ||
|
||
useEffect(() => { | ||
fetch('/api/players/by-elo') | ||
.then(response => response.json()) | ||
.then(data => { | ||
setPlayers(data); | ||
setLoading(false); | ||
}) | ||
.catch(error => { | ||
console.error('Error fetching leaderboard:', error); | ||
setLoading(false); | ||
}); | ||
}, []); | ||
|
||
if (loading) return <div className="text-center mt-4">Loading...</div>; | ||
|
||
return ( | ||
<div className="container mx-auto px-4 mt-8"> | ||
<h2 className="text-2xl font-bold mb-4">Leaderboard</h2> | ||
<div className="bg-gray-800 shadow-md rounded-lg overflow-hidden"> | ||
<table className="min-w-full"> | ||
<thead className="bg-gray-900 text-white"> | ||
<tr> | ||
<th className="px-6 py-3 text-left">Rank</th> | ||
<th className="px-6 py-3 text-left">Player</th> | ||
<th className="px-6 py-3 text-right">ELO</th> | ||
<th className="px-6 py-3 text-right">W</th> | ||
<th className="px-6 py-3 text-right">L</th> | ||
<th className="px-6 py-3 text-right">D</th> | ||
<th className="px-6 py-3 text-right">Win %</th> | ||
</tr> | ||
</thead> | ||
<tbody className="divide-y divide-gray-700"> | ||
{players.map((player, index) => ( | ||
<tr key={player.id} className="bg-gray-800 hover:bg-gray-700 text-gray-200"> | ||
<td className="px-6 py-4">{index + 1}</td> | ||
<td className="px-6 py-4"> | ||
<Link | ||
to={`/player/${player.player_name}`} | ||
className="text-blue-400 hover:text-blue-300" | ||
> | ||
{player.player_name} | ||
</Link> | ||
</td> | ||
<td className="px-6 py-4 text-right">{player.current_elo}</td> | ||
<td className="px-6 py-4 text-right text-green-400">{player.pug_wins}</td> | ||
<td className="px-6 py-4 text-right text-red-400">{player.pug_losses}</td> | ||
<td className="px-6 py-4 text-right text-gray-400">{player.pug_draws}</td> | ||
<td className="px-6 py-4 text-right"> | ||
{((player.pug_wins / (player.pug_wins + player.pug_losses)) * 100 || 0).toFixed(1)}% | ||
</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Leaderboard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
pub mod auth; | ||
pub mod notes; | ||
pub mod user; | ||
pub mod matches; | ||
pub mod players; | ||
pub mod player_elo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.